Results 1 to 5 of 5

Thread: use dll

  1. #1
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Red face use dll

    hello everyone,
    I m trying to embed dotnet dll into my QWidget .but I have no idea how does it implement .........................
    if anyone know please tell me ..........
    I need your help ........
    thanx in advance......

  2. #2
    Join Date
    Mar 2006
    Posts
    140
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: use dll

    A .dot dll is not a standard dll, it's an "Assembly" which is a IL (intermediate language byte code), not something that can be loaded by the standard C++ load library calls.
    Someone may have written a loader but it's not an out of the box option.

    If you have the source code for the dll, then I'd reccomend adding "attributes to the class declarations and members you want "exported" making them COM ready, then use the Active Qt API to treat them like any other COM object. Find some tutorials on the COM on .NET stuff by searching for CCW (COM Callable Wrapper) and RCW (Runtime Callable Wrapper). I used this technique to create a Windows Explorer context menu shell extension in C#.

    If you don't have the source code, then it'd be quite easy to create a .NET wrapper for the dll which does the above mentioned stuff. Create yourself a new "Class Library" project in Visual Studio, then add a "Reference" to the dll, include the namespaces from the external dll and you can wrap each public member into a COM callable class.

    I m trying to embed dotnet dll into my QWidget
    Are you trying to display ui controls on your QWidget? I'm not sure if it's that simple, maybe if the Control is defined as a COM object it will work, this will require some experimentation on your part.

  3. The following user says thank you to stevey for this useful post:

    ellacharmed (8th November 2012)

  4. #3
    Join Date
    Mar 2006
    Posts
    140
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: use dll

    Looks promising:
    3. There is no problem embedding COM or ActiveX controls in Qt, even in the CE version. We have ActiveQt for that.
    from http://blogs.msdn.com/mikehall/archi...indows-ce.aspx

    As long as you expose your .NET classes (either by modifying the source or writing a wrapper) to COM you should be fine. I'd personally use the wrapper approach and subclass each class, but don't extend anything, just pass all parameters into the base class and add the member "Attributes" to expose to COM. The only issue here is you'll need to distribute 2 dlls with the project, if you want only one then merge the 2 into 1 using ILMerge from the Microsoft website.

    I hope this helps.

  5. #4
    Join Date
    Mar 2006
    Posts
    140
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: use dll

    Here's a good explanation on exposing the .NET interface to COM
    Ignore the bit about Java, use QAxContainer

    http://www.codeproject.com/KB/COM/javanet.aspx

  6. The following 2 users say thank you to stevey for this useful post:

    ellacharmed (8th November 2012), MrShahi (25th April 2008)

  7. #5
    Join Date
    Mar 2006
    Posts
    140
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: use dll

    I ran a test, I wrote a .net user control in C# and built it.

    I then created a separate project with a "strong name" (Given that a .NET control to be exposed to COM needs to be registered in the Global Assembly Cache (GAC), it needs a strong name), but when you create a strongly named assembly in .NET, then every assembly referenced ALSO needs a strong name. You have 2 options, in the assembly you're trying to wrap, add a strong name ref to the project properties, but if you only have the dll and it isn't strongly named, you can't reference it from a strongly named project. So you need "Signer" from http://geekswithblogs.net/akraus1/ar...23/104288.aspx which will disassemble the assembly to IL (Intermediate Language) sign it and re-assemble to a new DLL. You will then be able to add the reference.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.