参考 https://xz.aliyun.com/t/3050
使用C++封装了一个DLL,导出接口给易语言调用
在C++的DLL中加载了一个C#的DLL
直接在易语言IDE中启动程序测试,调用不成功
易语言编译出来exe后,一切正常
c++代码如下:
HRESULT hr = mICLRRuntimeHost->ExecuteInDefaultAppDomain(L"OSSCom.dll",
L"OSSCom.PublicApi",
wszMethodName,
wszParam,
&dwRet);
经猜想验证测试,
发现ExecuteInDefaultAppDomain的第一个参数要写DLL的全路径,这样在易语言IDE中运行程序才正常
最终代码如下:
LPCWSTR pwzAssemblyPath = L"F:\\build\\OSSCom.dll";
HRESULT hr = mICLRRuntimeHost->ExecuteInDefaultAppDomain(pwzAssemblyPath,
L"OSSCom.PublicApi",
wszMethodName,
wszParam,
&dwRet);