Code is Deleted/Disappears from InitializeComponent() Wnform

E

edster

A *lot* of our teams code is being deleted from the
InitializeComponent() section of a winform, such as Grid settings,
event handler hooks, layout settings etc. This mainly seems to
happen to 3rd party controls such as Infragistics grids and menu bars
and toolbars, but it also happens on native .net tools.

I know you're thinking that I modified that procedure, but that's not
the case, the designer generates it wholly, i don't even move code
region in the code behind, I just leave it where it is. I tested
without an inherited form, without enums in the same cs file, etc
etc. But sometimes as soon as i open a form, it asks to check out
from source control and then wipes all the extended properties that
the designer generates in the initialize component procedure.
Recently, we cannot even make changes to the controls in the
"properties" window because it will wipe the code out.

We *never* touch this region of the form, the designer controls it
all. And we can't lose the productivity of not using the designer
for such simple tasks as layout and such.

I've read quite a few postings, but no solutions, and this bug has
followed us from beta, to 2002, to 2003....please has anyone a
solution for this issue? This is documented across multiple projects
and 8 developer boxes, some not even connected to the same domain, it
definitely exists.
 
L

Lloyd Sheen

I have had similar problems but everyone in this newgroup that has replied
makes a joke of it. I have reinstalled and the same problems persist.
Beyond that buttons in the IDE go missing. Changing the docking of the
solution explorer often takes a couple of minutes. This IDE has way too
many problems. I just keep hearing wait until next release.


edster said:
A *lot* of our teams code is being deleted from the
InitializeComponent() section of a winform, such as Grid settings,
event handler hooks, layout settings etc. This mainly seems to
happen to 3rd party controls such as Infragistics grids and menu bars
and toolbars, but it also happens on native .net tools.

I know you're thinking that I modified that procedure, but that's not
the case, the designer generates it wholly, i don't even move code
region in the code behind, I just leave it where it is. I tested
without an inherited form, without enums in the same cs file, etc
etc. But sometimes as soon as i open a form, it asks to check out
from source control and then wipes all the extended properties that
the designer generates in the initialize component procedure.
Recently, we cannot even make changes to the controls in the
"properties" window because it will wipe the code out.

We *never* touch this region of the form, the designer controls it
all. And we can't lose the productivity of not using the designer
for such simple tasks as layout and such.

I've read quite a few postings, but no solutions, and this bug has
followed us from beta, to 2002, to 2003....please has anyone a
solution for this issue? This is documented across multiple projects
and 8 developer boxes, some not even connected to the same domain, it
definitely exists.



----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
E

edster

Yeah, we've had this problem for a long time, and it has progressively
appeared more and more, and now it is rather routine but yet its hard
to reproduce in a new project, yet working with the project for more
than a few days will inevitably cause this problem over and over.
The web version of the init has very similar problems with the
designer.

Anyway, i very seldom post issues, but this is a lingering problem
where i just don't see the light at the end of the tunnel...i waited
for 2003 to come out months ago hoping it would fix the
problem....still waiting, hopefully whidbey can manage this
relatively big bug....

I'm wondering if the fault doesn't lie in how Infragistics implements
their design time properties because i primarily have a problem with
every single one of their controls. But they store a LOT of info in
InitializeComponent and it doesn't look unreasonable and is somewhat
well formed. Well their winforms generated code is, their web
generation leaves a lot to be desired.

As for the people that make fun, they just haven't experienced the
problem so they are quick to point the finger...the infamous "it
works on my box" syndrome. get used to it, a lot of developers tend
to look down on the skills and abilities of their counterparts
especially over the internet because they can't appreciate the
uniqueness of the problem. Ah well, we are what we are.
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi,

One cause of this problem I have once pinpointed is an exception thrown from
a control's constructor or inability to load the assembly containing the
control. Generally speaking, when a form is open in the designer, and the
designer cannot load or instantiate certain controls, it silently removes
them from the form and therefore removes their initialization code from the
InitializeComponent method.

The only remedy, I believe, is to exercise extreme caution when opening a
form in the designer. Pay special attention to the task list, the IDE adds
warning tasks notifying the user that the project needs to be rebuilt to
reflect changes made. If you see any such task on the list (you might need
to configure the Task List to show all types of tasks), *avoid* opening any
designer until you've successfully built the project.

Hope this helps to alleviate your frustration at least a little bit!

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

edster said:
Yeah, we've had this problem for a long time, and it has progressively
appeared more and more, and now it is rather routine but yet its hard
to reproduce in a new project, yet working with the project for more
than a few days will inevitably cause this problem over and over.
The web version of the init has very similar problems with the
designer.

Anyway, i very seldom post issues, but this is a lingering problem
where i just don't see the light at the end of the tunnel...i waited
for 2003 to come out months ago hoping it would fix the
problem....still waiting, hopefully whidbey can manage this
relatively big bug....

I'm wondering if the fault doesn't lie in how Infragistics implements
their design time properties because i primarily have a problem with
every single one of their controls. But they store a LOT of info in
InitializeComponent and it doesn't look unreasonable and is somewhat
well formed. Well their winforms generated code is, their web
generation leaves a lot to be desired.

As for the people that make fun, they just haven't experienced the
problem so they are quick to point the finger...the infamous "it
works on my box" syndrome. get used to it, a lot of developers tend
to look down on the skills and abilities of their counterparts
especially over the internet because they can't appreciate the
uniqueness of the problem. Ah well, we are what we are.



