Could not load file or assembly 'System.Drawing, Version=4.0.0.0

匆匆过客 提交于 2019-12-12 12:05:25

问题


I installed Monogame, and when trying to run a very simple hello world style game I get this exception. I understand that there are several posts on stack overflow regarding this error, but am still puzzled as to how to fix this. Do I need to uninstall .Net and reinstall a different version? If so, how do I do that?

A System.IO.FileNotFoundException was thrown. Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

Here's a downloadable link to the Xamarin Project:

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


回答1:


Such errors will occurs if you have reference to assemblies that do not ship with Xamarin.iOS. That's the case for System.Drawing.dll.

In your case it's likely because your project has references to both monotouch.dll and MonoMac.dll and that's not gonna work.

You need to build separate projects for each target, i.e. one for iOS (monotouch.dll) and one for OSX (MonoMac.dll).

From each project you can share source code and/or assemblies (for shared logic). Both projects also need to include platform specific code and references.

You end up with a lot of shared code (in source or assemblies) with a few platform specific bits of code.




回答2:


I ran into the same issue and above suggestion didn't worked for me, so I did the following :

Open you Project
Go to the Solution Explorer
Expand the Reference group
Delete the System.Drawing reference
Right click on Reference group
Add Reference
On the ".NET" tab, search for System.Drawing to add the right reference



来源:https://stackoverflow.com/questions/18150510/could-not-load-file-or-assembly-system-drawing-version-4-0-0-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!