G
Guest
Hi
I have a managed DLL code written in C#, which is calling / importing an
unmanaged DLL function. The function in the undamaged DLL code looks like
- Void delete_tuner (short tuner_number)
I create one class that shall contain a set of related unmanaged DLL
functions. The class I created looks like
public class Dll_Pool
{
public DllImportAttribute My_dll = new DllImportAttribute(dllName);
[DllImport(@"\\obj\\Release\\MLibTuners.dll")]
public static extern void delete_tuner(Int16 tuner_number);
public string GetDllName()
{
string dllName;
dllName = My_dll.Value;
return dllName;
}
public Dll_Pool()
{
}
public static void DllMain()
{
Int16 tuner_number = 0;
---> delete_tuner(tuner_number); <--- // The executing of the
code is stoped here and I got an error message
}
}
I have even a simple C# test code which is calling the imported function
according to
Dll_Pool.DllMain();
I have no problem to build the code and start running it in the debug mode.
As I show between the arrows in the code above the executing of the code is
stopped with error message saying.
"Loader Lock Was detected Attempting managed execution inside OS Loader
lock. Do not attempt to run managed code inside a DllMain or
image initialization function since doing so can cause the application to
hang."
I found information, under help documentation which describes what Loader
Lock means and the reasons of it but I did not find documentation in how to
solve the problem. I really hope someone could help me to solve the problem.
I have a managed DLL code written in C#, which is calling / importing an
unmanaged DLL function. The function in the undamaged DLL code looks like
- Void delete_tuner (short tuner_number)
I create one class that shall contain a set of related unmanaged DLL
functions. The class I created looks like
public class Dll_Pool
{
public DllImportAttribute My_dll = new DllImportAttribute(dllName);
[DllImport(@"\\obj\\Release\\MLibTuners.dll")]
public static extern void delete_tuner(Int16 tuner_number);
public string GetDllName()
{
string dllName;
dllName = My_dll.Value;
return dllName;
}
public Dll_Pool()
{
}
public static void DllMain()
{
Int16 tuner_number = 0;
---> delete_tuner(tuner_number); <--- // The executing of the
code is stoped here and I got an error message
}
}
I have even a simple C# test code which is calling the imported function
according to
Dll_Pool.DllMain();
I have no problem to build the code and start running it in the debug mode.
As I show between the arrows in the code above the executing of the code is
stopped with error message saying.
"Loader Lock Was detected Attempting managed execution inside OS Loader
lock. Do not attempt to run managed code inside a DllMain or
image initialization function since doing so can cause the application to
hang."
I found information, under help documentation which describes what Loader
Lock means and the reasons of it but I did not find documentation in how to
solve the problem. I really hope someone could help me to solve the problem.