So I have some users getting this error
System.MissingMethodException: Method not found: 'Void System.Net.Http.Headers.HttpHeaders.AddWithoutValidation(System.String, System.Collections.Generic.IEnumerable`1<System.String>)'.
at System.Net.Http.HttpHeaderExtensions.CopyTo(HttpContentHeaders fromHeaders, HttpContentHeaders toHeaders)
at System.Net.Http.ObjectContent..ctor(Type type, HttpContent content)
at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content)
at Octgn.Site.Api.ApiClient.Login(String username, String password)
I cannot reproduce this locally, but some people using my WPF app end up having this error. After some digging through the logs I see this
LOADED ASSEMBLY: System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_2.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll
I've tried in the csproj changing this
<Reference Include="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.dll</HintPath>
</Reference>
to this
<Reference Include="System.Net.Http">
<HintPath>..\..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.dll</HintPath>
</Reference>
I've also tried adding this to the app.config file
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0 - 4.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
None of these things seem to want to load the dll's that are in the same directory as the exe of my project. I have the dll's locally and I can't seem to get it to avoid the GAC. This is a product so it goes out to hundreds of people a day, so I'm hoping to find some solution that doesn't require the user to manually be doing something on their machine at the end.
I've also though about preemptively loading the dll in code on load with Assembly.Load
or something similar, but I'm not sure if that would even make a difference, and I would think there would be a more elegant solution.
Ok, so what about if I merged all of those new assemblies into a new assembly using ilmerge
http://www.microsoft.com/en-us/download/details.aspx?id=17630 ? Or does the GAC use namespaces etc? Well I'm trying it...when I get the people with the problem to test it I'll report back if it worked or not.
Any ideas?
I used ilmerge, and merged the assemblies into my library and got around it.