내가 관리되지 않는 C에서 .NET 메소드를 호출 탐험하고 ++ 코드를 C++ DLL을 통해 호출하고 How To Inject a Managed .NET Assembly (DLL) Into Another Process번에 전화했을 때
void StartTheDotNetRuntime()
{
// Bind to the CLR runtime..
ICLRRuntimeHost *pClrHost = NULL;
HRESULT hr = CorBindToRuntimeEx(
NULL, L"wks", 0, CLSID_CLRRuntimeHost,
IID_ICLRRuntimeHost, (PVOID*)&pClrHost);
// Push the CLR start button
hr = pClrHost->Start();
// Okay, the CLR is up and running in this (previously native) process.
// Now call a method on our managed class library.
DWORD dwRet = 0;
hr = pClrHost->ExecuteInDefaultAppDomain(
L"c:\\PathToYourManagedAssembly\\MyManagedAssembly.dll",
L"MyNamespace.MyClass", L"MyMethod", L"MyParameter", &dwRet);
// Stop the CLR runtime
hr = pClrHost->Stop();
// Don't forget to clean up.
pClrHost->Release();
}
이 문제없이 작동에 아래의 기능을 발견 할 때 닷 넷 호스팅 기능을 분할하는 방법 콘솔 응용 프로그램.
지금은 논리적으로이 세 부분
Method - DLLMain
DLL_PROCESS_ATTACH
Bind to the CLR runtime
Push the CLR start button
DLL_PROCESS_DETACH
Stop the CLR runtime
Do not forget to clean up.
Method - CallDotNetToDoSomething
어떻게 내가 이것을 달성하기 위해 ICLRRuntimeHost pClrHost/HRESULT의 시간을 선언 할에 있어야하는 DLL 내에서 사용하기 위해이 기능을 분할 할?
.NET 3.5에서 하나의 프로세스 (side-by-side)에서 여러 개의 .NET 런타임을 가질 수 있습니다. 이것이 원래 포스터의 문제에 어떻게 영향을 미치는지 확실하지 않습니다. –