----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
D

Dmitriy Lapshin [C# / .NET MVP]

Lloyd,

See my reply to edster. I should add there's absolutely nothing funny about
this bug. I have personally seen it several times, and my colleagues have
suffered from it too, it have once caused us to re-design a rather complex
form from scratch.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi Lloyd,

A remember I posted regarding this a time ago, and I do not see a lot of
jokes in this group.

In short I do not recommend to use InitializeComponent() at all, in fact all
the code between :

#region Web|Windows Form Designer generated code
#endregion

SHOULD NEVER BE TOUCHED !!!

and InitializeComponent() is in both cases inside this region.

if you need to initialize some controls you can do so in the constructor
AFTER the call to InitializeComponent() as it's clear stated on the default
constructor:
public ImportImages(string[] files)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//

}

or do it in the form_load event.


IIRC in the new version of VS the code used/needed by the designer will be
moved away from the file by default.


Hope this help,
 
G

Guest

I never have problems adding my own event handlers manually to the
InitializeComponent(). Maybe you are just incapable of understanding it and
yes I am aware that its generated by the designer. If the designer is
working correctly it should be able to handle it. If not then its a bug.



Ignacio Machin ( .NET/ C# MVP ) said:
Hi Lloyd,

A remember I posted regarding this a time ago, and I do not see a lot of
jokes in this group.

In short I do not recommend to use InitializeComponent() at all, in fact all
the code between :

#region Web|Windows Form Designer generated code
#endregion

SHOULD NEVER BE TOUCHED !!!

and InitializeComponent() is in both cases inside this region.

if you need to initialize some controls you can do so in the constructor
AFTER the call to InitializeComponent() as it's clear stated on the default
constructor:
public ImportImages(string[] files)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//

}

or do it in the form_load event.


IIRC in the new version of VS the code used/needed by the designer will be
moved away from the file by default.


Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

I have had similar problems but everyone in this newgroup that has replied
makes a joke of it. I have reinstalled and the same problems persist.
Beyond that buttons in the IDE go missing. Changing the docking of the
solution explorer often takes a couple of minutes. This IDE has way too
many problems. I just keep hearing wait until next release.


100,000 Encryption
=---
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

If you add your code in the same way that the designer would have done it,
then it will be ok and the designer will have no problem with it.

Having the designer cope with the programmer code would made it more
complex,
beside as the next version of VS will allow partial types and the aute
generated code will be placed on another file
take a look at
http://msdn.microsoft.com/chats/vstudio/vstudio_032103.asp

They particularly address this issue:
Host: Anders (Microsoft)
Q: What's the aim of partial types in C#?

A: Two reasons. First, people often ask us for include files. When we dig a
little deeper, it turns out they want to split large classes into multiple
files. Partial types will allow you to do that, but in a structured fashion.
Second, partial classes solve the "round trip" problem with auto generated
code. The code generator can create one file and the user's additions can be
placed in another file. When code is regenerated, the user's changes aren't
lost.



Cheers,


--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


I never have problems adding my own event handlers manually to the
InitializeComponent(). Maybe you are just incapable of understanding it and
yes I am aware that its generated by the designer. If the designer is
working correctly it should be able to handle it. If not then its a bug.



"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:[email protected]...
Hi Lloyd,

A remember I posted regarding this a time ago, and I do not see a lot of
jokes in this group.

In short I do not recommend to use InitializeComponent() at all, in fact all
the code between :

#region Web|Windows Form Designer generated code
#endregion

SHOULD NEVER BE TOUCHED !!!

and InitializeComponent() is in both cases inside this region.

if you need to initialize some controls you can do so in the constructor
AFTER the call to InitializeComponent() as it's clear stated on the default
constructor:
public ImportImages(string[] files)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//

}

or do it in the form_load event.


IIRC in the new version of VS the code used/needed by the designer will be
moved away from the file by default.


Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

I have had similar problems but everyone in this newgroup that has replied
makes a joke of it. I have reinstalled and the same problems persist.
Beyond that buttons in the IDE go missing. Changing the docking of the
solution explorer often takes a couple of minutes. This IDE has way too
many problems. I just keep hearing wait until next release.


A *lot* of our teams code is being deleted from the
InitializeComponent() section of a winform, such as Grid settings,
event handler hooks, layout settings etc. This mainly seems to
happen to 3rd party controls such as Infragistics grids and menu bars
and toolbars, but it also happens on native .net tools.

I know you're thinking that I modified that procedure, but that's not
the case, the designer generates it wholly, i don't even move code
region in the code behind, I just leave it where it is. I tested
without an inherited form, without enums in the same cs file, etc
etc. But sometimes as soon as i open a form, it asks to check out
from source control and then wipes all the extended properties that
the designer generates in the initialize component procedure.
Recently, we cannot even make changes to the controls in the
"properties" window because it will wipe the code out.

We *never* touch this region of the form, the designer controls it
all. And we can't lose the productivity of not using the designer
for such simple tasks as layout and such.

I've read quite a few postings, but no solutions, and this bug has
followed us from beta, to 2002, to 2003....please has anyone a
solution for this issue? This is documented across multiple projects
and 8 developer boxes, some not even connected to the same domain, it
definitely exists.



----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet
News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000
Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
S

Scott Beasley

I use VS.NET Studio as little as I can get by with, but have had this
to happen to me also. I find if I lock all the controls/forms, is
does not happen.

hope this helps,
scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top