locked
Unhandled exception trying to view windows form RRS feed

  • Question

  •  

    In a C# Windows application in VS 2005, I'm simply double-clicking a form in Solution Explorer to view it, however, it always prompts me to check the form out. If I don't check the form out, I receive an error dialog:

    The control System.Windows.Forms.Form has thrown an unhandled exception in the designer and has been disabled.

    Exception:
    The checkout was canceled by the user.

    Stack trace:
    at System.Windows.Forms.Form.OnVisibleChanged(EventArgs e)
    at System.Windows.Forms.Form.WmShowWindow(Message& m)
    at System.Windows.Forms.Form.WndProc(Message& m)

    Clicking "OK" on the error dialog brings up my form (or the border of it anyway) and then continues with a trace of the errors inside the form instead of showing the controls in my form.

    If I check out the form, all is well, but I shouldn't have to check out the form each time just to view it. Help!

    Any idea what's going on here?



     

    Tuesday, January 16, 2007 5:17 PM

Answers

  • Hi Mark,

    It may be ok for the Forms editor to change/rearrange their properties (e.g. they may be missing some property and need the file upgraded afte installing some service pach/hotfix, or they may want to keep the list of properties sorted, etc). In oerder to modify the file they call QueryEditFiles() into scci pacakge, which allows scci to checkout the file. However, I'd expect that once the file is checked out, saved and the  format is updated the editor will stop doing the QueryEdit calls and won't have to re-arrange the properties anymore.

    If they keep calling QueryEditFiles() and re-arranging the properties everytime that file is opened in editor, that is an editor bug. (There won't be a fix in source control side because scci has no control when it gets called on QueryEdit). You may want to use http://connect.microsoft.com/site/sitehome.aspx?SiteID=210 to submit a bug to the Forms/xml editor team. Please attach if you can the file that causes the problems - it will help the editor team in reproducing the issue and fixing the problem.

    Alin

    Tuesday, January 23, 2007 10:15 AM
    Moderator

All replies

  • Hello-

    Are you using SourceSafe 2005 or a differenet source control provider?  Also, what happens if you check out the form, check it back in, and then try opening it again?  will you still get the prompt?

    Thanks,

    Luke

    Thursday, January 18, 2007 6:16 PM
    Moderator
  • >If I check out the form, all is well, but I shouldn't have to check out the form each time just to view it.

    Checkout the form, save it and check it back in. It may be possible that the form editor needs to update some property in the form and they require the file to be editable to do that.

    After that, if you open the form and still see a checkout prompt, that would be an editor bug (the editor should not call QueryEditFiles() without reason during opening of a document). Checkout the form again, save it, then use ShowDifferences command to see exactly what was changed (either in the form, or in the code behind file). When you have the result call product support or contact the Form Editor (not sure if this forum is the right one http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=58&SiteID=1)

    Alin

    Saturday, January 20, 2007 9:52 AM
    Moderator
  • Alin,
    we also get this with VB projects, It appears to me that the VS2005 IDE attempts to carry out some sort of partial runtime functionality and as such it seems to need the resx files to be writeable.

     I'm not sure but at a guess I would say it is interpreting the xml layout information and then I guess it trys to optomise it re-writeing it the the file. The attributes then get re-arranged and the file delta is different. I have tried comparing the SourceSafe copy with the checked out copy and seen only these types of changes.

    I hope to find a fix as this has already effected delivery.

    Rgds
    Mark.

    Tuesday, January 23, 2007 9:55 AM
  • Hi Mark,

    It may be ok for the Forms editor to change/rearrange their properties (e.g. they may be missing some property and need the file upgraded afte installing some service pach/hotfix, or they may want to keep the list of properties sorted, etc). In oerder to modify the file they call QueryEditFiles() into scci pacakge, which allows scci to checkout the file. However, I'd expect that once the file is checked out, saved and the  format is updated the editor will stop doing the QueryEdit calls and won't have to re-arrange the properties anymore.

    If they keep calling QueryEditFiles() and re-arranging the properties everytime that file is opened in editor, that is an editor bug. (There won't be a fix in source control side because scci has no control when it gets called on QueryEdit). You may want to use http://connect.microsoft.com/site/sitehome.aspx?SiteID=210 to submit a bug to the Forms/xml editor team. Please attach if you can the file that causes the problems - it will help the editor team in reproducing the issue and fixing the problem.

    Alin

    Tuesday, January 23, 2007 10:15 AM
    Moderator
  •  

    Checking out the file, saving it, and checking it back in does not resolve the problem. One interesting (maybe) note: if I leave the form open in the designer after checking it back in, I can switch back and forth between other forms or .cs files and view the form without a problem. However, after closing the form and trying to view it again by double-clicking it in Solution Explorer, it prompts for check out again, and I must check it out in order to view it. As far as reporting this bug... I do not have Visual Studio as an available program to apply for feedback. I can see the group and browse previous feedback, but that's all. In the list of available programs to apply for, the only one that relates seems to be Visual Studio SP1 Beta. What now? Thanks.

    Tuesday, January 23, 2007 6:55 PM
  • I've run into exactly the same issue as described above.
    Wednesday, January 24, 2007 4:18 PM
  • Hello-

    If you click on the link that Alin provided (http://connect.microsoft.com/site/sitehome.aspx?SiteID=210) and then sign in you should see a green submit feedback button.  Click it, then after it makes you search for the issue and you continue on to submit new feedback you can click "Bug Submission Form".  Then under "Version" select "Visual Studio 2005 (All Products and Editions)" and enter the rest of the bug information.

    Thanks,

    Luke

    Thursday, January 25, 2007 7:16 PM
    Moderator
  •  

    Thanks. Bug submitted. ID: 253929.

    Thursday, January 25, 2007 10:14 PM
  • Have you sovled the issue?   I also encoutered exactly the same issue.

     

    Appreciate any help to fix this issue...

     

    More info:

     

    OS: Windows XP Professional SP2

    VS2005 version 8.0.50727.762 (SP.050727-760)

    .NET Framework Version 2.0.50727

     

    Thursday, October 25, 2007 8:57 AM
  •  

    The issue is not resolved. I submitted a bug, Microsoft provided a workaround (which did not work), and then promptly closed the case, preventing me from providing feedback or continuing with it. Frustrating. I've had to live with this quark, but it sure would be nice if it was fixed (and if Microsoft did not close the case before it was actually resolved).

     

    Thursday, October 25, 2007 3:40 PM
  • I have exactly the same problem... and finally found the solution for my particular case... hope it can help other user in there project.
    For me the problem disappeared after removing Docking option on a label in a SplitContainer (initially dock on top) replace by a location (0, 0) - anchor (top, left).

     

    The bug appears when label is in autosize mode and docked on a container. Can be systematically reproduced.


    • Proposed as answer by Squalou Wednesday, August 6, 2008 9:52 AM
    Tuesday, August 5, 2008 8:49 AM
  • I am having the same problem in Visual Studio 2010, but the form in question does not have any docked controls.  What else could be causing this?
    Tuesday, March 1, 2011 4:47 PM
  • I also have the same problem. In my case it is the ToolStrip with some toolStripButtons which are in AutoSize mode. When I change these buttons to a fixed size this issue does not appear anymore. -> Its not a very nice workaround!

     

    Thursday, September 8, 2011 9:52 AM
  • I too had the same issue but with a slightly different variant. Some specific forms alone will be checked out while I try to open it in designer.

    And to solve this, I had to change all the controls that had their AutoSize Property to False (Default) and now it works like charm.

    Thank you, Silvio...!

    Also not sure if this is a bug or intended behavior in VS 2008 / 2010.


    --Amos
    Friday, January 27, 2012 2:38 PM
  • Was having the same error, mine turned out to be a conflict between the anchor property and the FormBorderStyle property.  Had to change the anchor of all controls to the default, top and left and the border style to fixed3d.  Hopefully this helps people having the same issue.  I went through a lot of combinations to get the one that worked.
    Wednesday, October 3, 2012 2:54 PM