Reputation: 348
I have Sample.dll in C++ like this,
extern "C" __declspec(dllexport) int func()
{
return 100;
}
and in from C# i call this
[DllImport("SampleCPP.dll")]
public static extern int func();
I want to know when does Sample.dll will unload from memory when this C# application calls function func(); ?
Upvotes: 0
Views: 281
Reputation: 169488
The unmanaged DLL will be loaded into the process the first time a function in it is called (either from C# or from some other unmanaged code) and will not be unloaded until the AppDomain that loaded it is destroyed. In a typical program you only have one AppDomain, so it would be unloaded when the process terminates.
Upvotes: 3