Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Calling a .NET library (.dll) from a Qt application
QtWS25 Last Chance

Calling a .NET library (.dll) from a Qt application

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 11.8k 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.
  • M Offline
    M Offline
    magpielover
    wrote on 11 Jan 2012, 15:19 last edited by
    #1

    Hello,
    I am conducting a research about text clustering and have found a third party library written in .NET. However, I haven't used .NET and am not familiar with VS .NET environments. I would like to use the library I found in my pure c++ application. I googled and found some possible ways to do that. For example "ActiveQt":http://developer.qt.nokia.com/doc/qt-4.8/activeqt-dotnet.html.
    To be honest, I didn't find it useful for my purpose because it only demonstrates how Qt objects can be used in a .NET environment not how .NET objects can be used in a Qt environment.

    I have a few questions.

    Should I modify the source code of the library I found such as making it a COM object?
    If so, how?
    I guess it's possible to call the library as a COM object from Qt. But I am not sure how to do that.

    Second question is, is there anyone who had a similar problem and have managed to solve it or is there any descriptive tutorial I can follow?

    The question is pretty simple, I need to call a third party .NET dll in Qt.

    Hope you can help me.

    Thanks

    1 Reply Last reply
    0
    • J Offline
      J Offline
      joonhwan
      wrote on 12 Jan 2012, 12:06 last edited by
      #2

      If the .net assembly is written to support so called "COM Interop", then you can use it as COM componet using ActiveQt framework. QAxObject or QAxWidget will help you use the lib in your Qt app, I believe.

      joonhwan at gmail dot com

      1 Reply Last reply
      0
      • M Offline
        M Offline
        magpielover
        wrote on 12 Jan 2012, 14:32 last edited by
        #3

        Actually, I have achieved to use a simple C# library created in .NET in my Qt application without needing QAxObject or QAxWidget.

        I just used @#import "myLib.tlb"@ keyword.
        However, I cannot do the same things for a large library called WordNet.Net.
        I also tried the other way around and attempted to run examples/dotnet/wrapper/wrapper.sln , but it gives an error.

        @1>------ Build started: Project: lib, Configuration: Release Win32 ------
        1>Performing Custom Build Step
        1>The system cannot find the path specified.
        1>Project : error PRJ0019: A tool returned an error code from "Performing Custom Build Step"
        1>Build log was saved at "file://e:\Qt\Examples\4.7\activeqt\dotnet\wrapper\lib\Release\BuildLog.htm"
        1>lib - 1 error(s), 0 warning(s)@

        I don't know what to do with it but I will post here if I find a solution.
        Thanks

        1 Reply Last reply
        0
        • J Offline
          J Offline
          joonhwan
          wrote on 18 Jan 2012, 01:33 last edited by
          #4

          Hmm. your .NET assembly doesn't seem to carry tlb file.
          If your .net assembly provides COM interop, you can generate your own tlb file using tlbexp.exe.
          You can google this keyword 'tlbexp.exe" or "generate tlb from .NET assembly" ...

          BTW, if you know the CLSID, progid, .... of the component, I think it'll be easier to use dumpcpp.exe tool in Qt/bin than using #import ... primitive. dumpcpp can generate more Qt-stylish c++ wrapper.
          Hope this helps

          joonhwan at gmail dot com

          1 Reply Last reply
          0
          • H Offline
            H Offline
            HarrySatt
            wrote on 4 Feb 2013, 10:17 last edited by
            #5

            In QT5.0.0 I used the regasm command (VC 2010 SDK) to create a typelib from my .NET assemply created with National Instruments LabVIEW. dumpcpp helps me to create the .cpp and .h files for use with ActiveQt

            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