I have written in C# some code which needs to be called from several unmanaged applications (located in different directories).
I have written in unmanaged C++ a dll which is used by every application to load and execute the C# code. It looks like this:
Problem is with the name of the assembly.
When I install the assembly in the same directory as the calling application and the field MyManagedDll is filled with the physical assemblyname (like C:\xxx\xxx.dll) everything is fine.
But I want MyManagedDll to be called from several applications and therefore put it into the GAC.
If I do this and fill the field MyManagedDll with a string like "MyManagedDll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b3154aff06323403", the call to ExecuteInDefaultAppDomain fails. The HRESULT returned is 80070002 (COR_E_FILENOTFOUND)
Being very thankful for any advice,
Marcel
I have written in unmanaged C++ a dll which is used by every application to load and execute the C# code. It looks like this:
Code:
ICLRRuntimeHost * IRuntime = NULL;
LPCWSTR DotNetVersie = L"v2.0.50727";
LPCWSTR MyManagedDll = L"<Name of my dll>"; //PROBLEM !!
LPCWSTR MyTypename = L"MyNamespace.MyClass";
LPCWSTR MyMethod = L"MyMethod";
LPCWSTR MyArgument = L"<doesnt matter>";
DWORD ReturnValue = 0;
HRESULT DotNetStatus =
CorBindToRuntimeEx ( DotNetVersie, NULL, 0,
CLSID_CLRRuntimeHost,
IID_ICLRRuntimeHost,
(LPVOID *)&IRuntime );
if ( FAILED ( DotNetStatus ))
{ <handle error, no failures here>; }
DotNetStatus = IRuntime->Start ( );
if ( FAILED ( DotNetStatus ))
{ <handle error, no failures here, too>; }
DotNetStatus = IRuntime->ExecuteInDefaultAppDomain
( MyManagedDll, MyTypename, MyMethod,
MyArgument, &ReturnValue );
if ( FAILED ( DotNetStatus ))
{ <handle error, this is where things go wrong> }
... <etc> ...
Problem is with the name of the assembly.
When I install the assembly in the same directory as the calling application and the field MyManagedDll is filled with the physical assemblyname (like C:\xxx\xxx.dll) everything is fine.
But I want MyManagedDll to be called from several applications and therefore put it into the GAC.
If I do this and fill the field MyManagedDll with a string like "MyManagedDll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b3154aff06323403", the call to ExecuteInDefaultAppDomain fails. The HRESULT returned is 80070002 (COR_E_FILENOTFOUND)
Being very thankful for any advice,
Marcel