Why is Visual Studio Designer deleting the code?

Several times during our current project, the designer of the visual studio made changes that led to the loss of code. For example, event handler players that were manually configured in the constructor code were lost. Does anyone know why this happened?

Edit: I understand that manually editing these files is not a good idea, but it also happened with other events created through the constructor.

+3
source share
5 answers

Good for starters, read the XML at the top of your designer.cs file.

/// <summary>
/// Required method for Designer support - do not modify
/// contents of this method with the code editor.
/// </summary>
private void InitializeComponent()

, , . , , .

, , . , , , , NullReferenceException.

, , , , InitializeComponent(). - , , , .designer.cs, , .

+12

, , , ? MyForm.Designer.cs? partial.

+5

. - ( , ). , , , .

+3

.cs, , , Load .

0

, , , . , -, , , ... ?

-, , , Visual Studio , , , , .

, , - Microsoft , , . , Microsoft... , , , , .

0
source

Source: https://habr.com/ru/post/1735072/


All Articles