Invoking c# dll function from managed c++

Hello people.
I need help invoking c# dll from managed c++.
I have a String Export(); function in c#. Can anyone paste som sample code of how to invoke this function and retrieve the String?

Thanks in advance
All you have to do is reference the DLL, and then call the method, either statically (if it is a static method), or through an object. I'll assume the class' name is MyClass, and that the method is non-static, and you'll have to pardon my C++/CLI if it is not syntactically valid as I don't code in C++/CLI:

1
2
MyClass^ c = gcnew MyClass;
System::String^ theString = c->Export();


I think that gives you the idea. Others are free to correct me.

As a note, this site has traditionally covered unmanaged C++ only. In my opinion, you get faster and more accurate responses for CLI @ the MSDN forums.
Damn it. I get error when i reference to dll
0x06798844 { "Could not load file or assembly 'QBLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."}

I reference to my QBLib.dll by right clicking the c++ project and clicking References. Then i click on "add new reference" and i browse to my QBLib.dll.
Then i add using namespace QBLib; in my .cpp and it compiles without errors.

Any ideas?

EDIT: I just found out that my c++ dll was looking for c# dll in other directory.
The directory i had to put my c# dll is the directory in which the .exe program is located.
Last edited on
closed account (1vRz3TCk)
Try right clicking on the reference to QBLib.dll, select properties and see if Copy Local is set to true or not.
Topic archived. No new replies allowed.