MFC DLL Calling C# Assembly

D

David

I have been trying to get a simple mfc dll I wrote to add to numbers
call a C# assembly. Here is a sample of my C++ code in my cpp file.

extern "C" _declspec(dllexport) int Calc(int no1,int no2)
{
//result = no1 + no2;
return MangedAdder(no1, no2);
}
#pragma managed

#using <mscorlib.dll>
#using <ControllerLibrary.dll>

int MangedAdder(int a, int b)
{
ControllerLibrary::DLLController *t = new
ControllerLibrary::DLLController();
return t->AddNumbers(a, b);
}

All I really need is an extern function in a mfc dll that calls a
method in a C# assembly. I don't even know if I need a managed
function inside my C++ dll to call the C# method. The code above is
just based upon a sample I found on the internet. The error I am
getting with the code above is the following:

fatal error C1107: could not find assembly 'ControllerLibrary.dll':
please specify the assembly search path using /AI or by setting the
LIBPATH environment variable

I have put the ControllerLibrary.dll assembly in the directory of my
mfc project. I put the path to it in the LIBPATH. I put the path in
using the /AI switch. I have also given the assembly a strong name
and placed it in the gac. None of those changes seemed to help. I
would appreciate anyones suggestions or even better an example of code
that works which calls a C# method from a MFC DLL extern function.
Thanks for any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top