I have the following class:
private static class NativeSomeWrapper
{
[DllImport(NativeMethods.myCeeLib, EntryPoint = "Get_300_bars",
CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.SysInt)]
internal static extern IntPtr Get300bars([MarshalAs(UnmanagedType.SysInt)] IntPtr assessment);
}
And i have a static class that has responsibility to initilize the dll:
internal static class NativeMethods
{
public const string myCeeLib= "myCeeLib.dll";
static NativeMethods()
{
var path = GetPathToMyCeeLibFile();
var err = SetPath(path);
if (err != ErrorCode.Ok)
{
throw new FileNotFoundException("Coulnt find myCeeLib file.");
}
}
}
The problem is that NativeMethods
constructor is not getting called as expected.
How can i make sure that NativeMethods
static constructor is called and the path to library file is set correctly?