Bug 34648 - System.IO.FileNotFoundException: Could not load assembly 'System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile
Summary: System.IO.FileNotFoundException: Could not load assembly 'System.Net.Http.Web...
Status: RESOLVED ANSWERED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 5.1
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2015-10-07 14:59 UTC by Mukesh Kumar Mishra
Modified: 2017-06-28 12:04 UTC (History)
7 users (show)

Tags: BZCU
Is this bug a regression?: ---
Last known good build:


Attachments
While build solution with Xamarin studio we are facing same issue. (171.38 KB, image/png)
2015-10-08 08:02 UTC, Mukesh Kumar Mishra
Details
While build solution with Xamarin studio we are facing same issue. (217.08 KB, image/png)
2015-10-08 08:04 UTC, Mukesh Kumar Mishra
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Mukesh Kumar Mishra 2015-10-07 14:59:30 UTC
when i am trying to build my application. I am facing following exception.Can any buddy help me to short out this issue.

Error	138	Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'System.Net.Http.WebRequest.dll'
   at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
   at Xamarin.Android.Tasks.ResolveAssemblies.Execute()	Tensing.Mojave.MobileApp.Droid
Comment 1 Jonathan Pryor 2015-10-07 15:11:57 UTC
Please provide diagnostic build output:

http://developer.xamarin.com/guides/android/troubleshooting/troubleshooting/#Diagnostic_MSBuild_Output

Xamarin.Android doesn't provide a System.Net.Http.WebRequest.dll assembly, so I'm wondering where that assembly reference is coming from.
Comment 3 Mukesh Kumar Mishra 2015-10-08 05:22:00 UTC
Can you please find solution for me.
Comment 4 Mukesh Kumar Mishra 2015-10-08 08:02:06 UTC
Created attachment 13239 [details]
While build solution with Xamarin studio we are facing same issue.

We are getting the error while building the android app in xamarin studio.
Comment 5 Mukesh Kumar Mishra 2015-10-08 08:04:49 UTC
Created attachment 13240 [details]
While build solution with Xamarin studio we are facing same issue.

We are getting the error while building the android app in xamarin studio.
Comment 6 Jonathan Pryor 2015-10-08 11:40:30 UTC
Reformatting part of Comment #2 for readability:

> 13>    Adding assembly reference for Tensing.Hermosa.Sync, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null, recursively... (TaskId:296)
> 13>      Adding assembly reference for Microsoft.AspNet.SignalR.Client, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, recursively... (TaskId:296)
> 13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1147,2):
> error : Exception while loading assemblies: System.IO.FileNotFoundException:
> Could not load assembly 'System.Net.Http.WebRequest, Version=4.0.0.0, 

The problem, then, is that assembly Tensing.Hermosa.Sync.dll references Microsoft.AspNet.SignalR.Client.dll, and Microsoft.AspNet.SignalR.Client.dll references System.Net.Http.WebRequest.dll, and System.Net.Http.WebRequest.dll doesn't exist.

A quick look at the Microsoft.AspNet.SignalR.Client NuGet package [0, 1] shows that Microsoft.AspNet.SignalR.Client.dll DOES reference System.Net.Http.WebRequest.dll...but only for net45. All other profiles do NOT reference System.Net.Http.WebRequest.dll.

The question, then, is why is your project using the net45 version instead of the lib/portable-net45+sl5+netcore45+wp8+wp81 version? (The latter is what gets used when I create a new project and add a reference to the Microsoft.AspNet.SignalR.Client package.)

The output in Comment #2 can't help in answering that question. It's possible that *no* build output can answer that question, as it may be determined at "NuGet package reference time", so I'm not sure which log files -- if any! -- that information can be gleamed from.

[0]: https://www.nuget.org/packages/Microsoft.AspNet.SignalR.Client/2.2.0
[1]:
> $ curl -o package.zip https://api.nuget.org/packages/microsoft.aspnet.signalr.client.2.2.0.nupkg
> mkdir package
> cd package
> unzip ../package.zip
> $ for a in `find . -iname \*.dll` ; do echo "## $a" ; monodis --assemblyref $a | grep System.Net.Http.WebRequest ; done
> ## ./lib/net40/Microsoft.AspNet.SignalR.Client.dll
> ## ./lib/net45/Microsoft.AspNet.SignalR.Client.dll
> 	Name=System.Net.Http.WebRequest
> ## ./lib/portable-net45%2Bsl5%2Bnetcore45%2Bwp8%2Bwp81/Microsoft.AspNet.SignalR.Client.dll
> ## ./lib/portable-win81%2Bwpa81/Microsoft.AspNet.SignalR.Client.dll
> ## ./lib/portable-win81%2Bwpa81/Microsoft.AspNet.SignalR.Client.Store.dll