I inherited half of the completed application, which seems to be using a model that I'm not sure can work reliably.
This is an ASP.NET web service that loads unmanaged C ++. DLL on each call using
[DllImport ( "kernel32.dll" , EntryPoint = "LoadLibraryA" )]
public static extern int LoadLibrary( string lpLibFileName );
and then makes several calls, for example,
[DllImport(@"MyUnamanagedDLL.dll")]
public static extern string DoStuff( );
Unmanaged C ++. Dll uses a one-point relationship between states between calls. This means that it should only initialize once and load a bunch of slow files from disk and database, and not every web service call, because it is too slow.
Thus, each call to an unmanaged .dll first calls Getinstance (), if the instance is null, it initializes it and reloads everything if it does not assume that it is ready for operation.
FreeLibrary -, , , .
? , - , ? , singleton loadlibrary?