I've stripped it back to a basic concrete class and a two line test method and I'm at a loss to explain the error.
{
public double Close { get; }
public bool FirstBarOfSession { get; }
public double High { get; }
public double Low { get; }
public double Open { get; }
public DateTime Time { get; }
public long Volume { get; }
}
public void TestMethod1()
{
IBar bar = new MyBar();
var close = bar.Close;
}
Error:
Test method IBarTypeInitProblem.Test.TestMethod1 threw exception:
System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: ptr
at System.Runtime.InteropServices.Marshal.GetDelegate ForFunctionPointer(IntPtr*ptr,*Type*t)
at <CliSecureRT>.InitializeThroughDelegate(IntPtr)
at <CliSecureRT>.Initialize()
at .cctor()
--- End of inner exception stack trace ---
at IBarTypeInitProblem.Test.TestMethod1()
remove the var close = bar.Close line and no error. Add it and it throws an exception before then. Any Ideas??
Comment