I have brought in some old (not my own) code to a new solution which I want to modify. I am new to C# so I apologize if my terminology is incorrect or have missed anything obvious.
I have a main form MainForm.cs and custom component CustomComponent.cs which inherits the PropertyGrid. The CustomComponent is within the MainForm.
I am getting an error:
The type name 'MainNameSpace' does not exist in the type 'MainNameSpace.MainNameSpace'
Within MainForm.Designer.cs I have the generated code:
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
// stuff
this.customComponent1 = new MainNameSpace.MainNameSpace();
// more stuff
}
If I manually go in and change it to just “new MainNameSpace();” it works just fine. I don’t know why the name of the namespace is added twice. I tried checking the .resx file for anything suspicious but didn’t see anything, not that I’d know what to look for. Is there a good starting place to look? I’ve gone into the MainForm, CustomComponent, and everything else I can think of looking for the culprit but have not found anything that looks like the culprit. Any ideas as to where I should be looking/what to look for? I feel like the issue is in CustomComponent.cs but I do not know.
CustomComponent.cs:
namespace MainNameSpace
{
public partial class MainNameSpace : PropertyGrid
{
public MainNameSpace()
{
InitializeComponent();
}
// other stuff
}
}
Thanks!
I have had this problem before and I am pretty sure that it is with these lines:
The namespace and class cannot have the same name because it doesn’t know which one you are calling. Try changing either the namespace or class name and it should work.
Hope this helps!