Question

When trying to add SharpSVN to my C# project, compiling with SharpSVN related calls gives me this error:

FileLoadException was Unhandled 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 I did was add the References from the downloaded SharpSVN zip file and added the

using SharpSvn;

When I compile that it works fine, but when I add:

string targetPath = "https://bobl/svn/ConsoleApplication1";

SvnTarget target;
SvnTarget.TryParse(targetPath, out target);

It breaks with that error. I've searched this error and have had no luck in finding a solution.

Was it helpful?

Solution

The SharpSVN assembly is a mixed assembly built against version 2.0 of the CLR.
Therefore, it cannot be loaded in CLR version 4.0.

You need to change your project to target .Net 3.5 (or earlier) in Project Properties.
Since .Net 2.0, .Net 3.0, and .Net 3.5 all use version 2.0 of the CLR, it will work in any of those versions.

OTHER TIPS

Add this to your app.config if you want to keep targeting .NET 4:

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

This will enable the loading support of mixed mode assemblies (mostly C++/CLI assemblies containing both unmanaged and managed code) built for an older version of the framework.

As Julien mentioned you need to add the compatibility code to your project's app.config or web.config:

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

This is all well and good, but if you are having this problem with a test runner (like MSTest) inside Visual Studio, you actually have to make this change to the test runner's config file.

I wrote a post about this very problem in VS 2012:

http://www.diaryofaninja.com/blog/2012/09/13/net-20-mixed-mode-assemblies-in-visual-studio-net-45-test-projects

In Visual Studio 2012, you need to add the startup code to the following file:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.executionengine86.exe.config
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top