意外发现了winform的一个控件个数的极限

很久没来CSDN了,今天跟大家分享一个我的发现,调试这个的时间用了很久,希望大家在遇到类似问题时,不要走弯路.

如下图,我用反射在一个窗体上根据从数据库里取来的数据创建自定义控件,当完成1169个之后创建第1170个,而且每次都是在1170时,会报错,如下图.

有时则直接说发生 了一个异常,根本没把这个错误报出来.

大概是微软觉得你肯定不会在同一个窗体上创建1000多个控件吧…..

托管(v4.0.30319)): 已加载“C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Transactions.resources\v4.0_4.0.0.0_zh-Hans_b77a5c561934e089\System.Transactions.resources.dll”System.Transactions Critical: 0 : <TraceRecord xmlns="" Severity="Critical"><TraceIdentifier></TraceIdentifier><Description>未处理的异常</Description><AppDomain>YDHfw2015.vshost.exe</AppDomain><Exception><ExceptionType>System.ComponentModel.Win32Exception, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>创建窗口句柄时出错。</Message><StackTrace> 在 System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) 在 System.Windows.Forms.ToolTip.CreateHandle() 在 System.Windows.Forms.ToolTip.get_TopLevelControl() 在 System.Windows.Forms.ToolTip.CreateRegion(Control ctl) 在 System.Windows.Forms.ToolTip.HandleCreated(Object sender, EventArgs eventargs) 在 System.Windows.Forms.Control.OnHandleCreated(EventArgs e) 在 System.Windows.Forms.Control.WmCreate(Message&amp;amp; m) 在 System.Windows.Forms.Control.WndProc(Message&amp;amp; m) 在 System.Windows.Forms.Label.WndProc(Message&amp;amp; m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp;amp; m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp;amp; m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)</StackTrace><ExceptionString>System.ComponentModel.Win32Exception (0x80004005): 创建窗口句柄时出错。 在 System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) 在 System.Windows.Forms.ToolTip.CreateHandle() 在 System.Windows.Forms.ToolTip.get_TopLevelControl() 在 System.Windows.Forms.ToolTip.CreateRegion(Control ctl) 在 System.Windows.Forms.ToolTip.HandleCreated(Object sender, EventArgs eventargs) 在 System.Windows.Forms.Control.OnHandleCreated(EventArgs e) 在 System.Windows.Forms.Control.WmCreate(Message&amp;amp; m) 在 System.Windows.Forms.Control.WndProc(Message&amp;amp; m) 在 System.Windows.Forms.Label.WndProc(Message&amp;amp; m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp;amp; m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp;amp; m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)</ExceptionString><NativeErrorCode>486</NativeErrorCode></Exception></TraceRecord>

,每个人在他的人生发轫之初,总有一段时光,

意外发现了winform的一个控件个数的极限

相关文章:

你感兴趣的文章:

标签云: