?
Solved

Adding a reference to one assembly requires additional references!

Posted on 2008-06-10
5
Medium Priority
?
253 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:
Joel Coehoorn earned 1500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

839 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