2

I am currently investigating a strange bug where merely adding a certain assembly reference in a project seems to break some functionality of another assembly at runtime. For details, see another question on SO.

What happens when you add an assembly reference? What kind of side effects can it have?

Community
  • 1
  • 1
Sebastian Negraszus
  • 11,915
  • 7
  • 43
  • 70
  • 2
    Does it break at runtime or compile time? The first immediate affect is namespace scope - the namespace and public items of that assembly become visible in code. Perhaps there is a naming clash. It'd be obvious at compile time, but perhaps less obvious at runtime if reflection is involved? – Adam Houldsworth Jul 11 '12 at 08:56
  • If it is runtime, it might be that dependencies of the referenced assembly are missing. – MBen Jul 11 '12 at 09:04
  • @Sebastian What is the error? Any sample code? – Adam Houldsworth Jul 11 '12 at 09:04
  • @AdamHouldsworth: For the precise error, see the other question I linked to. In this question I am more interested in understanding what is happening when you add a reference, not solving the original problem. There is the other question for that. – Sebastian Negraszus Jul 11 '12 at 09:09

1 Answers1

0

Global Assembly Cache

You cannot add references from the global assembly cache because it is strictly part of the run-time environment.


Custom Component

If you deploy or copy an application that contains a reference to a custom component registered in the global assembly cache, the component will not be deployed or copied with the application, regardless of the Copy Local setting.


Outputs of Another Project

You should avoid adding file references to outputs of another project in the same solution, because doing this may cause compilation errors. Instead, use the Projects tab of the Add Reference dialog box to create project-to-project references.


Registered COM DLL

If you want to add a reference to a registered COM DLL that contains an internal manifest, make sure that you unregister the DLL first. If you do not, Visual Studio adds the assembly reference as an ActiveX Component instead of as a native DLL.


EnvDTE namespaces

When you manually add a reference to any of the EnvDTE namespaces (EnvDTE, EnvDTE80, EnvDTE90, EnvDTE90a, or EnvDTE100), set the Embed Interop Types property of the reference to False in the Properties window. Setting this property to True can cause build issues because of certain EnvDTE properties that cannot be embedded.


Reference: MSDN - How to: Add or Remove References in Visual Studio

John Isaiah Carmona
  • 5,260
  • 10
  • 45
  • 79