Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Call .NET C# dll from QT ?

Call .NET C# dll from QT ?

Scheduled Pinned Locked Moved 3rd Party Software
5 Posts 3 Posters 9.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zakkar1
    wrote on 6 Jun 2014, 12:55 last edited by
    #1

    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.html

    but 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

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      zakkar1
      wrote on 6 Jun 2014, 13:30 last edited by
      #2

      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 ?

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vezprog
        wrote on 9 Aug 2014, 00:59 last edited by
        #3

        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.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          TioRoy
          wrote on 9 Aug 2014, 02:28 last edited by
          #4

          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.

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vezprog
            wrote on 9 Aug 2014, 10:06 last edited by
            #5

            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

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved