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?
Well, this is probably superfluous now, but the issue apparently had something to do with Unity 3.5.1406, as that got pulled down, and replaced with Unity 4.0. I also replaced the older, apparently unsupported Unity.WebApi library that hasn't been updated in several years, and replaced it with the newer, apparently supported Unity.AspNet.WebApi library. That's a little tricky in NuGet, as a search for "Unity WebApi" returns the older library at the top of the list, and hides the newer library down off the bottom of the first page.
Between all that, it works now, without any issues I've spotted.