[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Adding a reference to one assembly requires additional references!

Posted on 2008-06-10
5
Medium Priority
?
251 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
[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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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