Hello!
I have a problem: I have a .NET process in which my unmanaged FreeBasic DLL is loaded by a global windows hook.
From this DLL, I wanted to inject a VB.NET DLL into the project and call a VB.NET function in the context of the already running .NET runtime.
I created the following C++ DLL as a "loader":
...and the following VB.NET DLL ("HermesLib.dll"):Code:// HermesLibLoader.cpp : Definiert die exportierten Funktionen für die DLL-Anwendung. // #include "stdafx.h" #include "mscoree.h" #include "HermesLibLoader.h" #pragma comment(lib, "mscoree.lib") HERMESLIBLOADER_API HRESULT fnHermesLibLoader(LPCWSTR szFilename, LPCWSTR szParam) { ICLRRuntimeHost *pClrHost = NULL; HRESULT hr = CorBindToRuntimeEx(NULL, L"wks", 0, CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (PVOID*)&pClrHost); if(!SUCCEEDED(hr)) return hr; DWORD dwRet = 0; hr = pClrHost->ExecuteInDefaultAppDomain(szFilename, L"HermesClass", L"Init", szParam, &dwRet); pClrHost->Release(); if(!SUCCEEDED(hr)) return hr; if(dwRet != 42) return ERROR_INVALID_DATA; return ERROR_SUCCESS; }
What happens is, I get a HRESULT of 0x80131522 (COR_E_TYPELOAD).Code:Public Class HermesClass Public Shared Function Init(ByVal Parameter As String) As Integer HelloWorld(Parameter) Return 42 End Function Public Shared Sub HelloWorld(ByVal Parameter As String) MsgBox("Hello World from Hermes! (Param = """ & Parameter & """)") End Sub End Class
Can you help me?
Best regards,
Cherry


Reply With Quote

Bookmarks