微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Monogame模板在System.TypeInitializationException的启动时崩溃

试图在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.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

在单声道中运行。

我努力了:

坏的网关与Debian上的Nginx,单声道和fastcgi

想用cmake制作独立的程序

如何声明全局风格,并在uwp中使用该风格

如何在libpcap中使用“pcap_lookupdev()”?

运行button在Qt Creator中被禁用

重新安装单声道

重新安装Monogame

重新安装Xamarin Studio

更新窗口

错误一直没有改变。

使用SFML.Net代替monogame时,不会发生此错误

整个解决scheme可以在这里find

我怎样才能在Linux上用C ++读取()和O_DIRECT文件

Windows媒体基础枚举相机设备

fwrite()vs write()在光盘caching的情况下

MinGW和gluT未定义引用'_imp ____ glutinitWithExit @ 12'

微软的copyFileEx错误

固定:

确保单声道配置文件中没有任何不正确的映射,即删除看起来像这样的任何行:

<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: Program Files(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上面链接错误报告,以增加在不久的将来得到修复的机会。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