I tried calling a function from a vb dotnet dll(from a cpp dll),
this is my code
#include "main.h"
#include <windows.h>
#include <mscoree.h>
#pragma comment(lib,"mscoree.lib")
void DLL_EXPORT SomeFunction()
{
ICLRRuntimeHost *pClrHost = NULL;
HRESULT hr = CorBindToRuntimeEx(
NULL, L"wks", 0, CLSID_CLRRuntimeHost,
IID_ICLRRuntimeHost, (PVOID*)&pClrHost);
hr = pClrHost->Start();
DWORD dwRet = 0;
hr = pClrHost->ExecuteInDefaultAppDomain(
L"message.dll",
L"message.Class1", L"message", L"Hello", &dwRet);
}
extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE; }
the dotnet code is
Public Class Class1
Function message(ByVal a As String)
MsgBox(a)
End Function
End Class
when i try calling SomeFunction using ExecDLL.exe nothing happens
am using codeblocks
compiler is MS visual C++ 2005/2008