I have a VB.NET/ASP.NET Webforms application which uses the Gmail API. Originally it was targeting 4.5.2 and everything worked fine. The specifications changed and it now must run on a server with .NET 4.0 installed. When i retargeted the project I began getting the following error:
Multiple assemblies with equivalent identity have been imported: 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll' and 'C:\Users\User\AppData\Local\Temp\Temporary ASP.NET Files\root\a17744b0\bc5d4def\assembly\dl3\8947372f\000e8a3c_c74bd001\System.Runtime.dll'. Remove one of the duplicate references.
After many hours researching and debugging I have narrowed down the issue but cant seem to resolve it. In short the Gmail API Requires the use of the Async and Await operators which are not supported in 4.0. To allow the use of these features, when installing the Gmail API NuGet package it also installs Microsoft.Bcl, Microsoft.Bcl.Build, and Microsoft.Bcl.Async Packages and ands a System.Runtime Reference to the web.config:
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" />
</dependentAssembly>
I believe the GAC System.Runtime is conflicting with the the one imported by the Microsoft.Bcl NuGet package. I checked the version number of the dll installed and it matches the reference in the web.config. Unfortunately it also seems to match the one in the GAC resulting in the above error.
When i remove the web.config reference i get:
BC31091: Import of type 'AsyncTaskMethodBuilder(Of )' from assembly or module 'App_Code.cq-gmlla.dll' failed.
at the following code:
Private Async Function GetService() As Task(Of GmailService)
Additionally, I cant find where the GAC System.runtime dll is referenced(unless it's <add assembly="*" /> in the framework root web.config), but when I temporarily remove the System.Runtime.dll file from the GAC I dont get the equivalent identity error. However, I do get the following compiler error with no further message:
The compiler failed with error code -532462766.
It seems like 4.0 is no longer being supported and target packages are not available for VS 2015 so that may be relevant, but I'm not sure.
I didn't find any articles specifically about my issue, instead similar and general articles regarding assembly, NuGet and reference issues and am therefore refraining from linking them as they don't really add much to my question.
I have reached the limits of what i know about the GAC and Assemblies so any help would be greatly appreciated.