Given that Project A is a C# Class Library and that Project B is a console application that has a dependency on Project A.
In Project A the following class is defined:
public class ActionMailNotifier : RazorMailerBase
{
private readonly string _viewPath;
private readonly EmailHost _emailConfig;
...
...
}
"RazorMailBase" is contained in an external dll, ActionMailer.dll, that is referenced by Project A.
In Project B the following class is defined:
public class EmailFareMonitorAlertNotifier : ActionMailNotifier
{
...
...
}
If ActionMailer.dll is not referenced in Project B the compiler generates an error message indicating that a reference to ActionMailer.dll is required. Is there a way to structure this such that a reference to the external dll is not required in Project B?
EmailFareMonitorAlertNotifier
只要EmailFareMonitorAlertNotifier
最终从程序集external.dll
派生,您需要引用它,以便编译器和运行时具有使用该类型所需的信息。
No. If you were to remove all references to any type in Project B that references ActionMailer.dll, you wouldn't see any errors. But since RazorMailBase
is defined in ActionMailer.dll, you'll have to have that reference to use ActionMailNotifier
, or any other type derived from a class in the external library.
作为绝对最小值,项目B将必须引用其自己类型的EmailFareMonitorAlertNotifier
的继承层次结构中存在的所有程序集,所以我猜答案是否定的。
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.