views:

268

answers:

2

I have assembly A with class Z that inherits from class X in assembly B. Now in a completely different solution, I have assembly C, which uses class Z.

The compiler complains unless assembly C has a reference to both assembly A & B. Even though assembly C does not use class Z directly in anyway.

Is this expected?

It seems to me that if assembly B is missing at run time stuff blows up, but at compile time it shouldn't care.

What am I missing here?

My goal is that I can tell my clients to depend on class Z in assembly A, but I can completely reconfigure my assemblies on the other side and have no effect at all on the client when they upgrade.

A: 

expected behavior; all assemblies up the chain must be referenced

[i don't like this, but that's the way it seems to be]

Steven A. Lowe
+5  A: 

Yes, that's expected.

Think about it - how can assembly C know what it can do with Z unless it knows what the base class is? How could it know about any public members exposed by X?

Jon Skeet
I guess I expected it to work like an interface in code. I am not sure why, I made this assumption.. but I did.
NotMyself