473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Localizable + PasswordChar = Handle error

I'm creating a user control that has a handful of controls on it (19 in
total). One of the controls on the UC is a textbox for a user's password, so
I've set the PasswordChar property to "*". I rebuild and all is well.

The problem arises when I have the PasswordChar set, and then try to set
Localizable to True for the UC. If I set Localizable to true and have
PasswordChar set and rebuild, Visual Studio 2005 will then try to reload the
User Control in the designer but will show the message "Error creating window
handle." The only way to fix it is to open the Resx file and remove my
PasswordChar property and rebuild.

I can replicate this every time. Is this a bug in VS 2005? What's going on?
Aug 9 '06 #1
7 2224
Hi Jeff,

Thanks for your reply. I tried doing what you said in a new project and it
worked fine. However, on my original control it continues to happen. Here
is the stack trace available from the designer:

Error creating window handle.
Hide

at System.Windows.Forms.NativeWindow.CreateHandle(Cre ateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.TextBoxBase.CreateHandle()
at System.Windows.Forms.TextBox.get_PasswordChar()
at System.Windows.Forms.Design.TextBoxDesigner.get_Pa sswordChar()

I'm aware that I can probably start my user control all over, but I'd rather
not do that unless absolutely necessary. I'd also like an understanding as
to why, exactly, this is happening.

Thanks.

- ryan.

""Jeffrey Tan[MSFT]"" wrote:
Hi,

I have created a sample test usercontrol project in VS2005 C#. I dropped a
textbox and a button on the Form set TextBox.PasswordChar to '*'. After
setting Localizable property to true and switch the language to English
United State, I set PasswordChar to '*' and rebuild. I can see the
PasswordChar with value '*' in UserControl1.en-US.resx file. But I did not
get any exception in the designer. I have attached the sample project in
this reply.

Have you tried to create a new project with above steps? Can this be
reproduced? If so, please provide the sample little project to me. Thanks.

Additionally, can you provide the detailed call stack information regarding
this error? I think this error is Win32Exception.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights
Aug 10 '06 #2
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("ErrorCreatingHa ndle"), 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/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 11 '06 #3
Hey Jeff,

Thanks again for your reply. I'm on a roll with finding new things, it
seems like ("ConfigurationErrorException when reading protected config..." is
another one). I can't scientifically prove that the exception I'm receiving
would be the Win32 exception, but I'd be very surprised if it was an memory
exception. My user control has less than 20 controls on it, and I have 2
gigs of ram in my machine - so memory shouldn't be a problem.

But like I said, I haven't been able to reproduce this on any other form -
only the one. Perhaps I'll simply try and delete the text box and re-add it.
I'll post back and let you know how that goes.

Cheers - and thanks for all the help!

- ryan.

""Jeffrey Tan[MSFT]"" wrote:
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("ErrorCreatingHa ndle"), 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/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 11 '06 #4
Hi Ryan,

Oh, it seems that your another ConfigurationErrorException issue is still
working with my colleague Steven Cheng. I have just discussed with him with
this issue, and he is still researching and discussing this issue with US
developer team. I am sure he will give you a follow up in that thread ASAP.

Regarding our issue, yes, I agree that the simplest way may be delete and
re-add the TextBox and have a try, I hope this will resolve the problem.
Anyway, please feel free to feedback result here.

If you are curious, we have several ways to troubleshoot the issue by
debugging the VS2005 IDE:

1. You may use windbg to attach the VS2005 IDE project, and set a
breakpoint on user32!CreateWindowExW and user32!CreateWindowExA, then you
may break in NativeWindow.CreateHandle method while calling
UnsafeNativeMethods.CreateWindowEx(). Then you may check the return value
and Last win32 error of CreateWindowEx. Note: since CreateWindowEx is a
frequently called API, windbg may break in various other places which are
not we want to break.

2. You may use another instance of VS2005 IDE to debug your problematic
VS2005 IDE project, in the debug "Exceptions..." dialog, you may open the
"first chance" exception break for Win32Exception and OutOfMemoryException.
Then, whenever one of these 2 exceptions are thrown, the VS2005 debugger
will break, and you can find out which exception generated this "Error
creating window handle" error message.

Note: by using debuggers, you'd better set the correct symbol path for it,
then the debugger will have the correct symbol information for all FCL
assemblies.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 14 '06 #5
Hi Ryan,

Have you reivewed my last reply? Does it make sense to you? If you still
need any help or have any concern, please feel free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 16 '06 #6
Hello Jeff,

Sorry for the late reply - I've read it and understand it, however I
haven't yet tried your proposed method of debugging. I tried deleting
and readding the textbox, but it did not work. Also, I received the
same error on a different user control I was creating (not entirely
sure why). I decided to give up on the PasswordChars and simply
utilize the UseDefaultPasswordChars property (or whatever it's called)
for 3 reasons:

1. It works no matter what
2. It's standard in windows, and
3. I didn't know about it in the first place.

Thanks.

- ryan.

"Jeffrey Tan[MSFT]" wrote:
Hi Ryan,

Have you reivewed my last reply? Does it make sense to you? If you still
need any help or have any concern, please feel free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Aug 16 '06 #7
Hi Ryan,

Yes, VS IDE issues and design-time issues are hard to troubleshoot without
intensive debugging of the VS IDE, however, finding the root cause is not
always that simple.

Anyway, I am glad to see that you have found a suitable workaround for your
issue. If you need further help, please feel free to post. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 17 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rick | last post by:
In VB .Net how do I make the PasswordChar property of a Textbox work out to be that nice big round dot that we see in most system password fields? There is no special character I can see to place...
1
by: John | last post by:
I am creating an application which is password controlled on startup. I created a textbox for the user to enter the password. However, I would like to also have a menu option so the user can...
3
by: rosty | last post by:
This is taken from MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html /frlrfsystemwindowsformstextboxclasspasswordchartopic.asp) "When the PasswordChar property is...
5
by: Hareth | last post by:
Is there a way to take a text, from a textbox & later passwordChar the text. I'm not using a masked textbox. I tried: textBox1.PasswordChar = '*'; but this didn't change my text. I know how...
7
by: siddhiash | last post by:
Hi Friends I want to add PasswordChar Property which shows ****** for string which I type in PropertyGrid Control. Regards, Siddharth
3
by: Michael Brown | last post by:
Hi there, After applying the "Localizable" attribute to my form using the (form) properties window in VS, I was expecting to see "" preceding my form's class in code (added automatically by the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.