1

When I turn on Code Coverage in my test settings, on a project that references the Unity DI container I get the following error:

Cannot initialize the ASP.NET project '{Project Name}'.

The event log specifies the following reason:

Could not load file or assembly 'Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name signature could not be verified.

How do I get around this issue?

I am running Visual Studio 2010 Ultimate on a Windows 7 X64 machine.

Kimoz
  • 375
  • 4
  • 11
  • possible duplicate of [Test run errors with MSTest in VS2010](http://stackoverflow.com/questions/2761587/test-run-errors-with-mstest-in-vs2010) – Tomas Aschan May 23 '10 at 15:33
  • I see that now. Though the answer came to this question. An way of combining the answers? – Kimoz May 23 '10 at 17:45

2 Answers2

4

How do I get around this issue?

A shot in the dark without knowing the root cause: Have you tried using the strong name utility to skip verification of the offending assembly(s)?

sn -Vr <assembly>
Curt Nichols
  • 2,757
  • 1
  • 17
  • 24
  • Wow, this is what I've had same problem and sn -Vr "Microsoft.Practices.Unity,31bf3856ad364e35" sn -Vr "Microsoft.Practices.ServiceLocation,31bf3856ad364e35" sn -Vr "Microsoft.Practices.Unity.Configuration,31bf3856ad364e35" did the trick! Very cool. – er-v May 23 '10 at 17:10
  • Is `sn` a command line utility that has to be run from cmd, or could it be run from within VS? I'm unable to run it in either. How do I use it? – Tomas Aschan May 23 '10 at 19:42
  • Tomas, I run it from the VS command line which I believe just refers to sn.exe as installed in the Windows SDK. – Curt Nichols May 24 '10 at 17:39
0

I've had the exact same problem (although with Ninject) - see the second error in my question.

The proposed solution (which I haven't had time to verify yet) is to re-build the non-working assembly with signing turned off.

This assumes, of course, that you have the source code available. I had to build Ninject against .NET 4 myself (there was no released version for .NET 4 when I started the project), which is why I ended up in this situation in the first place.

Community
  • 1
  • 1
Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
  • 1
    :) Hello, Tomas. Looks like sn -Vr can fix problems, and there is no need to compile code without key. – er-v May 23 '10 at 17:42