Xamarin.Mac - PCLStorage.dll Could Not Load "Systems.Windows.Forms"
I built a Xamarin.Mac test app which targets Xamarin.Mac, .NET 4.5 which references a Xamarin.Mac class library which targets the same. The library pulls in the latest, stable PCLStorage NuGet from NuGet.org. But when I run the app, I get an immediate System.IO.FileNotFoundException in Main() with this message.
Could not load file or assembly 'System.Windows.Forms' or one of its dependencies.
I've commented out most of the code in the library and I believe I've isolated the offending statement to this line.
var folder = FileSystem.Current.LocalStorage;
When it fails, the last line in the Application Output window shows
Loaded assembly..../MonoBundle/PCLStorage.dll [External]
If I comment the line out, the app starts up just fine and the Output does NOT show PCLStorage.dll being loaded at all. PCLStorage.Abstractions.dll [External] loads with no problems.
I'm running Xamarin Studio 5.10.3 (build 51) with Xamarin.Mac Version 2.4.2.1 (Xamarin Enterprise), and a colleague can reproduce the same problem in their dev environment running the same project.
No problem on iOS, Android, and Windows.
I've been debugging this for days now. Do you have a clue as to what my problem might be?
Thanks
I think Xamarin.Mac ends up using the .NET 4.5 version of PCL Storage. So it blows up at this line: https://github.com/dsplaisted/PCLStorage/blob/d1b905429d0686ed8dfdf03c26fe83ea3c5857ce/src/PCLStorage.FileSystem.Desktop/DesktopFileSystem.cs#L31
See also #28.
Strange Daniel...
When I changed the Target Framework of just the Xamain.Mac app to Mono/.NET 4.5 it worked. When I changed it back to Xamarin.Mac .NET 4.5 it also worked.
Something got nudged during the toggle, but what's inexplicable is nothing discernable changed in the .csproj file.
What do you think?