6
votes

I'm trying to understand why I'm getting the following errors when running tests in Xamarin Studio 5.9.1 (build 3) on OS X.


System.IO.FileNotFoundException : Could not load file or assembly 'System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

System.IO.FileNotFoundException


System.TypeLoadException : A type load exception has occurred.

System.TypeLoadException


All projects build successfully and the same tests run just fine in Visual Studio on Windows using the same solution.

I am seeing a warning when building the test project on OS X, despite having already installed and added the reference.

All projects referencing MyProject.fsproj must install nuget package Microsoft.Bcl.Build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317569.

2
Please do not post error messages as pictures. It's way to small to read and it's cut off on the right as well. In addition, people will not find your post when googling.nvoigt
I can't read the stack traces. They are way too small. Also, please provide more information on your project. Is this an iOS project, an Android project, a PCL?SharpMobileCode
Sounds like xbuild cannot work like MSBuild, so you might wait till MSBuild xplat is ready.Lex Li

2 Answers

3
votes

I still don't know why Xamarin behaves differently than Visual Studio, but the root cause was that the test project was targeting .Net 4.5 whereas the main project was targeting .Net 4.0

Thanks to @7sharp9 for the help.

0
votes

Different platforms (Android, iOS, Desktop) have different System.Net.Http.dll binaries - compiled from the same source, but each version references the mscorlib.dll (and other base-class libraries) from the platform it was built against.

This is not a problem when you use it in an application - Xamarin Studio will automatically pick the right version for you - but you can't use it in a Portable Class Library.

Microsoft initially implemented HttpClient as part of .NET 4.5, but then released a portable version of it (with a Windows-only license). If I understand this correctly, then that's mostly the same API as in .NET 4.5 plus a few minor additions (I think they added gzip compression, which Mono's version currently doesn't).

For Xamarin / Mono, all we need to do to create an open-source version of this library is to take our existing sources and compile them against the portable profile. I haven't tried this yet, but this could be as easy as editing the .csproj file and replacing the .

Also would suggest that you install HttpClient NuGet package System.Net.Http.HttpClient is available directly from the latest version of Xamarin.

Simply check for updates from Xamarin Studio ;-)