I have project B
depending on project A
which is a library that has it's own dependencies.
In project A
I reference the assemblies that define Dependency1Base<T>
and Dependency2Class
, and define MyClass
like this:
namespace MyNamespace
{
public class MyClass: Dependency1Base<Dependency2Class>
{
}
}
In project B
, I just reference project A
and try to instance MyClass
namespace MyNamespace
{
public class B
{
public void main ()
{
var myInstance = new MyClass();
}
}
}
Project A
builds fine, but when I try to build project B
, I get an error telling me that Dependency1Base
and Dependency2Class
are defined in an assembly that is not referenced. So I'm wondering if there is a way to link this definitions in project A
so that I don't have to add those references to project B
? or do I always need to reference the dependencies of project A
in any other project that uses MyClass
?
Yes, you do need to reference everything class or object you use in your project. But you don't have to reference more than that.
If you have a class C
that inherits from B
, which itself inherits from A
:
In C
, you must reference B
, and if you use some properties or method that come from A
, you must reference A
as well
In B
, you must reference A
In `A, you don't have to reference anything.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.