Link to home
Start Free TrialLog in
Avatar of kalliopi
kalliopi

asked on

Assembly add a reference to itself when adding user controls from the ToolBox?!?!?!?!

I have an assembly with some UserControl's in it.  Whenever I add one of those user controls to a WinForm, VS2010 adds a reference to it's own assembly.  From then on, I get warnings that there are duplicate definitions of the user control class (the local version, and the version that is compiled in the referenced dll).  I can't edit and continue any of these classes because even though there are no errors after editing, it can't make the changes to the referenced/compiled assembly.

Once I remove the "extra" reference, then the warnings go away, and I can edit/continue again.

This only happens when I drag the control onto a form from the Toolbox.  

Why would visual studio add this circular reference though?  Seems strange.

IT's easy enough to fix, but annoying when I forget that this is what's going on.

Any Suggestions?
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

This doesn't sound like normal behavior, so it might be related to some strange configuration you set up for the control library...what I have no idea...
This sounds like the control class and the namespace have the same name

namespace MyControl
{
    public class MyControl
    {
    }
}

change one or other of the names.
>the local version, and the version that is compiled in the referenced dll
How do you drag and drop the user control from toolbox onto a DLL project? Is it winforms?
Avatar of kalliopi
kalliopi

ASKER

I know it doesn't sound like normal behavior, that's why I'm posting the question.  I've never seen this before either.

This is a winforms project, with winforms UserControls.  They do not share controlname/namespaces.  

I add a new user control to the project, next time I build, it shows up in the toolbox (automagicaly, by VS 2010).  I drag/drop that new control, from the toolbox on a form (or another control) and rather than simply adding the control, it adds the control, and adds a DLL reference under references to the /bin/debug/project.dll file - thus the problems ensue.

Any other ideas/suggestions?
ASKER CERTIFIED SOLUTION
Avatar of kalliopi
kalliopi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
None of the other reasons suggested this, and one of my developers found the reference which resolved the VERY ODD behavior.