SharpSVN error in VS2010
Asked Answered
R

3

2

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 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?

Rosanarosane answered 19/9, 2011 at 16:31 Comment(1)
I've got a similar problem, sort of. I'm getting that error, but my project doesn't even use SharpSVN anymore (it used to awhile back, but we removed it). Been working fine for months, suddenly failed overnight with no changes made. Very frustrating as there don't appear to be any references to SharpSVN anywhere in the project or on the system.Hazzard
R
1

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).

Rosanarosane answered 20/9, 2011 at 13:49 Comment(1)
I had the same problem and I've solved it by using the x86 version. Neither the project settings, nor GAC helped. Sth odd is going on here...Janka
S
1

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.

Simplify answered 19/9, 2011 at 18:33 Comment(1)
I've tried adding that snippet already and VS tells me that schema information for the attribute could not be found. I'm not sure if it actually prevents compilation or not, so I'll give it a try. Thanks!Rosanarosane
R
1

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).

Rosanarosane answered 20/9, 2011 at 13:49 Comment(1)
I had the same problem and I've solved it by using the x86 version. Neither the project settings, nor GAC helped. Sth odd is going on here...Janka
E
1

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.

Education answered 24/10, 2011 at 15:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.