“Microsoft.Xna.Framework.Graphics.GraphicsDevice.GraphicsDevice”给我 AccessViolationException
因此,最近我正在学习有关如何在 Visual Studio 中使用 FNA 制作游戏的教程。 一切正常,直到我添加了这四行代码(在 cs 中):
graphics.PreferredBackBufferWidth = 1280;
graphics.PreferredBackBufferHeight = 720;
graphics.IsFullScreen = false;
graphics.ApplyChanges();
现在,每当我启动游戏时,它都会给我这个错误(它可能与我得到的错误有点不同,因为我必须翻译它的某些部分) ):
This exception was originally thrown on this call stack:
Microsoft.Xna.Framework.Graphics.GraphicsDevice.GraphicsDevice (Microsoft.Xna.Framework.Graphics.GraphicsAdapter, Microsoft.Xna.Framework.Graphics.GraphicsProfile, Microsoft.Xna.Framework.Graphics.PresentationParameters)
Microsoft.Xna.Framework.GraphicsDeviceManager.Microsoft.Xna.Framework.IGraphicsDeviceManager.CreateDevice ()
Microsoft.Xna.Framework.Game.DoInitialize ()
Microsoft.Xna.Framework.Game.Run ()
GameEngine.Program.Main (string []) in Program.cs
我查遍了整个互联网,目前还没有解决方案。另外,出于某种原因,它确实可以在 VSC 中工作,但我想在 VS 中执行此操作(实际上,我在 VSC 中使用了 NuGet 包,因此这可能是解决方案,但我实际使用的所有代码都是相同的)。
如果这以某种方式帮助您解决问题,这是我正在关注的系列,我陷入了第二部分: https://www.youtube.com/playlist?list=PL3wErD7ZIp_DtsTKoouVCxu81UQkI9VZL
感谢您的帮助!
So, recently I was following a tutorial on how to make a game with FNA in Visual Studio.
Everything worked fine until I added these four lines of code (in cs):
graphics.PreferredBackBufferWidth = 1280;
graphics.PreferredBackBufferHeight = 720;
graphics.IsFullScreen = false;
graphics.ApplyChanges();
Now, whenever I launch the game it gives me this error (it can be a little bit different than the one I get because I had to translate some parts of it):
This exception was originally thrown on this call stack:
Microsoft.Xna.Framework.Graphics.GraphicsDevice.GraphicsDevice (Microsoft.Xna.Framework.Graphics.GraphicsAdapter, Microsoft.Xna.Framework.Graphics.GraphicsProfile, Microsoft.Xna.Framework.Graphics.PresentationParameters)
Microsoft.Xna.Framework.GraphicsDeviceManager.Microsoft.Xna.Framework.IGraphicsDeviceManager.CreateDevice ()
Microsoft.Xna.Framework.Game.DoInitialize ()
Microsoft.Xna.Framework.Game.Run ()
GameEngine.Program.Main (string []) in Program.cs
I searched the whole internet about this, and there is no solution so far. Also, for some reason it DOES work in VSC, tho I would like to do it in VS (actually, I used the NuGet package in VSC so that might be the solution, but all the code that I'm actually using is the same).
If that somehow helps you with the solution, here is the series I was following, and I got stuck on part two: https://www.youtube.com/playlist?list=PL3wErD7ZIp_DtsTKoouVCxu81UQkI9VZL
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论