471,319 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Indirect assembly references

I've got a solution with two projects. One of those (namespace
MyProject.A) is using a library (e.g. Gentle.Framework). The other
(namespace MyProject.B) is only using classes from MyProject.A.

When compiling the stuff, I get an error message saying that an assembly
reference to Gentle.Framework is needed in MyProject.B. Why is this? I
don't explicitly use anything from Gentle.Framework from within
MyProject.B. Shouldn't the idea of Packages be to hide information about
the implementation. Why has MyProject.B to link to Gentle.Framework just
because MyProejct.A uses that framework for its implementation?

TIA,

Henning.
Nov 29 '05 #1
3 3879
To make it a little clearer... I've got to project files, the first one
being dependent only from a library (Gentle.Framework), the second one
being dependent only from the first one.

Project PackageA.csproj:

Class ClassA.cs:

----------
| using System;
| using Gentle.Framework; /* with reference */
|
| namespace MyProject.A
| {
| /* using Gentle framework */
| }
----------

Project PackageB.csproj:

Class ClassB.cs

---------
| using System;
| using MyProject.A; /* with reference */
|
| namespace MyProject.B
| {
| /* using classes from MyProject.A */
| }
----------

My question:

Why do I have to reference the "Gentle.Framwork.dll" from within
PackageB.csproj?

Henning Möller schrieb:
I've got a solution with two projects. One of those (namespace
MyProject.A) is using a library (e.g. Gentle.Framework). The other
(namespace MyProject.B) is only using classes from MyProject.A.

When compiling the stuff, I get an error message saying that an assembly
reference to Gentle.Framework is needed in MyProject.B. Why is this? I
don't explicitly use anything from Gentle.Framework from within
MyProject.B. Shouldn't the idea of Packages be to hide information about
the implementation. Why has MyProject.B to link to Gentle.Framework just
because MyProejct.A uses that framework for its implementation?

TIA,

Henning.

Nov 29 '05 #2
Henning,

Not always, though. It happens when MyProject.A use classes from
Gentle.Framework as base classes or implements interfaces. In this case the
compiler needs to have reference to the Gentle.Framework assembly because
now you basically uses a class from Gentle.Framework is part of the
declaration of a class in MyProject.A.

Look at it this way - if in MyProject.B you wan to instantiate some class
declared in Gentle.Framework and you didn't add a reference to it, the
compiler will complain and you will add this reference without saying a
word. The situation is almost the same - now you don't isntantiate this
class directly, but it is instantiated as part of the class declared in
MyProject.B so you need to add reference to assembly(ies) for all base
classes and intefaces.

HTH

Stoitcho Goutsev (100) [C# MVP]

"Henning Möller" <he*****@moeller-mingers.de> wrote in message
news:dm**********@online.de...
I've got a solution with two projects. One of those (namespace
MyProject.A) is using a library (e.g. Gentle.Framework). The other
(namespace MyProject.B) is only using classes from MyProject.A.

When compiling the stuff, I get an error message saying that an assembly
reference to Gentle.Framework is needed in MyProject.B. Why is this? I
don't explicitly use anything from Gentle.Framework from within
MyProject.B. Shouldn't the idea of Packages be to hide information about
the implementation. Why has MyProject.B to link to Gentle.Framework just
because MyProejct.A uses that framework for its implementation?

TIA,

Henning.

Nov 29 '05 #3
Thanks for this insight.

You're right, this is kind of reasonable. And in fact, I've got to
consider my inheriting the technology classes (Gentle) in the business
logic layer a design flaw. I'll change that to aggregation instead. That
saves me from those additional references.

Cya,
Henning.

Stoitcho Goutsev (100) [C# MVP] schrieb:
Henning,

Not always, though. It happens when MyProject.A use classes from
Gentle.Framework as base classes or implements interfaces. In this case the
compiler needs to have reference to the Gentle.Framework assembly because
now you basically uses a class from Gentle.Framework is part of the
declaration of a class in MyProject.A.

Look at it this way - if in MyProject.B you wan to instantiate some class
declared in Gentle.Framework and you didn't add a reference to it, the
compiler will complain and you will add this reference without saying a
word. The situation is almost the same - now you don't isntantiate this
class directly, but it is instantiated as part of the class declared in
MyProject.B so you need to add reference to assembly(ies) for all base
classes and intefaces.

HTH

Stoitcho Goutsev (100) [C# MVP]

"Henning Möller" <he*****@moeller-mingers.de> wrote in message
news:dm**********@online.de...
I've got a solution with two projects. One of those (namespace
MyProject.A) is using a library (e.g. Gentle.Framework). The other
(namespace MyProject.B) is only using classes from MyProject.A.

When compiling the stuff, I get an error message saying that an assembly
reference to Gentle.Framework is needed in MyProject.B. Why is this? I
don't explicitly use anything from Gentle.Framework from within
MyProject.B. Shouldn't the idea of Packages be to hide information about
the implementation. Why has MyProject.B to link to Gentle.Framework just
because MyProejct.A uses that framework for its implementation?

TIA,

Henning.


Nov 30 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Christopher Burns | last post: by
13 posts views Thread by ganeshb | last post: by
reply views Thread by Eric Barr | last post: by
2 posts views Thread by john | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.