473,322 Members | 1,690 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,322 software developers and data experts.

InitializeComponent code lost

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
Nov 15 '05 #1
3 11559
The problem here is this. If you add your own code to the
InitializeComponent and then add a new control to your form or delete a
control from your form, then your code may become deleted. Microsoft
actually warns about it and does not recommend to add your own code to the
InitializeComponent. That's why there is a comment added to it:
/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary
You'll be better off adding your code to the constructor. So, it's not a
bug, it's a feature.

"Tabo" <ka********@hotmail.com> wrote in message
news:09****************************@phx.gbl...
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

Nov 15 '05 #2
I don't know about Tabo's problem, but I loose *all* code in
InitializeComponent *very* regularly.
After I make a change to my .aspx page (in html source view), this method is
wiped out *completely* by my VS.Net 2003. Everything's gone: event handlers,
property initialisation, everything, InitalizeComponent is completely
empty...

This is driving me mad. I regularly save the contents of InitializeComponent
in a separate file, so I can copy and paste it whenever needed (which
happens to be several times a day)...
I had this in the original VS.Net, and the 'feature' is still there in
VS.Net 2003...

Luc K

"codewriter" <co**************@yahoo.com> wrote in message
news:e1*******************@news20.bellglobal.com.. .
The problem here is this. If you add your own code to the
InitializeComponent and then add a new control to your form or delete a
control from your form, then your code may become deleted. Microsoft
actually warns about it and does not recommend to add your own code to the
InitializeComponent. That's why there is a comment added to it:
/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary
You'll be better off adding your code to the constructor. So, it's not a
bug, it's a feature.

"Tabo" <ka********@hotmail.com> wrote in message
news:09****************************@phx.gbl...
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


Nov 15 '05 #3
Forgot to tell that this is supposed to fix the problem in VS .Net 2002:
http://support.microsoft.com/?kbid=324199&sd=msdn

(unfortunately it's still there in VS .Net 2003)

Luc K

"Luc Kumps" <NO*********@pandora.be> wrote in message
news:Vu******************@afrodite.telenet-ops.be...
I don't know about Tabo's problem, but I loose *all* code in
InitializeComponent *very* regularly.
After I make a change to my .aspx page (in html source view), this method is wiped out *completely* by my VS.Net 2003. Everything's gone: event handlers, property initialisation, everything, InitalizeComponent is completely
empty...

This is driving me mad. I regularly save the contents of InitializeComponent in a separate file, so I can copy and paste it whenever needed (which
happens to be several times a day)...
I had this in the original VS.Net, and the 'feature' is still there in
VS.Net 2003...

Luc K

"codewriter" <co**************@yahoo.com> wrote in message
news:e1*******************@news20.bellglobal.com.. .
The problem here is this. If you add your own code to the
InitializeComponent and then add a new control to your form or delete a
control from your form, then your code may become deleted. Microsoft
actually warns about it and does not recommend to add your own code to the InitializeComponent. That's why there is a comment added to it:
/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary
You'll be better off adding your code to the constructor. So, it's not a
bug, it's a feature.

"Tabo" <ka********@hotmail.com> wrote in message
news:09****************************@phx.gbl...
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



Nov 15 '05 #4

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

Similar topics

0
by: Ryan Liu | last post by:
I think there are two way to define user control. For example, I want to define a ComoBox with contains only AM, PM items. a.. One way I define a class extends...
8
by: edster | last post by:
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...
0
by: Marcin Grzębski | last post by:
Hi, I want do create control (based on UserControl) that contains collection MyItemCollection (inherited from ICollection) of objects MyItem. I spent so much time to force this collection save...
14
by: TT (Tom Tempelaere) | last post by:
Hi people, The code that follows throws an ExecutionEngineException. This was written in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE 7.1 (7.1.3088). The framework is .NET...
2
by: Dica | last post by:
this is related to an earlier question i had. i'm trying to figure out visual studio 2003 and c#. i started a simple app to try to learn the basics and used many of the wizards to set up things...
6
by: Winshent | last post by:
I have read many threads which indicate that this was a problem with version 2002. Why should i be suffering this? I am using VB.NET 2003 Standard Edition... is it still a problem with 2003? ...
3
by: bhavik | last post by:
hi I have problem that when I am upload my application to the client server, I am losing buttion event on some pages. on some pages button event is working fine ro some pages is not working. I...
0
by: mtcc | last post by:
i try simple web page, for first time i add session "aa" var, and i add button, and i check if session keep aa value in postback. when i add call to Dataadapter.fill method, i lost my session on...
5
by: Otto Wyss | last post by:
I've a simple if statement yet it executes even if condition is false. What can be wrong? var j = -1; for (var i in files) { var f = files.split('/', 1); alert (j+','+i+','+(j == -1) ||...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.