views:

419

answers:

2

My project references an assembly (will call it X) that references another assembly (will call it Y).

When I try to compile my project, it demands that it should reference assembly Y. Why is that? I get the following error on the line where assembly X is referenced:

The type 'DevExpress.XtraEditors.XtraForm' is defined in an assembly that is not referenced. You must add a reference to assembly 'DevExpress.Utils.v9.1, Version=9.1.2.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a'.

'DevExpress.XtraEditors.XtraForm' is the assembly Y.

Why is this? I haven't seen this behavior before.

+1  A: 

This has always been the behavior as how else will the compiler build your project if it does not have a reference to all the dependencies?

The assemblies that are referenced by your project are required for your application to work. You are using types from those assemblies and without those types your application cannot build. More importantly without those types your application cannot run.

Now consider that every assembly that you reference was built in the same manner as your assembly and requires that all its referenced assemblies be present and accounted for. This does create a chain reaction that can be annoying but the end result is that once you are executing your application, the CLR has all the assemblies that it needs to run your application.

Andrew Hare
+5  A: 

This has always been in place. You will only get these at compile time if you're using an object that gets methods/properties/members etc from assembly Y.

The why is because .NET cannot rely on assembly X to ensure it will be able to obtain proper symbol and meta data information.

Chad Moran
I don't think it's always been this way. I ported the project from .net1.1 to .net3.5 and this issue appeared. If what you are saying is true, then in Project A refs Assembly B which refs Assembly C which refs assembly D, my Project A would have to reference Assemblies B, C and D. Makes no sense
AngryHacker