我尝试调试以便找到有问题的bug,但我不能,因为问题似乎被System.Drawing (System.Drawing.Graphics.GetHdc
使用的例程更深入)
这是我的类,它位于同一解决方案中的另一个项目中。该类被编译为库(dll),该库由我的示例项目引用,该项目是可执行文件。
namespace CTRGui
{
public class CTRForm : Form
{
}
}
如您所见,该类完全为空,仅从Form继承。下一个代码段是我的示例项目中的入口点。提醒一下,CTRForm是我的示例项目引用的库的一部分。
namespace CTRGuiExample
{
class Example
{
static void Main(string[] Args)
{
CTRGui.CTRForm form = new CTRGui.CTRForm();
Application.Run(form);
}
}
}
(可视)调试器显示在Application.Run上抛出异常(正常情况下考虑到它没有PDB /源代码),并且调用堆栈告诉我实际上抛出了System.ArgumentException System.Drawing.Graphics.GetHdc
尽管进行了调试,但是徒劳无功,我无法找到解决此问题的方法。
编辑:根据要求提供异常详细信息。
VS给我的复制的异常细节:
System.ArgumentException occurred
HResult=-2147024809
Message=Parameter is not valid.
Source=System.Drawing
StackTrace:
at System.Drawing.Graphics.GetHdc()
InnerException:
Visual Studio中显示的异常信息:
Exception thrown: 'System.ArgumentException' in System.Drawing.dll
Additional information: Parameter is not valid.
调用堆栈:
System.Drawing.dll!System.Drawing.Graphics.GetHdc() Unknown
System.Drawing.dll!System.Drawing.BufferedGraphics.RenderInternal(System.Runtime.InteropServices.HandleRef refTargetDC, System.Drawing.BufferedGraphics buffer) Unknown
System.Drawing.dll!System.Drawing.BufferedGraphics.Render() Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WmPaint(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Form.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) Unknown
> CTRGuiExample.exe!CTRGuiExample.Example.Main(string[] Args) Line 15 C#