I just upgraded my ASP.NET MVC/WebApi project from Microsoft.Practices.Unity 3.5.1404 to 3.5.1406 (via nuget, just released). Afterwards, I'm getting this compile error:
Error CS0012 The type 'IUnityContainer' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Practices.Unity, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
On lines like:
GlobalConfiguration.Configuration.DependencyResolver =
new Unity.WebApi.UnityDependencyResolver(container);
Of course, I'm not referencing 3.0.0.0, but 3.5.1.0. So my assumption is that the Unity.WebApi
assembly has been compiled against an earlier version of the Microsoft.Practices.Unity
assembly. Theoretically, you'd want to fix that with an assembly redirect, like so:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.1.0" newVersion="3.5.1.0" />
</dependentAssembly>
However, that doesn't seem to work.
Any suggestions?
This might be an more updated answer for how to upgrade from Unity 3.5.1 to 4.0.1.
The type 'IUnityContainer' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Practices.Unity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Either via Package Manager Console or NuGet:
Code: