Solved

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

Posted on 2011-02-25
6
1,327 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
Comment Utility
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
Comment Utility
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
Comment Utility
>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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 6

Author Comment

by:kalliopi
Comment Utility
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
Comment Utility
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
Comment Utility
None of the other reasons suggested this, and one of my developers found the reference which resolved the VERY ODD behavior.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

18 Experts available now in Live!

Get 1:1 Help Now