Here's a strange one.
After renaming a class, one of my forms began giving me errors in the designer, refusing to open. Funny thing is, the form worked just fine when I ran the program.
I began reverting my changes to deduce the problem. I have now reverted completely back to the last commit - in which I know the form was working in the designer - cleaned the solution, and deleted the bin/ and obj/ folders, as well as the *.suo file for good measure.
The form still does not display in designer.
Here are the errors it gives:
Could not find 'MyNamespace.MyControl'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built.
The variable 'myControl1' is either undeclared or was never assigned.
The variable is both declared and assigned, and MyControl builds fine (again, the form works fine when the program is actually run). Stranger still, if I try to create a new form and drag a MyControl onto it, I get this Entity-Framework error:
Failed to create component 'MyControl'. The error message follows:
'System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
at System.Data.Objects.ObjectContect.CreateEntityConnection(String connectionString)
etc. etc.
There is nothing wrong with my connection string: it worked before, and, again, it works when I actually run the program (the control already exists on the old form from the previous commit).
Any ideas whatsoever? I am completely at a loss.
[Edit]
The only significant code:
MyControl.cs
public MyControl()
{
_entities = new MyEFEntities(); //Entity-framework generated class
}
MyForm.Designer.cs
private void InitializeComponent()
{
this.myControl1 = new MyNamespace.MyControl();
...
this.Controls.Add(this.myControl1);
}
MyEFDatabase.Designer.cs
public MyEFEntities() : base("name=MyEFEntities", "MyEFEntities") { ... }
App.Config
<connectionStrings>
<add name="MyEFEntities" connectionString="metadata=res://*/MyEFDatabase.csdl|res://*/MyEFDatabase.ssdl|res://*/MyEFDatabase.msl;provider=System.Data.SqlClient;provider connection string="Data Source=MyDatabaseServer;Initial Catalog=MyDatabase;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
</connectionStrings>
I've tried the "replace " with '" trick - didn't help.
[Edit2] It is happening to new projects also, but not immediately. Only after fiddling around a bit (it has something to do with adding a many-to-one relationship that EF did not figure out on its own), but I can't figure out the exact steps to reproduce.