Hi Ryan,
Yes, I understand your concern.
It seems that this exception is generated in NativeWindow.CreateHandle
method, while NativeWindow class is trying to create the TextBox control.
Below is the source code of NativeWindow.CreateHandle method:
public virtual void CreateHandle(CreateParams cp)
{
IntSecurity.CreateAnyWindow.Demand();
if (((cp.Style & 0x40000000) != 0x40000000) || (cp.Parent ==
IntPtr.Zero))
{
IntSecurity.TopLevelWindow.Demand();
}
lock (this)
{
this.CheckReleased();
NativeWindow.WindowClass class1 =
NativeWindow.WindowClass.Create(cp.ClassName, cp.ClassStyle);
lock (NativeWindow.createWindowSyncObject)
{
if (this.handle == IntPtr.Zero)
{
class1.targetWindow = this;
IntPtr ptr1 =
UnsafeNativeMethods.GetModuleHandle(null);
IntPtr ptr2 = IntPtr.Zero;
int num1 = 0;
try
{
if ((cp.Caption != null) &&
(cp.Caption.Length > 0x7fff))
{
cp.Caption = cp.Caption.Substring(0,
0x7fff);
}
ptr2 =
UnsafeNativeMethods.CreateWindowEx(cp.ExStyle, class1.windowClassName,
cp.Caption, cp.Style, cp.X, cp.Y, cp.Width, cp.Height, new HandleRef(cp,
cp.Parent), NativeMethods.NullHandleRef, new HandleRef(null, ptr1),
cp.Param);
num1 = Marshal.GetLastWin32Error();
}
catch (NullReferenceException exception1)
{
throw new
OutOfMemoryException(SR.GetString("ErrorCreatingHandle"), exception1);
}
class1.targetWindow = null;
if (ptr2 == IntPtr.Zero)
{
throw new Win32Exception(num1,
SR.GetString("ErrorCreatingHandle"));
}
this.ownHandle = true;
HandleCollector.Add(ptr2,
NativeMethods.CommonHandles.Window);
}
}
}
}
As you can see that there are 2 points where "Error creating window handle"
exception will throw. One is OutOfMemoryException and another is
Win32Exception. Can you confirm if your exception is OutOfMemoryException
or Win32Exception.
Normally the OutOfMemoryException is caused by too many user objects are
created in the process which may hit the process limitation. You may try to
remove some controls from the designer to see if this will eliminate the
exception.
While for Win32Exception, it is caused by CreateWindowEx win32 API calling
failed. You may check Win32Exception.NativeErrorCode property to see what
exact error CreateWindowEx win32 API is meeting.
Additionally, I have tried to perform some research in our internal
database, but all the "Error creating window handle" errors I found do not
have the code path from TextBoxDesigner.get_PasswordChar. They are all
runtime exceptions. It seems that Microsoft did not recieve your exact
problem before.
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.