Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-25
6
Medium Priority
?
1,351 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
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…

670 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