C# - Getting references of reference

I have built a class library project, that references a couple dll's. In the constructor of my class library project I use some enums from one of the referenced dll's. When using my class library in another project is it possible to not have to add references to my dll and the ones my class library project references internally?


It depends on what you mean by reference internally.

If your application project uses type A from your class library, and that class does not expose any public types from other libraries, 3rd party or not, you don't need to add any references to more than your class library containing type A.

However, if type A exposes some public properties, methods returning types, or taking parameters of types, or perhaps type A is descended from a type, that is located in some other assembly, then you need a reference to that other assembly as well.

So if you indeed mean uses internally, then it should not be necessary to add more than just the one reference to your class library.

However, if the compiler complains, then that's what matters.


You only need to reference the DLL. You only reference what you use in an assembly; the assemblies are fully self-describing individual units and thus don't require referencing the references a referenced assembly references (I am being tongue-in-cheek with my repeated use of the word 'reference' here btw :-) .

Imagine if you did have to do that - the BCL references many different things, let alone a 3rd-party component, imagine how much effort you'd have to go to just getting the references right!!


If you are referencing any types (even if only it's their members or typed instances) that a refernced assembly is exposing then you have to include a reference to that assembly as well.


Take your own enum in the ctor, and translate it to the 3rd party enum. I believe that'll keep your caller from having to reference the 3rd party assembly (though, of course, it'll still need to be available at runtime for your code to work).


I think lassevk explained it concisely, but just wanted to add that although you don't need to reference those additional assemblies used by the DLL (again assuming they are only used internally and not exposed), you do still need to make them accessible to your application. That is, they must be findable--either alongside the application, or in the GAC, otherwise the DLL that uses them won't be able to find them.


I'm not sure what are you trying to do but you don't have to reference any assembly if you don't want to . You can use reflection. It is usually regarded as a hack and is not recommendable but sometimes necessary. Here you have an article explaining how to.


  • What is the easiest way to test for class membership in coffeescript?
  • How does -InputObject parameter of the Sort-Object cmdlet work?
  • Calling a Java method from a sqlite trigger (android)
  • junit: how to avoid false positives when using forkMode=“once”?
  • What if the best way to return Option types by WCF service
  • Setting a Sharepoint Site Theme through a Web Service?
  • Best GAC Tutorial/Overview? [closed]
  • What is the best way to include a style sheet for a specific page?
  • How to override List.Add method?
  • How to modify the HTML tag in Drupal 6?
  • Wrap assemblies in .NET?
  • Why can't I use non-integral types with switch [duplicate]
  • init_seg and warning C4073 from library code?
  • Other than Linq to SQL does anything else consume INotifyPropertyChanging?
  • Translating C# to PowerShell in InterIMAP
  • Synchronize windows folders
  • Does Apple allow the usage of sysctl.h within iOS applications?
  • Servlet stops working on Tomcat server after some hits or time
  • Possible to “watch” both HAML and SASS at the same time?
  • Private IP address in reserved subnet range
  • Best way to dynamically load an xml configuration file into a Flex4/Flash movie at runtime?
  • SAVE attribute needed for Fortran variables when only the C_LOC address is returned to a C program?
  • Web.config system.webserver errors
  • WPF Visiblity Binding to Boolean Expression with multiple Variables
  • Spring Cloud Microservice Architecture Confusion
  • How does document.ready work with angular element directives?
  • Not able to aggregate on nested fields in elasticsearch
  • gspread or such: help me get cell coordinates (not value)
  • x64 applications using gdi+: what are the consequences on performance?
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • How to get Eclipse Oxygen to run on Java 9
  • Yii2: Config params vs. const/define
  • Q promise. Difference between .when and .then
  • NetLogo BehaviorSpace - Measure runs using reporters
  • Spring security and special characters
  • JSON with duplicate key names losing information when parsed
  • Statically linking a C++ library to a C# process using CLI or any other way
  • C# - Getting references of reference
  • -fvisibility=hidden not passed by compiler for Debug builds
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]