Resolved Auto-generated code error

keb1965

Well-known member
Joined
Feb 9, 2009
Messages
103
Programming Experience
10+
Ok, this is an error that I have seen ever since VS 2003, right now I am using VS 2010 Ultimate .. anyway, I have a custom component that I need for a project, and that I intend on using in other projects in the future. Anyway, the code inside it is pretty simple, display an image (or multiple of images) based on the value of a property that is set by the calling code.

So the problem comes in when I add the component to my form, everything is cool, but as soon as I add or change anything else about the form, VS generates an error and tells me that it cannot find my component. I then have to change the auto-generated code to Global.MyControl instead of simply MyControl (which is what it is changed to).

This happens with not only custom controls, but also with data imported into the project. Is there something I need to set to resolve this, now that I am having to use VS more, I am having these problems more frequently.
 
Last edited:
Ok, I managed to find a solution .. I can't imagine why Microsoft doesn't preclude this in their various other restrictions within the software.

Steps to recreate:

Create a new project, name it MyForm

1) add a user control
2) rename Form1 to MyForm
3) compile
4) add UserControl1 to MyForm
5) compile

There should be at least 1 error generated, possibly many more:

"Error Type 'MyForm.UserControl1' is not defined."

So, I guess the word of caution is don't duplicate any names within your project.
 
Back
Top