Call .NET C# dll from QT ?
-
wrote on 6 Jun 2014, 12:55 last edited by
Hi ,
I'm new in C++ and QT and I need some help.
I have built a com object (not something visual) with some methods and the task is to call my .NET C# dll from inside QT (a console application or even a Windows Application).
I read the documentation and tried unsuccessfully to make that call happen.I read the below
http://doc.qt.digia.com/4.6/qaxbase.html#control-prop
https://qt-project.org/doc/qt-4.7/activeqt-dotnet.htmlbut without success.
Can anyone has a small snippet of code on how to do this in QT ?
Is QT supports that ?I tried to use this
QAxObject object("C:/Myfolder/MyCOM.dll")
but I got an unresolved something
I tried this
QLibrary lib( "C:\Myfolder\MyCOM.dll" );
lib.load();
but it was not loaded.
I ran out of ideas .Appreciate any help you could give me.
thank you in advance -
wrote on 6 Jun 2014, 13:30 last edited by
I have tried this
QLibrary mylib("C:\Myfolder\MyCOM.dll");
bool okLoad = mylib.load();
bool loaded = mylib.isLoaded();and both bool return true
So, that means that the dll is loaded ?
And Now how can I call a method from the Com Object ? -
wrote on 9 Aug 2014, 00:59 last edited by
You need to resolve the functions you would like to call in the dll. The "QLibrary documentation":http://qt-project.org/doc/qt-5/QLibrary.html shows an example.
Create a typedef for the function prototype, then resolve the function by name.
-
wrote on 9 Aug 2014, 02:28 last edited by
C# DLL cannot directly called like C++ DLL's. So QLibrary cannot be used.
You can use QAxObject, but your C# DLL need to export COM objects (Interop) which is not enabled by default during compilation.
-
wrote on 9 Aug 2014, 10:06 last edited by
I apologize, you are correct. QLibrary is only for C.
There is a good example on the QAxBase docs "here":https://qt-project.org/doc/qt-4.7/qaxbase.html, although I have only used QAxObject to populate Microsoft excel documents