[英]unmanaged c++ dll called from c#, crashes when CString used in dll
[英]when does unmanaged c++ dll unload from memory when called from C# code using pinvoke
我在C ++中有這樣的Sample.dll,
extern "C" __declspec(dllexport) int func()
{
return 100;
}
從C#中我稱之為
[DllImport("SampleCPP.dll")]
public static extern int func();
我想知道當C#應用程序調用函數func()時Sample.dll何時從內存中卸載。 ?
第一次調用非托管DLL(從C#或從其他非托管代碼)中的函數時,它將被加載到進程中,直到加載它的AppDomain被銷毀,才將其卸載。 在典型的程序中,您只有一個AppDomain,因此當進程終止時,它將被卸載。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.