Rules for references when inheriting from the base class

Given that project A is a C # class library and that project B is a console application that is dependent on project A.

Project A defines the following class:

public class ActionMailNotifier : RazorMailerBase { private readonly string _viewPath; private readonly EmailHost _emailConfig; ... ... } 

"RazorMailBase" is contained in an external dll, ActionMailer.dll, referenced by project A.

Project B defines the following class:

 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 so that a link to an external dll is not required in Project B?

+4
source share
3 answers

No. As long as EmailFareMonitorAlertNotifier ultimately comes from the external.dll assembly, you need to reference it so that the compiler and runtime have the information necessary to use this type.

+1
source

No. If you deleted all references to any type in project B that references ActionMailer.dll, you will not see any errors. But since RazorMailBase is defined in ActionMailer.dll, you will need to use this link to use ActionMailNotifier or any other type derived from a class in an external library.

0
source

As an absolute minimum, Project B will have to reference all the assemblies present in the hierarchy of the hierarchy of its own type EmailFareMonitorAlertNotifier , therefore, I think the answer is no.

0
source

All Articles