views:

346

answers:

2

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.

+2  A: 

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
Wow, this is what I've had same problem andsn -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
Thank you for the quick answer. This made my day ;)
Kimoz
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 Lycken
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
A: 

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.

Tomas Lycken
:) Hello, Tomas. Looks like sn -Vr can fix problems, and there is no need to compile code without key.
er-v