2010-10-25 89 views
2

在WindowsCE平台(自定义构建)上,我们的C#gui使用常规窗体来显示“弹出菜单”。 我们将FormBorderstyle设置为,因为我们不希望窗体控件可见。Form.FormBorderStyle原生异常访问冲突

一段时间后,一些客户报告了“灰盒子”。 经过一些测试后,我们可以很快地重现问题。当我们不断地打开2个不同的菜单(表单)时,平台向我们展示了一个本地异常。

错误
一个土生土长的例外Tiger.CEHost.exe发生 。选择退出并 然后重新启动该程序,或选择 详细信息以获取更多信息。

细节:

错误
ExceptionCode:0000005
ExceptionAdress:00000001
读:00000001

在WL.SetSTyle(IntPtr的hwnThis,UInt32的dwMask,UInt32的dwStyle)
在Form._SetBorderStyle(AGL_WINDOWSTYLE wstyVal,AGL_WINDOWSTYLE wstyMask)
在Form.set_FormBorderStyle(FormBorderStyle值)
在pDropDown.PopupForm.Show()
在pDropDown.Show()
在pButton.ShowHideDropDown()
在pButton.OnClick(EventArgs的)
在控制。 WnProc(WM WM,的Int32 wParam中,的Int32 LPARAM)
在Control._InternalWnProc(WM WM,的Int32 wParam中,的Int32 LPARAM)
在EVL.EnterMainLoop(IntPtr的hwnMain)
在Application.Run(表格FM)
在Program.Main(String [] args)

它似乎总是在FormBorderStyle属性失败。我们已经尝试删除所有的pInvokes,因为可能有些内存被覆盖了,但这没有帮助。

我们还记录每个调用Show方法,每个调用都在gui线程中进行,并且Form包含一个有效的句柄。

回答

0

这似乎是在netcfagl3_5.dll一个bug(会通知微软这个)

当我们使用pinvokes(SetWindowLong函数)设置FormBorderstyle我们无法重现该问题。

如果有人遇到这个罕见的错误,这是设置formborderstyle而不使用.net FormBorderStyle属性的代码。

private const uint WS_OVERLAPPED = 0x00000000; 
     private const uint WS_POPUP = 0x80000000; 
     private const uint WS_CHILD = 0x40000000; 
     private const uint WS_MINIMIZE = 0x20000000; 
     private const uint WS_VISIBLE = 0x10000000; 
     private const uint WS_DISABLED = 0x08000000; 
     private const uint WS_CLIPSIBLINGS = 0x04000000; 
     private const uint WS_CLIPCHILDREN = 0x02000000; 
     private const uint WS_MAXIMIZE = 0x01000000; 
     private const uint WS_CAPTION = 0x00C00000; 
     private const uint WS_BORDER = 0x00800000; 
     private const uint WS_DLGFRAME = 0x00400000; 
     private const uint WS_VSCROLL = 0x00200000; 
     private const uint WS_HSCROLL = 0x00100000; 
     private const uint WS_SYSMENU = 0x00080000; 
     private const uint WS_THICKFRAME = 0x00040000; 
     private const uint WS_GROUP = 0x00020000; 
     private const uint WS_TABSTOP = 0x00010000; 

     private const int WS_MINIMIZEBOX = 0x00020000; 
     private const int WS_MAXIMIZEBOX = 0x00010000; 

     private const uint WS_EX_DLGMODALFRAME = 0x00000001; 
     private const uint WS_EX_NOPARENTNOTIFY = 0x00000004; 
     private const uint WS_EX_TOPMOST = 0x00000008; 
     private const uint WS_EX_ACCEPTFILES = 0x00000010; 
     private const uint WS_EX_TRANSPARENT = 0x00000020; 
     private const uint WS_EX_MDICHILD = 0x00000040; 
     private const uint WS_EX_TOOLWINDOW = 0x00000080; 
     private const uint WS_EX_WINDOWEDGE = 0x00000100; 
     private const uint WS_EX_CLIENTEDGE = 0x00000200; 
     private const uint WS_EX_CONTEXTHELP = 0x00000400; 
     private const uint WS_EX_STATICEDGE = 0x00020000; 

     private const int WS_EX_NOANIMATION = 0x04000000; 
     public const int GWL_EX_STYLE = -20; 
     public const int GWL_STYLE = (-16); 

public static void SetNoBorder(Form form) { 
      RemoveFormStyle(form, GWL_STYLE, (int)(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU)); 
      RemoveFormStyle(form, GWL_EX_STYLE, (int)(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)); 
     } 

public static void RemoveFormStyle(Form f, int modifier, int style) { 
      int currStyle = GetWindowLong(f.Handle, GWL_EX_STYLE); 
      currStyle &= ~style; 
      SetWindowLong(f.Handle, modifier, currStyle); 
     } 

    [DllImport("Coredll.dll", SetLastError = true)] 
    public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); 

    [DllImport("coredll.dll", SetLastError = true)] 
    public static extern int GetWindowLong(IntPtr hWnd, int nIndex); 
+0

是否曾经有过一篇知识库文章或者其他什么文章? – JoelHess 2011-03-18 01:26:47

+0

@JoelHess,不,在那个时刻没有时间,并且真的忘了它。 – Stormenet 2011-03-18 10:45:28

1

我从来没有见过这个,这往往会让我觉得它不太可能成为CF甚至是你的应用程序的问题。

您的设备是否有足够的内存来运行应用程序?低内存条件应该会抛出一个OOM,但我已经看到它做了其他可预测性较低的事情,所以它总是首先要检查。

如果内存不是问题,你确定它不是平台问题吗?请记住,由于大部分操作系统是由OEM开发的,因此您不能排除操作系统中的问题。

我要做两件事情:

  1. 是否在其他一些硬件(即使是仿真器)没有问题的同一应用程序运行正常?如果它在其他硬件上工作,则会严重影响平台的问题。由于在C#中使用小型应用程序进行再现相当容易,因此我建议在C/C++中构建一个应用程序,该应用程序执行相同的功能项目以查看其行为或给出相同的问题。

+0

内存不是问题,操作系统是内部构建的。我使用旧版本的操作系统进行过一次测试,但遇到异常需要一段时间。我将搜索旧版本的操作系统,看看是否可以消除这个问题。使用小型应用程序再现也不是那么容易,有些事情需要运行才能发生(不确定是否需要运行它才能发生,或者如果它发生得更快,我需要做更长时间的测试为此) – Stormenet 2010-10-25 15:11:11

+0

好吧,问题似乎在.net AGL dll中,如果您有兴趣,请参阅我的答案。并感谢您的意见。 – Stormenet 2010-10-27 08:27:02