SharpSVN error in VS2010

I am trying to get SharpSVN to work with a VB.NET project that I am working on in VS2010. I added SharpSVN.dll to my project links, but when I try to download the site, the following error appears:

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. View the stack trace for more information about the error and its occurrence in the code.

Exception Details: System.BadImageFormatException: Failed to load file or assembly "SharpSvn" or one of its dependencies. An attempt was made to download a program with the wrong format.

Source Error:

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

My machine is 64-bit, and I installed Configuration Manager to build on x64, and also copied the 64-bit version of SharpSVN.dll into my project bin directory. In addition, I also tried installing the assembly on x86 and using the version of SharpSVN.dll x86 and the same error appeared (so I suspect that the error may not be directly related to the instruction set family).

In my configuration file, I tried to add the following to the assemblys attribute:

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

Any ideas?

+2
sharpsvn
source share
3 answers

Despite the fact that <add assembly> was enough, I really solved this problem by adding SharpSvn to the GAC (in case someone also runs into this problem).

+1
source share

I have the same error and cannot explain what is happening. However, with the 32-bit 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. 

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

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

Not sure what happened with the 64-bit version, but you can always create it from the source .

+1
source share

I'm not sure why adding to the GAC worked for you, this is the wrong behavior for the assembly loader.

The error relates to the bitness of the assembly. SharpSVN is a mixed-mode assembly, that is: it contains both managed and unmanaged code. You must specifically configure x86 (using the x86 SharpSVN build) or x64 (again with the appropriate build). You must additionally install all your assemblies explicitly on x86 or x64. Targeting Any processor will allow the runtime to make this decision for you, and it will not be able to load SharpSvn.dll if it selects a word length that does not match the SharpSvn DLL.

+1
source share

All Articles