Failed to load file or assembly "System.Drawing, Version = 4.0.0.0

I installed Monogame, and trying to run a very simple hello world style game, I get this exception. I understand that there are a few stack overflow reports regarding this error, but I'm still puzzled by how to fix this. Do I need to remove .Net and reinstall a different version? If so, how do I do this?

A System.IO.FileNotFoundException has been thrown. Failed to load file or assembly "System.Drawing, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a" or one of its dependencies.

Here's the download link for the Xamarin project:

https://www.dropbox.com/s/q7quw26lg1etdts/MonoGameTester.zip

+4
source share
2 answers

Such errors will occur if you have a link to assemblies that do not ship with Xamarin.iOS. This is the case for System.Drawing.dll .

In your case, this is likely because your project has links to both monotouch.dll and MonoMac.dll , and this will not work.

You need to create separate projects for each target , that is, for iOS (monotouch.dll) and for OSX (MonoMac.dll).

In each project, you can use the source code and / or assemblies (for general logic). Both projects should also include platform-specific code and links.

As a result, you get a lot of common code (in the source or assemblies) with several bits of code defined on the platform.

+5
source

I came across the same question and the above sentence did not work for me, so I did the following:

Open project

Go to Solution Explorer
Expand Help Group
Remove System.Drawing Link
Right click on help group
Add link
On the .NET tab, find System.Drawing to add the correct link

0
source

Source: https://habr.com/ru/post/1496183/


All Articles