Solved

Adding a reference to one assembly requires additional references!

Posted on 2008-06-10
5
243 Views
Last Modified: 2010-04-15
Hi there,

I am trying to get straight in my head that sometimes when i add a reference to a project then it won't compile as it says that this assembly reference a,b,c,d so you must add a reference to a,b,c,d in my current project.

Confusing! :-) ... Actually i am quite used to it... and very easy to fix... just do exactly what it says...

The thing that is annoying me a little bit is that sometimes it happens and sometimes it doesn't....

Can anyone explain exactly in which scenerio it happens, is it if the other assembly exposes public methods (for example) which take parameters of another assembly.

Any ideas or help would be really appreciated...as i say its pretty easy to fix BUT i just wanted to know why ... so i can think my design up a little better..

Thanks in advance

0
Comment
Question by:iangregson1
  • 2
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
jcoehoorn earned 500 total points
ID: 21753216
> "the other assembly exposes public methods (for example) which take parameters of another assembly."

Sounds pretty close. The assembly can also expose classes, structures, delegates, enums, etc defined by these assemblies.
0
 
LVL 14

Expert Comment

by:ajitha75
ID: 21753975
You will need to add a reference to an assembly if you are going to directly use any types(classes, structures etc) from that assembly in your project.

0
 

Author Comment

by:iangregson1
ID: 21757005
Thanks both, so to confirm, sorry still a little confused...

so if i reference an assembly and that assembly references 5 other assemblies but all the types used from these assemblies are private/internal then visual studio is not going to force me to add a reference to these 5 assemblies in my current assembly?

Is that right,

Stress, i just think i confused myself :-)
0
 
LVL 14

Expert Comment

by:ajitha75
ID: 21758382
it depends. if any of the types from those 5 assemblies are used in the public interface of your referenced assembly then it will be a problem. To give an example.

In assembly1.dll
you have a type

public class A
{
              public void method1(classB  parameter1)
              {
                         ....do something....
               }
}


Now in assembly2.dll
you have

public Class B
{
             .....methods  & properties
}

since Class B is in public interface of method1 and you are going to use method1, you will have to reference both dll.

However another scenario

In assembly1.dll
you have a type

public class A
{
              public void method1()
              {
                      B b = new B();
                         ....do something....
               }
}


Now in assembly2.dll
you have

public Class B
{
             .....methods  & properties
}


here you dont have to reference assembly2.dll
0
 

Author Comment

by:iangregson1
ID: 21759399
hi ajitha75,

yes but that isn't quite what i was referring to ...

i know if one assembly uses another it requires the reference... what i was referring to was (see my oriiginal post)....

its when an assembly reference another assembly but visual studio requires you to reference even more assemblies becasue the assembly you are referencing also references these...
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

Suggested Solutions

Title # Comments Views Activity
Data Saving(2) 2 29
How to measure sizes and angles in scanned images ? 3 31
Jquery autocomplete 10 31
Asp.net mvc foreach 3 12
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
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…

746 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

10 Experts available now in Live!

Get 1:1 Help Now