Localizable + PasswordChar = Handle error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ryan

    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?
  • Ryan

    #2
    RE: Localizable + PasswordChar = Handle error

    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.NativeWin dow.CreateHandl e(CreateParams cp)
    at System.Windows. Forms.Control.C reateHandle()
    at System.Windows. Forms.TextBoxBa se.CreateHandle ()
    at System.Windows. Forms.TextBox.g et_PasswordChar ()
    at System.Windows. Forms.Design.Te xtBoxDesigner.g et_PasswordChar ()

    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.Passwor dChar 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
    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

    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

    Comment

    • Jeffrey Tan[MSFT]

      #3
      RE: Localizable + PasswordChar = Handle error

      Hi Ryan,

      Yes, I understand your concern.

      It seems that this exception is generated in NativeWindow.Cr eateHandle
      method, while NativeWindow class is trying to create the TextBox control.
      Below is the source code of NativeWindow.Cr eateHandle method:

      public virtual void CreateHandle(Cr eateParams cp)
      {
      IntSecurity.Cre ateAnyWindow.De mand();
      if (((cp.Style & 0x40000000) != 0x40000000) || (cp.Parent ==
      IntPtr.Zero))
      {
      IntSecurity.Top LevelWindow.Dem and();
      }
      lock (this)
      {
      this.CheckRelea sed();
      NativeWindow.Wi ndowClass class1 =
      NativeWindow.Wi ndowClass.Creat e(cp.ClassName, cp.ClassStyle);
      lock (NativeWindow.c reateWindowSync Object)
      {
      if (this.handle == IntPtr.Zero)
      {
      class1.targetWi ndow = this;
      IntPtr ptr1 =
      UnsafeNativeMet hods.GetModuleH andle(null);
      IntPtr ptr2 = IntPtr.Zero;
      int num1 = 0;
      try
      {
      if ((cp.Caption != null) &&
      (cp.Caption.Len gth 0x7fff))
      {
      cp.Caption = cp.Caption.Subs tring(0,
      0x7fff);
      }
      ptr2 =
      UnsafeNativeMet hods.CreateWind owEx(cp.ExStyle , class1.windowCl assName,
      cp.Caption, cp.Style, cp.X, cp.Y, cp.Width, cp.Height, new HandleRef(cp,
      cp.Parent), NativeMethods.N ullHandleRef, new HandleRef(null, ptr1),
      cp.Param);
      num1 = Marshal.GetLast Win32Error();
      }
      catch (NullReferenceE xception exception1)
      {
      throw new
      OutOfMemoryExce ption(SR.GetStr ing("ErrorCreat ingHandle"), exception1);
      }
      class1.targetWi ndow = null;
      if (ptr2 == IntPtr.Zero)
      {
      throw new Win32Exception( num1,
      SR.GetString("E rrorCreatingHan dle"));
      }
      this.ownHandle = true;
      HandleCollector .Add(ptr2,
      NativeMethods.C ommonHandles.Wi ndow);
      }
      }
      }
      }
      As you can see that there are 2 points where "Error creating window handle"
      exception will throw. One is OutOfMemoryExce ption and another is
      Win32Exception. Can you confirm if your exception is OutOfMemoryExce ption
      or Win32Exception.

      Normally the OutOfMemoryExce ption 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_PasswordCh ar. 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
      Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

      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.

      Comment

      • Ryan

        #4
        RE: Localizable + PasswordChar = Handle error

        Hey Jeff,

        Thanks again for your reply. I'm on a roll with finding new things, it
        seems like ("Configuration ErrorException 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.Cr eateHandle
        method, while NativeWindow class is trying to create the TextBox control.
        Below is the source code of NativeWindow.Cr eateHandle method:
        >
        public virtual void CreateHandle(Cr eateParams cp)
        {
        IntSecurity.Cre ateAnyWindow.De mand();
        if (((cp.Style & 0x40000000) != 0x40000000) || (cp.Parent ==
        IntPtr.Zero))
        {
        IntSecurity.Top LevelWindow.Dem and();
        }
        lock (this)
        {
        this.CheckRelea sed();
        NativeWindow.Wi ndowClass class1 =
        NativeWindow.Wi ndowClass.Creat e(cp.ClassName, cp.ClassStyle);
        lock (NativeWindow.c reateWindowSync Object)
        {
        if (this.handle == IntPtr.Zero)
        {
        class1.targetWi ndow = this;
        IntPtr ptr1 =
        UnsafeNativeMet hods.GetModuleH andle(null);
        IntPtr ptr2 = IntPtr.Zero;
        int num1 = 0;
        try
        {
        if ((cp.Caption != null) &&
        (cp.Caption.Len gth 0x7fff))
        {
        cp.Caption = cp.Caption.Subs tring(0,
        0x7fff);
        }
        ptr2 =
        UnsafeNativeMet hods.CreateWind owEx(cp.ExStyle , class1.windowCl assName,
        cp.Caption, cp.Style, cp.X, cp.Y, cp.Width, cp.Height, new HandleRef(cp,
        cp.Parent), NativeMethods.N ullHandleRef, new HandleRef(null, ptr1),
        cp.Param);
        num1 = Marshal.GetLast Win32Error();
        }
        catch (NullReferenceE xception exception1)
        {
        throw new
        OutOfMemoryExce ption(SR.GetStr ing("ErrorCreat ingHandle"), exception1);
        }
        class1.targetWi ndow = null;
        if (ptr2 == IntPtr.Zero)
        {
        throw new Win32Exception( num1,
        SR.GetString("E rrorCreatingHan dle"));
        }
        this.ownHandle = true;
        HandleCollector .Add(ptr2,
        NativeMethods.C ommonHandles.Wi ndow);
        }
        }
        }
        }
        As you can see that there are 2 points where "Error creating window handle"
        exception will throw. One is OutOfMemoryExce ption and another is
        Win32Exception. Can you confirm if your exception is OutOfMemoryExce ption
        or Win32Exception.
        >
        Normally the OutOfMemoryExce ption 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_PasswordCh ar. 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
        Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

        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.
        >
        >

        Comment

        • Jeffrey Tan[MSFT]

          #5
          RE: Localizable + PasswordChar = Handle error

          Hi Ryan,

          Oh, it seems that your another ConfigurationEr rorException 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!CreateWi ndowExW and user32!CreateWi ndowExA, then you
          may break in NativeWindow.Cr eateHandle method while calling
          UnsafeNativeMet hods.CreateWind owEx(). 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 OutOfMemoryExce ption.
          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
          Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

          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.

          Comment

          • Jeffrey Tan[MSFT]

            #6
            RE: Localizable + PasswordChar = Handle error

            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
            Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

            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.

            Comment

            • cranley

              #7
              Re: Localizable + PasswordChar = Handle error

              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 UseDefaultPassw ordChars 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
              Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

              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.

              Comment

              • Jeffrey Tan[MSFT]

                #8
                Re: Localizable + PasswordChar = Handle error

                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
                Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

                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.

                Comment

                Working...