我目前正在嘗試使現有的VB.NET項目運行。在WndProc消息中拋出一個空指針異常,但堆棧跟蹤並沒有給我任何東西。我可以在啓動窗體的設計器代碼中放置一個斷點,但是當我通過它時,會通過WndProc函數觸發一個NULL指針異常。上面的方法似乎是Windows方法。我唯一的線索是帶有Msg = 24和WParam = 1的Message參數。我認爲HWnd = 5178884沒有幫助。什麼是WndProc消息24
我粘貼堆棧跟蹤以防萬一有人有任何想法。 注意:我屏蔽了MyNamespace和MyBaseForm和MyFormA,因爲源代碼是專有的。這對.NET框架運行在Visual Studio 2008中3.5
MyNamespace.Forms.MyBaseForm.WndProc(Message& m)\r\n
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n
System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n
System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)\r\n
System.Windows.Forms.Control.SetVisibleCore(Boolean value)\r\n
System.Windows.Forms.Form.SetVisibleCore(Boolean value)\r\n
System.Windows.Forms.Control.set_Visible(Boolean value)\r\n
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n
System.Windows.Forms.Application.Run(ApplicationContext context)\r\n
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()\r\n
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()\r\n
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)\r\n
MyFormA.My.MyApplication.Main(String[] Args)
17d14f5c-a337-4978-8281-53493378c1071.vb:Line 81\r\n
System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n
System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n
System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n
System.Threading.ThreadHelper.ThreadStart()"
謝謝。我猜測81行調用是來自系統API,因爲它叫做MyFormA.My.MyApplication.Main。可能是visual studio的一部分。這個名字是一個guid。它可能不是原因。 – Nap 2012-02-08 11:43:14
只需在此處添加對WM_SHOWWINDOW的引用即可。 http://winapi.freetechsecrets.com/win32/WIN32WMSHOWWINDOW.htm – Nap 2012-02-17 05:54:35