473,396 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Code is Deleted/Disappears from InitializeComponent() Wnform

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 =---
Nov 15 '05 #1
8 2591
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" <ed@hatcorp-dot-com.no-spam.invalid> wrote in message
news:40**********@127.0.0.1...
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

=---
Nov 15 '05 #2
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 =---
Nov 15 '05 #3
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" <ed@hatcorp-dot-com.no-spam.invalid> wrote in message
news:40**********@127.0.0.1...
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

=---

Nov 15 '05 #4
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.

--
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

"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in message
news:R2*******************@twister01.bloor.is.net. cable.rogers.com...
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.


Nov 15 '05 #5
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

"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in message
news:R2*******************@twister01.bloor.is.net. cable.rogers.com...
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" <ed@hatcorp-dot-com.no-spam.invalid> wrote in message
news:40**********@127.0.0.1...
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 =---

Nov 15 '05 #6
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:eP**************@TK2MSFTNGP11.phx.gbl...
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

"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in message news:R2*******************@twister01.bloor.is.net. cable.rogers.com...
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" <ed@hatcorp-dot-com.no-spam.invalid> wrote in message
news:40**********@127.0.0.1...
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
=---


Nov 15 '05 #7
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/vstu...dio_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
<di********@discussion.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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:eP**************@TK2MSFTNGP11.phx.gbl...
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

"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in

message
news:R2*******************@twister01.bloor.is.net. cable.rogers.com...
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" <ed@hatcorp-dot-com.no-spam.invalid> wrote in message
news:40**********@127.0.0.1...
> 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
=---



Nov 15 '05 #8
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

ed@hatcorp-dot-com.no-spam.invalid (edster) wrote in message news:<40**********@127.0.0.1>...
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 =---

Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jonas L | last post by:
I have created a derived version of a normal form, e.g. called MyForm (public class MyForm : System.Windows.Forms.Form). The form is simply specifing a standard icon that we use within the company....
3
by: Tabo | last post by:
when i build the project using C#, the code in InitializeComponent lost sometimes. Is it a bug?? if yes, can some method fix it? thanks for help. Tabo
0
by: Norbert Heidbüchel | last post by:
Hi all, I have read a lot of postings and web pages about drag and drop and treeviews, but could not find an answer to my problem. Sorry, if I missed something. I am trying to drag and drop...
0
by: pepsi | last post by:
A wierd problem is occuring in asp.net. I have few web pages and at times some of the code just disappears from InitializeComponent() in designer generated code. Lets say I have these four lines...
1
by: Rob Meade | last post by:
Hi all, I found an article on how to write a Windows service here: http://www.dotnetbips.com/displayarticle.aspx?id=178 It was pretty much what I wanted, I want the service to scan a...
1
by: Maziar Aflatoun | last post by:
Hi everyone, I'm using VisualStudio 2003 and sometimes when I make changes in the design view, the code in my InitializeComponent() completely disappears and I have redefine the Events for that...
3
by: Scott Kilbourn | last post by:
Hi, I added some custom code to the InitalizeComponent function of a control that I'm working on. Every once in a while, I've noticed that the code that I added disappears. I finally tracked...
0
by: fds | last post by:
Hello! I have a very specific question and that is about how to inherit a control for example the control System.Windows.Forms.TextBox without causing the environment to delete the control when...
2
by: sush_jd via DotNetMonster.com | last post by:
I am using managed VC++ code in a Win Form App. There is a text box - txtRONumber. I have defined a KeyDown event handler (non-default) for it, like below. InitializeComponent() is being called...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.