开发者

SharpSVN error in VS2010

开发者 https://www.devze.com 2023-04-06 02:49 出处:网络
I\'m trying to get SharpSVN to work with a VB.NET project I\'m working on in VS2010. I\'ve added SharpSVN.dll to my project references but the following error appears when I try to load the site:

I'm trying to get SharpSVN to work with a VB.NET project I'm working on in VS2010. I've added SharpSVN.dll to my project references but the following error appears when I try to load the site:

Could not load file or assembly 'SharpSvn' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.BadImageFormatException: Could not load file or assembly 'SharpSvn' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of 开发者_StackOverflow社区the exception can be identified using the exception stack trace below.

My machine is 64-bit, and I've set the Configuration Manager to build to x64 as well as copied the 64-bit version of SharpSVN.dll into my project's bin directory. Additionally, I've also tried setting build to x86 and using the x86 version of SharpSVN.dll and the same error appears (so I suspect the error may not be directly related to instruction set family).

In my config file, I've tried adding the following to the assemblies attribute:

<add assembly="SharpSvn, Version=1.6016.1637.10768, Culture=neutral, PublicKeyToken=d729672594885a28"/>

Any ideas?


I have the same error and can't explain what's going on. However, with the 32bit version, the error is more descriptive:

Unhandled Exception: System.IO.FileLoadException: Mixed mode assembly is built against 
  version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without 
  additional configuration information.

Which you can fix by adding the following snippet to your app.config

<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0"/>
</startup>

Not sure what's wrong with the 64bit version, but you can always build it from source.


Despite thinking that <add assembly> was enough, I actually solved this issue by adding SharpSvn to GAC (in case anybody is running into this problem as well).


I am not sure why adding to the GAC worked for you, this is not the correct behavior for the assembly loader.

The error refers to the bitness of an assembly. SharpSVN is a mixed mode assembly, ie: it contains both managed and unmanaged code. You must specifically target x86 (with the x86 SharpSVN Assembly) or x64 (again with appropriate assembly). You must further set all your assemblies to be explicitly x86 or x64. Targeting Any CPU will allow the runtime to make this decision for you, and it will fail to load SharpSvn.dll if it picks a word length that does not match the SharpSvn DLL.

0

精彩评论

暂无评论...
验证码 换一张
取 消