C# RLNET/OPENTK System.MissingMethodException 在 运行 时间内
C# RLNET/OPENTK System.MissingMethodException during run-time
我正在尝试使用 RLNET 库在 c# 中制作一个小型 2d 游戏。 RLNET 库依赖 OpenTK,因此我使用 Visual Studio 中的 NuGet 包管理器将 RLNET 和 OpenTK 的最新版本添加到我的项目中。我正在阅读一个解释如何使用这些库的教程。但是,当我 运行 将代码 运行 放入 运行 时的 MissingMethodException 中。
我正在学习的教程在这里:https://roguesharp.wordpress.com/2016/03/02/roguesharp-v3-tutorial-creating-the-project/
解决方案资源管理器在“引用”下拉列表下显示项目中包含的两个库。我还将它们包含在我的代码中:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RLNET;
using OpenTK;
namespace Rouge_Game
{
class Program
{
private static readonly int _screenWidth = 100;
private static readonly int _screenHeight = 70;
private static RLRootConsole _rootConsole;
static void Main(string[] args)
{
// This must be the exact name of the bitmap font file we are using or it will error.
string fontFileName = "terminal8x8.png";
// The title will appear at the top of the console window
string consoleTitle = "RougeSharp V3 Tutorial - Level 1";
// Tell RLNet to use the bitmap font that we specified and that each tile is 8 x 8 pixels
_rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight,
8, 8, 1f, consoleTitle);
// Set up a handler for RLNET's Update event
_rootConsole.Update += OnRootConsoleUpdate;
// Set up a handler for RLNET's Render event
_rootConsole.Render += OnRootConsoleRender;
// Begin RLNET's game loop
_rootConsole.Run();
}
// Event handler for RLNET's Update event
private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e)
{
_rootConsole.Print(10, 10, "It worked!", RLColor.White);
}
// Event handler for RLNET's Render event
private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
{
// Tell RLNET to draw the console that we set
_rootConsole.Draw();
}
}
}
代码中有 运行 时间错误的部分是这样的:
// Event handler for RLNET's Render event
private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
{
// Tell RLNET to draw the console that we set
_rootConsole.Draw();
}
当我 运行 项目编译时没有错误并且程序启动,但随后抛出此异常:
System.MissingMethodException
HResult=0x80131513
Message=Method not found: 'Void
OpenTK.Graphics.OpenGL.GL.BlendFunc(OpenTK.Graphics.OpenGL.BlendingFactorSrc, OpenTK.Graphics.OpenGL.BlendingFactorDest)'.
Source=RLNET
StackTrace:
at RLNET.RLRootConsole.Draw()
at Rouge_Game.Program.OnRootConsoleRender(Object sender, UpdateEventArgs e) in C:\Users\pjmul\source\repos\Rouge Game\Rouge Game\Program.cs:line 45
at RLNET.RLRootConsole.window_RenderFrame(Object sender, FrameEventArgs e)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at OpenTK.GameWindow.OnRenderFrame(FrameEventArgs e)
at OpenTK.GameWindow.RaiseRenderFrame(Double elapsed, Double& timestamp)
at OpenTK.GameWindow.DispatchRenderFrame()
at OpenTK.GameWindow.Run(Double updates_per_second, Double frames_per_second)
at OpenTK.GameWindow.Run(Double updateRate)
at RLNET.RLRootConsole.Run(Double fps)
at Rouge_Game.Program.Main(String[] args) in
C:\Users\pjmul\source\repos\Rouge Game\Rouge Game\Program.cs:line 32
我不明白这个错误,但是当我使用 Visual Studio 中内置的对象查看器时,我可以在打开 OpenTK.dll 时找到 "missing" 函数。非常感谢任何关于如何修复此错误的建议。我还要感谢任何花时间提前帮助我的人。
OpenTK 的 3.x 分支有问题。尝试将您的 OpenTK 软件包降级回 2.x,它会起作用。
我正在尝试使用 RLNET 库在 c# 中制作一个小型 2d 游戏。 RLNET 库依赖 OpenTK,因此我使用 Visual Studio 中的 NuGet 包管理器将 RLNET 和 OpenTK 的最新版本添加到我的项目中。我正在阅读一个解释如何使用这些库的教程。但是,当我 运行 将代码 运行 放入 运行 时的 MissingMethodException 中。
我正在学习的教程在这里:https://roguesharp.wordpress.com/2016/03/02/roguesharp-v3-tutorial-creating-the-project/
解决方案资源管理器在“引用”下拉列表下显示项目中包含的两个库。我还将它们包含在我的代码中:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RLNET;
using OpenTK;
namespace Rouge_Game
{
class Program
{
private static readonly int _screenWidth = 100;
private static readonly int _screenHeight = 70;
private static RLRootConsole _rootConsole;
static void Main(string[] args)
{
// This must be the exact name of the bitmap font file we are using or it will error.
string fontFileName = "terminal8x8.png";
// The title will appear at the top of the console window
string consoleTitle = "RougeSharp V3 Tutorial - Level 1";
// Tell RLNet to use the bitmap font that we specified and that each tile is 8 x 8 pixels
_rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight,
8, 8, 1f, consoleTitle);
// Set up a handler for RLNET's Update event
_rootConsole.Update += OnRootConsoleUpdate;
// Set up a handler for RLNET's Render event
_rootConsole.Render += OnRootConsoleRender;
// Begin RLNET's game loop
_rootConsole.Run();
}
// Event handler for RLNET's Update event
private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e)
{
_rootConsole.Print(10, 10, "It worked!", RLColor.White);
}
// Event handler for RLNET's Render event
private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
{
// Tell RLNET to draw the console that we set
_rootConsole.Draw();
}
}
}
代码中有 运行 时间错误的部分是这样的:
// Event handler for RLNET's Render event
private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
{
// Tell RLNET to draw the console that we set
_rootConsole.Draw();
}
当我 运行 项目编译时没有错误并且程序启动,但随后抛出此异常:
System.MissingMethodException
HResult=0x80131513
Message=Method not found: 'Void
OpenTK.Graphics.OpenGL.GL.BlendFunc(OpenTK.Graphics.OpenGL.BlendingFactorSrc, OpenTK.Graphics.OpenGL.BlendingFactorDest)'.
Source=RLNET
StackTrace:
at RLNET.RLRootConsole.Draw()
at Rouge_Game.Program.OnRootConsoleRender(Object sender, UpdateEventArgs e) in C:\Users\pjmul\source\repos\Rouge Game\Rouge Game\Program.cs:line 45
at RLNET.RLRootConsole.window_RenderFrame(Object sender, FrameEventArgs e)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at OpenTK.GameWindow.OnRenderFrame(FrameEventArgs e)
at OpenTK.GameWindow.RaiseRenderFrame(Double elapsed, Double& timestamp)
at OpenTK.GameWindow.DispatchRenderFrame()
at OpenTK.GameWindow.Run(Double updates_per_second, Double frames_per_second)
at OpenTK.GameWindow.Run(Double updateRate)
at RLNET.RLRootConsole.Run(Double fps)
at Rouge_Game.Program.Main(String[] args) in
C:\Users\pjmul\source\repos\Rouge Game\Rouge Game\Program.cs:line 32
我不明白这个错误,但是当我使用 Visual Studio 中内置的对象查看器时,我可以在打开 OpenTK.dll 时找到 "missing" 函数。非常感谢任何关于如何修复此错误的建议。我还要感谢任何花时间提前帮助我的人。
OpenTK 的 3.x 分支有问题。尝试将您的 OpenTK 软件包降级回 2.x,它会起作用。