I have an issue that is apparently not new, but one that I still can't seem to find an answer to yet.
I am using Google's Analytics API for .NET and am having a rough time trying to get the assemblies to play nicely together. I don't get any build errors when I build through Visual Studio 2012. However, when I start using NGen to precompile the projects, I see a lot of bad assembly references.
I'm using MVC 4, Visual Studio 2012, and the latest Google.Apis packages (1.5.0.1-beta as of right now).
The .dll's / versions I have installed in the project in question are:
DotNetOpenAuth, Version 4.0.0.11165
System.Web.Mvc, Version 4.0.0.0
System.Net.Http.Primitives, Version 4.2.13.0
log4net, Version 1.2.11.0
Google.Apis, Version 1.5.0.1-beta
Here are the errors I am finding in NGen's output:
Failed to load dependency System.Net.Http.Primitives of assembly Google.Apis, Version=1.4.0.28227, Culture=neutral, PublicKeyToken=null because of the following error : The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Failed to load dependency System.Web.Mvc of assembly DotNetOpenAuth, Version=4.0.0.11165, Culture=neutral, PublicKeyToken=2780ccd10d57b246 because of the following error : The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Failed to load dependency log4net of assembly DotNetOpenAuth, Version=4.0.0.11165, Culture=neutral, PublicKeyToken=2780ccd10d57b246 because of the following error : The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
And here is what I have in that project's web.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" />
<bindingRedirect oldVersion="1.0.0.0-1.2.11.0" newVersion="1.2.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.13.0" newVersion="4.2.13.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
I believe that most of that was built out when I used NuGet to install the Google.Apis packages, but I can't figure out why the assembly binding redirects aren't preventing these errors from NGen.
If anyone could help point me in the right direction, I would really appreciate it! Thank you!
Have you tried supplying your application's config file to NGEN using /ExeConfig? For a web app you may need to copy the web.config to app.exe.config and pass in a path to a non-existent app.exe in your web-app directory.