I've implemented a Dependency constructor within my main program which works perfectly, the method is triggered and it logs my data just fine. however when I attempt to achieve the same thing in another class it gives me the following error:
""System.Null.ReferenceException "object not set to an instance of an object"
I've included the private property and constructor in the class ,as I have in my main program but its still giving me an error. The problem is that the "_LoggingData" is set to null. Does anyone know why this is? Thankyou
This is the private property and constructor that i've included in my exceptionHandling class (where the exception is being thrown)
""System.Null.ReferenceException "object not set to an instance of an object"
I've included the private property and constructor in the class ,as I have in my main program but its still giving me an error. The problem is that the "_LoggingData" is set to null. Does anyone know why this is? Thankyou
C#:
// the error is occuring in the code below. I have this exact code in my main program so i dont understand why its throwing an exception
_loggingData.LogEvent($"An error occured opening {fileName} - Reason : File read error");
This is the private property and constructor that i've included in my exceptionHandling class (where the exception is being thrown)
C#:
private static ILoggingData _loggingData;
public ExceptionHandling(ILoggingData loggingdata) // this is where the error is occuring.
{
_loggingData = loggingdata;
}
Last edited: