Author Topic: VS Auto-generated code problem in form  (Read 1384 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
VS Auto-generated code problem in form
« on: August 20, 2010, 02:57:28 PM »
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 value 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.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: VS Auto-generated code problem in form
« Reply #1 on: August 20, 2010, 03:26:28 PM »
Ah .. I knew if I searched long enough I would find the solution ...

Evidently, Microsoft decided it is ok to name a control class the same as the solution .. i.e. is you have a solution named "MyForm" and add a form to it called "MyForm" any calls to that form by the autogenerated code will produce a compile error.

So, just an FYI .. ensure your classes and forms are named differently than the solution.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie