Hello
I have the following problem. When I'm designing controls and use them, Visual Studio tends to delete controls randomly
I think this is because my user control uses data-adapters, etc. which will result in an error during design time. The result is that Visual Studio deletes this control, because it doesn't work or something like this. This results in a null-reference-exception, which is correct because my control is gone (the "Protected UserControl1 As UserControl" is the only thing remaining)
Is there a way, tha't disables the power of the design time functions. In design time Visual Studio can delete and create controls, bur I want that the design time cannot delete user controls that maybe in design time create an exception (which only is "?"), but work when running the app. Now I have to backup the information in the Sub InitializeComponents to restore it if the design time is deleting controls
I have found on internet and in my own experience that if you don't open the design view, that problem not occurs. However, sometimes I want to open it to make changes. The design time then deletes some of my user controls
Thanks for any help
Regards
Michiel Doeven
"Ying-Shen Yu[MSFT]" - 09 Apr 2004 08:41 GMT
Hi Michiel,
I'm afraid we can prevent Visual Studio from deleting a user control by
throwing an exception in design-time. In fact, base on my knowledge the
unexpected deletion of usercontrol is caused by an internal unhandled
exception in the method/property of the user control. So I think it's
better to debug your user control in design-time and try catching the first
chance exception to make clear what caused the internal exception. The
technical article below will show you how to debug a design-time control.
You need also enable the "first-chance"exception in the Exception Dialog in
IDE.
If you have trouble to analyze the exception, please give me more
information about the problem and the exception, I'll follow up with you on
this issue.
Thanks!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
"Ying-Shen Yu[MSFT]" - 09 Apr 2004 08:43 GMT
Sorry, forgot to add the link in last post.
<Debugging Design-Time Controls>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/
html/DesignTimeDebugging.asp
Best regards,
Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
Michiel Doeven - 15 Apr 2004 13:37 GMT
Thanks for your help. I solved the problem with the
property "Designmode" as mentioned in the link.
Every part of code that can be called in designtime that
could raise an exception is now checked with the property
Designmode. And because the property doesn't work in the
constructor (as stated in the link) I moved all code that
could cause a problem to the Load-event (and then checked
Designmode).
The exception I usually got was only "?". Nothing more.
So thanks for your help,
Best Regards,
Michiel Doeven
>-----Original Message-----
>
[quoted text clipped - 15 lines]
>
>.