Solved

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

Posted on 2011-02-25
6
1,339 Views
Last Modified: 2013-12-17
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?
0
Comment
Question by:kalliopi
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34985885
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...
0
 
LVL 1

Expert Comment

by:jefftope
ID: 35005808
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.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35021377
>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?
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 6

Author Comment

by:kalliopi
ID: 35038184
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?
0
 
LVL 6

Accepted Solution

by:
kalliopi earned 0 total points
ID: 36188342
So - the problem turns out t have been result of a CIRCULAR reference in our projects.  There were actually 2 projects.

Project A had a reference to project B.  Project B had a DLL reference to the output DLL of Project A.  Because of this, it didn't show up as a circular reference, but caused the whole solution to rebuild EVER time (even if NOTHING had changed), and also to add the DLL reference to it's own project as originally described.

Getting rid of the circular reference solved the problem.
0
 
LVL 6

Author Closing Comment

by:kalliopi
ID: 36212881
None of the other reasons suggested this, and one of my developers found the reference which resolved the VERY ODD behavior.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question