Reputation: 151
After moving and rearranging controls on a Winform when invoking a Build and/or Rebuild All command the following error message appears :
"An error occurred while processing this command. Could not load file or assembly 'LoLock, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."
At that point all the controls disappear from the Designer and form the executing form as well. I've scoured the designer cs file and run diffs
against a previous working version and cannot find anything amiss.
This has happened to me on several occasions and appears to be random.
Any clues ??
Upvotes: 0
Views: 978
Reputation: 633
I also experienced this with a user control.
I received an exception for each control that had the Add method removed from the designer.
Surprisingly, I had a couple of panels, and the Add code for the children of those panels remained in tact.
I only had to implement Add for those panels and a few controls that were not in containers, which is fortunate because there were over 100 controls.
An error was introduced in the constructor of the user control, and I believe that this contributed to the chain of events resulting in the corrupt designer file.
Upvotes: 0
Reputation: 31
I've had the same problem...exactly...same error followed by the disappearance of most of the controls. The controls that are missing in the designer are my custom controls. The change I made before the error and the disappearance was to add a constructor to each of the controls derived class (i.e. my part of the control). So far, I've noted that the Control.Add(...) is missing for each of the hundred or so controls that have disappeared (from the automatically generated Form.designer.cs file). This is the one point that seems to differ from your situation if you are running a diff on the designer.cs file between pre and post failure. Mine definitely has missing Add()s.
So far, my solution is to manually add back the Add() methods to the generated file. However, it would obviously help if there was some way to get visual studio to see this problem and add the controls back automatically. However, I can't think of any way that VS could know, at this point, which controls to add to which parent control.
For example, before the error I had the following group box defined in my designer.cs file:
//
// groupBox10
//
this.groupBox10.Controls.Add(this.checkBox_FincaDescription_ForRent);
this.groupBox10.Controls.Add(this.checkBox_FincaDescription_ForSale);
this.groupBox10.Location = new System.Drawing.Point(883, 67);
this.groupBox10.Name = "groupBox10";
this.groupBox10.Size = new System.Drawing.Size(310, 76);
this.groupBox10.TabIndex = 9;
this.groupBox10.TabStop = false;
this.groupBox10.Text = "Property Type";
After the FAIL I have the following code which was generated as a result of either the error or simply the designers failure to manage my custom controls:
//
// groupBox10
//
this.groupBox10.Location = new System.Drawing.Point(883, 67);
this.groupBox10.Name = "groupBox10";
this.groupBox10.Size = new System.Drawing.Size(310, 76);
this.groupBox10.TabIndex = 9;
this.groupBox10.TabStop = false;
this.groupBox10.Text = "Property Type";
This is a massive FAIL for me as I have so many fields to manually correct (although luckily only a few group boxes and a good backup). I have read of so many people having this same problem from 2005 on, I can't believe it hasn't been addressed.
Upvotes: 2