Idk if this is correct section for sources code snipets, but here is a source to load .net dll in native process..
.NET C# dll code
C++ CodeCode:namespace MyNamespace { public class MyClass { // This method will be called by native code inside the target process... public static int MyMethod(String pwzArgument) { MessageBox.Show("Hello World"); return 0; } } }
Orginal credits: codingthewheel.comCode:void Start() { // Bind to the CLR runtime.. ICLRRuntimeHost *pClrHost = NULL; HRESULT hr = CorBindToRuntimeEx( NULL, L"wks", 0, CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (PVOID*)&pClrHost); // Push the big START button shown above hr = pClrHost->Start(); // Okay, the CLR is up and running in this (previously native) process. // Now call a method on our managed C# class library. DWORD dwRet = 0; hr = pClrHost->ExecuteInDefaultAppDomain( L"c:\\PathToYourManagedAssembly\\MyManagedAssembly.dll", L"MyNamespace.MyClass", L"MyMethod", L"MyParameter", &dwRet); // Optionally stop the CLR runtime (we could also leave it running) hr = pClrHost->Stop(); // Don't forget to clean up. pClrHost->Release(); }



Reply With Quote![[Source] .NET Dll in Native process](http://ragezone.com/hyper728.png)



