Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rules for references when inheriting from base class

Tags:

c#

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?

like image 948
Mike Moore Avatar asked Feb 19 '13 19:02

Mike Moore


1 Answers

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

like image 200
Jon Avatar answered Sep 17 '22 14:09

Jon