Solved

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

Posted on 2011-02-25
6
1,330 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.net/WinForms: adjust Screen Resolution 6 40
Vb.net dynamic formulas in runtime 11 61
Anyway to make "All" the default in the dropdown? 6 34
SQL syntax in VB.net 5 28
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now