Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-02-25
6
Medium Priority
?
1,355 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

885 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