尝试在Windows上运行此程序
#region Using Statements
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Input;
#endregion
namespace asdf
{
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public Game1() //Exception raised points to here
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
graphics.IsFullScreen = true;
}
protected override void Initialize()
{
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
{
Exit();
}
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
base.Draw(gameTime);
}
}
}
引发以下异常
Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /tmp/install/lib/libgdiplus.so
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x000cc] in C:cygwinsourcesmonomcsclassSystem.DrawingSystem.DrawinggdipFunctions.cs:127
--- End of inner exception stack trace ---
at System.Drawing.Icon.get_Handle () [0x00020] in C:cygwinsourcesmonomcsclassSystem.DrawingSystem.DrawingIcon.cs:646
at (wrapper remoting-invoke-with-check) System.Drawing.Icon:get_Handle ()
at OpenTK.Platform.Windows.WinGLNative.set_Icon (System.Drawing.Icon value) [0x00000] in <filename unknown>:0
at OpenTK.NativeWindow.set_Icon (System.Drawing.Icon value) [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.OpenTKGameWindow.Initialize () [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.OpenTKGameWindow..ctor () [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.OpenTKGamePlatform..ctor (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.GamePlatform.Create (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.Game..ctor () [0x00000] in <filename unknown>:0
at asdf.Program.Main (System.String[] arrayargs) [0x00000] in <
filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /tmp/install/lib/libgdiplus.so
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x000cc] in C:cygwinsourcesmonomcsclassSystem.DrawingSystem.DrawinggdipFunctions.cs:127
--- End of inner exception stack trace ---
at System.Drawing.Icon.get_Handle () [0x00020] in C:cygwinsourcesmonomcsclassSystem.DrawingSystem.DrawingIcon.cs:646
at (wrapper remoting-invoke-with-check) System.Drawing.Icon:get_Handle ()
at OpenTK.Platform.Windows.WinGLNative.set_Icon (System.Drawing.Icon value) [0x00000]in <filename unknown>:0
at OpenTK.NativeWindow.set_Icon (System.Drawing.Icon value) [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.OpenTKGameWindow.Initialize () [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.OpenTKGameWindow..ctor () [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.OpenTKGamePlatform..ctor (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.GamePlatform.Create (Microsoft.Xna.Framework.Game game) [0x00000] in <filename unknown>:0
at Microsoft.Xna.Framework.Game..ctor () [0x00000] in <filename unknown>:0
at asdf.Program.Main (System.String[] arrayargs) [0x00000] in <filename unknown>:0
在单声道中运行时。
我试过:
重新安装单声道
重新安装单游戏
重新安装 Xamarin Studio
更新窗口
并且错误保持不变。
使用 SFML.Net 代替单游戏时不会发生此错误
完整的解决方案可以在这里找到
修复:
确保 mono 配置文件中没有任何不正确的映射,即删除任何如下所示的行:
<dllmap dll="gdiplus" target="whatever" />
<dllmap dll="gdiplus.dll" target="whatever" />
解释:
如果您查看异常详细信息,您很可能会发现抛出了一个底层System.DllNotFoundException
,因为父类Game
包含对通过gdiplus.dll
公开的System.Drawing.GDIPlus
的引用。 gdiplus.dll
是一个核心的.NET Framework库,所以它应该已经在GAC中了。无法使用 Mono 等跨平台框架加载此内容的最常见原因是 DLL 映射无效。
单声道错误:https://bugzilla.xamarin.com/show_bug.cgi?id=8309
解决方案:在"C:\程序文件 (x86)\Mono-3.2.3\etc\mono\config"中,找到并删除以下行:
<dllmap dll="gdiplus" target="/tmp/install/lib/libgdiplus.so" />
<dllmap dll="gdiplus.dll" target="/tmp/install/lib/libgdiplus.so" />
我可以验证这是否解决了问题。
我还建议对上面链接的错误报告执行 ping 操作,以增加在不久的将来获得修复的机会。