I guess I wasn't clear. It is deleting its own code. Here is a simple
scenario.
1) Make a custom control
2) Make a form and drop that control on it
3) Now "break" the custom control -- put something that throws an exception
in the constructor (as a trypical example I occasionally forget to hide
references to objects that are null in design mode as they get initialized at
run time)
4) Go back to the form in design mode. It will destroy all the code about
the custom control -- where it was, any initialization information.
This is stupid. One control on one form isn't too bad. But I might have 50
data entry controls on some form and if I break that control it deletes all
of them. This is obviously painful to recreate and there is just no good
reason for it as far as I can tell. If it runs into trouble why can't it
just paint the area with an error marker of some sort?
"Steve McLellan" wrote:
It does say you shouldn't edit code in there - the designer can delete and
destroy anything it finds. From experience, it's better either doing your
own code outside the designer created code or at least keeping a copy of the
function before you go into the designer. I agree it's really irritating,
but it can be avoided (or at least made less destructive).
Steve
"Eric Hudson" <Er********@discussions.microsoft.com> wrote in message
news:40**********************************@microsof t.com... A quick rant and a question.
Why does the designer in VS2003 delete code about custom components that
it can't load? I've had large sections of forms disappear in the blink of an
eye just because I've introduced a small error in a widely used custom
control that makes it throw an exception at design time.
IMHO the code should be sacrosanct -- if the designer can't create some
sub control then it should just throw up a blank or a red X or something (it
would be nice if it would be smart enough to figure out where the control
is supposed to be and just mark that area) and make note of the exception.
Is there some way to stop the designer from deleteing code (aside from
marking the code read only before entering the designer, which is what I've
started doing)? Is this going to change any time soon?
Thanks,
Eric
PS This is in Visual C#, from some things I have read it behaves
differently in Visual Basic but I haven't tried that.