.NET Forum / Visual Studio.NET / IDE / October 2006
vb.net forms designer mode
|
|
Thread rating:  |
Alex - 16 Oct 2006 09:09 GMT Hello everybody,
Since 1 and a half year I am responsible for bug fixing, updating a house internal solution - visualisation of diagnostic data from an embedded system.
3 weeks ago, i changed to lines of code, design mode could be opned and everything was displayed correctly. Last week I wanted to test something. I opned the vs studio 2003 and loaded the project. To my suprise, the following message was shown instead of the design view:
"An error occurred while loading the document. Fix the error, and then try loading the document again. The error massage follows:
An exception occured while trying to create an instance of DiagStudio.frmMaster. The exception was "Request for the permission of type System.Security.Permissions.FileIOPermission, mscorling, Verions=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed".
All forms that are inheriting from frmMaster show the same error message. The user information boxes - message boxes - do not inherit and they are showing. The project is stored on a local harddrive. The Sub New exists in frmMaster and does not have any parameters.
I have tried to delete the content of the 'obj' and 'bin' folders and rebuild the solution - no changes. I tried an earlier revision - same problem although it worked some months ago.
Thanks for your help, Alex
Linda Liu [MSFT] - 16 Oct 2006 11:18 GMT Hi Alex,
When a form is opened in form designer, the code in the InitializeComponent method of the form is executed by VS IDE. If there're errors in the InitializeComponent method, the form won't be opened correctly in form designer.
The InitializeComponent method resides in the form.designer.vb file, which is hidden in Solution Explorer by default. To show this file, click the 'Show All Files' option on the head of the Solution Explorer. You will see the frmMaster.Designer.vb file under the frmMaster in the Solution Explorer.
To narrow down the range of problem, I recommend you to comment out all the code in the InitializeComponent method within the frmMaster.Designer.vb file temporarily and save the changes and re-open the form in form designer. In theory, the frmMaster could be opened in the designer at this time. Close the form in the designer and remove the comment on a part of the code in the InitializeComponent method and save the changes and re-open the form in the designer to see if it could be opened correctly.
Follow the above steps, you should find out which lines of code cause the problem at last and then modify them to fix the problem.
Please try my suggestion and let me know the result.
Sincerely, Linda Liu 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.
Alex - 16 Oct 2006 13:33 GMT Hello Linda,
>>> The InitializeComponent method resides in the form.designer.vb file, which is hidden in Solution Explorer by default. To show this file, click the 'Show All Files' option on the head of the Solution Explorer. You will see the frmMaster.Designer.vb file under the frmMaster in the Solution Explorer. <<<
'Show all files' was activated. I can find frmMaster.vb and frmMaster.resx but not frmMaster.Designer.vb. I assume that the "Private Sub InitializeComponent()" in the Windows Form Designer generated code corresponds to that file?
>>> To narrow down the range of problem, I recommend you to comment out all the code in the InitializeComponent method within the frmMaster.Designer.vb file temporarily and save the changes and re-open the form in form designer. In theory, the frmMaster could be opened in the designer at this time. <<<
It was no problem to open the frmMaster file in the designer. I am having problems with the child forms. I have commented out all the lines in the InitializeComponent Sub but the problem - child form is not shown in design mode - is still existing.
Follow the above steps, you should find out which lines of code cause the problem at last and then modify them to fix the problem. <<< I didn't find the lines of code which caused the problem as the problem is still existing with Private Sub InitializeComponent() 'do nothing End Sub
Thank you for your help Alex
Linda Liu [MSFT] - 17 Oct 2006 10:33 GMT Hi Alex,
Thank you for your prompt response.
I made a mistake in my previous reply. form.Designer.vb file exists in VS 2005, which is a higher version to VS 2003. In VS 2003, it is the form.vb file that contains the InitializeComponent method. It seems that you have found the InitializeComponent method in the frmMaster.vb file : )
Since it is the derived forms that couldn't be opened in the designer, I recommend you to build the project and then re-open the derived forms in the designer to see if the problem still exists.
If the problem still exists, I suspect that the design-time error is caused by the code in the frmMaster's New method and Load event handler if frmMaster has one(both methods reside in frmMaster.vb file), because the code in the frmMaster's New method and Load event handler will be executed when the derived form is opened in the designer.
I sugguest that you use the means of commenting out code to find out which lines of code in the frmMaster's New method and Load event handler cause the problem. After you find them out, you could make modifications to fix the problem.
Please try my suggestion and let me know the result.
Sincerely, Linda Liu Microsoft Online Community Support
Alex - 17 Oct 2006 17:05 GMT Hi Linda,
> Thank you for your prompt response. :)
> I made a mistake in my previous reply. form.Designer.vb file exists in VS > 2005, which is a higher version to VS 2003. In VS 2003, it is the form.vb > file that contains the InitializeComponent method. It seems that you have > found the InitializeComponent method in the frmMaster.vb file : ) Yes, I found it :)
> Since it is the derived forms that couldn't be opened in the designer, I > recommend you to build the project and then re-open the derived forms in > the designer to see if the problem still exists. Done
> If the problem still exists, I suspect that the design-time error is caused > by the code in the frmMaster's New method and Load event handler if > frmMaster has one(both methods reside in frmMaster.vb file), because the > code in the frmMaster's New method and Load event handler will be executed > when the derived form is opened in the designer. I already thought about that, but as i have not changed a single line of code in the New method and the Load event, i thought that everythin in them should be okay.
> I sugguest that you use the means of commenting out code to find out which > lines of code in the frmMaster's New method and Load event handler cause > the problem. After you find them out, you could make modifications to fix > the problem. First I commented out the code int the Load event, save, rebuild solution and the same error message.
Then i commented out the code in the New Event - expect for MyBase.New() and InitalizeComponent(). Save, Rebuild solution and the designer form came up :). I deleted the comments from the Load event, Save Rebuild and the designer form was shown. I opened the new method and delted the comment signs from the first code lines. At last, 2 lines of code were left. I have tried the first one and the error message came back. I added the comment sign to this line of code, save, rebuild and the error message again.
At the end the code from New and Load were commented again and everything was fine. Step after step i inserted the code lines. At the end, each single line is back in the Load event and the New method and everything is working!
:( I do not know what caused this failure but it is very strange to me. The differences to the last revision are: 2 lines added without any comment/code 1 comment line 1 empty line was deleted
Thank you for your help
Sincerely, Alex
Alex - 17 Oct 2006 17:27 GMT Hi Linda,
after the commit into the repository, I reopened my project and the error is back again. I do not know why, I will investigate this issue tomorrow again
:(. Sincerely Alex
Linda Liu [MSFT] - 18 Oct 2006 08:25 GMT Hi Alex,
Thank you very much for your detailed feedback.
To make things clearer, let me summarize the problem first.
You have a project containing a base form called frmMaster and some child forms derived from frmMaster. The project could be built successfully and frmMaster could be opened in the designer correctly. However, all forms derived from frmMaster couldn't be opened in the designer.
You have tried the means of commenting out the code in the New method and Load event handler of frmMaster, and fould 2 lines of code in the New method that may cause the problem. If you comment out the 2 lines of code, the problem disappears. You close the project and re-load it in VS 2003 only to find that the problem comes again. If I have any misunderstanding, please point them out.
You may have a try adding a new form derived from frmMaster and don't add any control or code in the new form. Open the new form in the designer to see if it could be opened correctly.
If the new form couldn't be opened in the designer, I suggest that you add a new form in the project to replace frmMaster. Copy the controls and code of frmMaster to the new form(remember to subscribe events of the controls at design-time in the new form if they have). Then delete frmMaster and rename the new form 'frmMaster'(both the file name and class name).
Please try my suggestion to see if the problem disappears and let me know the result.
Sincerely, Linda Liu Microsoft Online Community Support
Alex - 18 Oct 2006 12:14 GMT Hi Linda,
> You have a project containing a base form called frmMaster and some child > forms derived from frmMaster. The project could be built successfully and > frmMaster could be opened in the designer correctly. However, all forms > derived from frmMaster couldn't be opened in the designer. Thats my problem
> You have tried the means of commenting out the code in the New method and > Load event handler of frmMaster, and fould 2 lines of code in the New > method that may cause the problem. If you comment out the 2 lines of code, > the problem disappears. I commented everything out and could open the design view. Then I tried to locate the codeline causing this behaviour. At the end two lines of code were commented out, I deleted the ' sign from one line and the problem was back. I added the comment sign to the specific line and the problem was still existing. I commented every line of New and Load out as I could not open the design form.
After each line was commented, I could open the design view again. Begin to locate the code line again. At the end of deleting the comment sign, each single code line in New and Load was functioning from my last revision and I could open the design view.
Changes made to the last revision: NONE!
> You close the project and re-load it in VS 2003 > only to find that the problem comes again. If I have any misunderstanding, > please point them out. I built the project, saved it and closed VS2003. I made a commit to the repository and reopend the project and the problem was there again.
> You may have a try adding a new form derived from frmMaster and don't add > any control or code in the new form. Open the new form in the designer to [quoted text clipped - 8 lines] > Please try my suggestion to see if the problem disappears and let me know > the result. Will try this today.
Sincerely, Alex
Alex - 18 Oct 2006 14:36 GMT Hi Linda,
> You may have a try adding a new form derived from frmMaster and don't add > any control or code in the new form. Open the new form in the designer to > see if it could be opened correctly. Can't see the new form in designer mode, only the error message again.
> If the new form couldn't be opened in the designer, I suggest that you add > a new form in the project to replace frmMaster. Copy the controls and code > of frmMaster to the new form(remember to subscribe events of the controls > at design-time in the new form if they have). Then delete frmMaster and > rename the new form 'frmMaster'(both the file name and class name). Sorry, no success
I also tried to come up with a new project. I copied all vb files in a new directory. I started VS Studio and added the existing forms to my New Project. I added the needed references and import directives. Then i created a new file (Form1) and copied the controls and code from frmMaster into Form1 except for the InitializeComponent method. Then i deleted frmMaster and renamed Form1 to frmMaster including the class name. Rebuild was successfull but I still can not open the design view.
Sincerely, Alex
Linda Liu [MSFT] - 19 Oct 2006 08:23 GMT Hi Alex,
> I made a commit to the repository and reopend the project and the problem was there again.
Could you tell me what you mean by 'I made a commit to the repository'?
If you don't commit to the repository and reopen the project, does the problem still exist?
In addition, could you tell me what controls are on the frmMaster? Could you show me the code in the New method and Load event handler of frmMaster?
If it is possible, I think you'd better make a sample project that could just reproduce the problem and send it to me. To get my actual email address, remove 'online' from my displayed email address.
Sincerely, Linda Liu Microsoft Online Community Support
Alex - 19 Oct 2006 10:35 GMT Hi Linda,
> Could you tell me what you mean by 'I made a commit to the repository'? > > If you don't commit to the repository and reopen the project, does the > problem still exist? With repository I mean our versioning system (Subversion) and the commit is equals a checkin
> In addition, could you tell me what controls are on the frmMaster? Could > you show me the code in the New method and Load event handler of frmMaster? System.Windows.Forms.ErrorProvider System.Windows.Forms.HelpProvider System.Windows.Forms.Timer
no other controls
> If it is possible, I think you'd better make a sample project that could > just reproduce the problem and send it to me. I will try to reproduce this.
Sincerely, Alex
Linda Liu [MSFT] - 20 Oct 2006 05:26 GMT Hi Alex,
Thank you for your sample project.
I have opened your sample project on my computer with VS2003. I opened a form derived from frmMaster directly in the designer and an error occurred - 'An error occurred while loading the document. Fix the error, and then try loading the document again. The error message follows: An exception occurred while trying to create an instance of DiagStudio.frmMaster. The exception was "Request for the permission of type System.Security.Permission.FileIOPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed".' Although I got an error when I opened the derived form as well, the error I got is different from that you got.
Then I built the solution and opened the derived form again. At this time, this derived form could be opened in the designer correctly.
So it seems that the problem has nothing to do with the code in your project, but has something to do with the environment on your computer. You have mentioned that you have a repository and I think the problem is related to this repository. I suggest that you disconnect your project from the repository or 'check out' the project from the repository and then open the derived forms in the designer to see if the problem still exists.
Hope this helps.
Please try my suggestion and tell me the result.
Thank you for your cooperation so far!
Sincerely, Linda Liu Microsoft Online Community Support
Alex - 20 Oct 2006 08:38 GMT > I have opened your sample project on my computer with VS2003. I opened a > form derived from frmMaster directly in the designer and an error occurred [quoted text clipped - 6 lines] > an error when I opened the derived form as well, the error I got is > different from that you got. If it was the error message between the quots, it is exactly the same message.
> Then I built the solution and opened the derived form again. At this time, > this derived form could be opened in the designer correctly.
> So it seems that the problem has nothing to do with the code in your > project,
:)
> but has something to do with the environment on your computer. You > have mentioned that you have a repository and I think the problem is > related to this repository. I suggest that you disconnect your project from > the repository or 'check out' the project from the repository and then open > the derived forms in the designer to see if the problem still exists. When I make the 'check out', my project files and the dependencies are copied to my local harddisk. There are some extra folders, but Vs studio did not recognize them for the last year. There were no changes (softwareupdates, patches) between the last functioning version and today.
I think I will have to try this on a fresh installation.
Thank you for your patience and help
Sincerely, Alex
Alex - 23 Oct 2006 08:04 GMT Hi Linda,
i've tried to open the project on a second computer. The derived form could be opened in the designer correctly. I assume that my environment has a defect.
Thank you for your help. Sincerely Alex
> Hi Alex, > [quoted text clipped - 30 lines] > Linda Liu > Microsoft Online Community Support Linda Liu [MSFT] - 24 Oct 2006 12:14 GMT Hi Alex,
Thank you for your update.
It seems that the problem only exists on the specific machine. If possible, I suggest that you repair the VS on that machine or reinstall the VS if repair doesn't solve the problem. To do this, open the Control Panel and select 'Add and Remove Programs'.
If you have any question, please feel free to let me know.
Sincerely, Linda Liu Microsoft Online Community Support
Alex - 24 Oct 2006 12:22 GMT Hello Linda,
> It seems that the problem only exists on the specific machine. If possible, > I suggest that you repair the VS on that machine or reinstall the VS if > repair doesn't solve the problem. Looks like, I will try to solve this problem
Thanky you Alex
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|