Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Creating a shared DLL using ActiveQt



  • Re: Create a shared Dll to be used in a vb.net or c# application
    @hskoglund
    It has been quite sometime.. exactly one year since the last time you helped me with the same topic. Getting the hierarchy example working.
    At that time the example worked and then the DLL that I created also worked and I could see the DLL in the visual Studio references as a COM Component.
    Now I had to modify the DLL to add some more functionality and recreate the DLL. However this time again the DLL is not seen in the references.

    My development environment was untouched for the last 6 months, Windows 7 64bit OS, with Qt5.8 for MSVC15 32 bit, MSVC15 Community Edition.
    Everything working perfectly fine till regsvr32 step.. no problem with that.
    However the com component not seen in Visual Studio. Since It was not working, I recreated the development enviornment in another Virtual Machine and tried the same with hierarchy example to start as first step. However, even for hierarchy example, it does not work for me now.
    If i try to add the reference using Browse, I get an error
    A Reference to ... hierarchyax.dll could not be added. Please make sure the file is accessible and that it is a valid assembly or COM component.
    This is the exact same error that i get for my application dll also.
    I am going wrong somewhere.
    Please help me understand my mistake.

    Thanks.



  • Hi there :-)

    I have almost the same setup as you (Win7, MSVC2015 Qt 5.10.1 32-bit) just tested the hierarchy example.

    Building the hierarchyax.dll, when I tried to do a regsvr32 on it it failed with "Could not register" :-( I forgot the windeployqt step. Old man :-(

    But after I did windeployqt on hierarchyax.dll I could do a successful regsvr32 on it (regsvr32 shows its dialog box "..registered ok") then when I started a new VB.NET project in Visual Studio, I could do Project/Add Reference and add the hierarchyax 1.0 Type Library no problem.

    But perhaps it fails for you to add the reference in Visual Studio, even though you've done windeployqt and regsvr32 successfully, because on Windows, what can happen, if you've compiled and recompiled your component many times it can bloat/suffocate the registry so that old/deleted entries of your .dll hide the real ones from Visual Studio.

    What you can try then in Visual Studio, goto Project/Add Reference... and then select the COM tab (as usual) to the left, but now click the Browse button down below. Then navigate to where you .dll is and try to select it that way.

    Edit: sorry didn't read until now that you've already tried the Browse button :-(
    Hmmm if regsvr32 succeeds then it should be visible in the "Type Libraries" list.
    If you've been struck by the registry sickness I talk about above, one other workaround is to rename the .dll and then do regsvr32 on it. That way you'll get the a fresh entry in the registry.



  • @hskoglund
    Yes, I even tried doing that but still the same result.
    In fact yesterday I did that complete process in a completely new Virtual Machine with fresh installation of the visual studio, qt and still the same result. First I though I might have skewed the code while making the changes in my project. But when i saw the same thing happening with the hierarchy example, that is when I am thouroughly confused.
    Even renaming the dll has not solved that.
    The Regsvr32 is a success but no listing.



  • Hmm, maybe we need to check your registry health:
    open a CMD window and type regedit then type ctrl+F to search for hierarchyax
    If regsvr32 and the registry are ok then the first 3 hits should be these:
    0_1521121488024_Screenshot from 2018-03-15 14-38-01.png 0_1521121496400_Screenshot from 2018-03-15 14-39-06.png 0_1521121500160_Screenshot from 2018-03-15 14-40-00.png



  • @hskoglund said in Creating a shared DLL using ActiveQt:

    hierarchyax
    Your images do not match with my search results. I have attached the first 6 instances of registry results.
    0_1521208952788_hierarchyax1.jpg 0_1521208959649_hierarchyax2.jpg 0_1521208965075_hierarchyax3.jpg 0_1521208971405_hierarchyax4.jpg 0_1521208976897_hierarchyax5.jpg 0_1521208982545_hierarchyax6.jpg

    What is your suggestion?



  • Hi, your registry looks fine, you have the same entries I have (I got them in another order). The ProgID 'hierarchyax.QParentWidget.1' is correct.

    So if your registry is healthy then why isn't the hiearchyax dll showing up in Visual Studio? Here's how my list looks, do you have some other similar entries or is your list all different?
    0_1521216912120_Screenshot from 2018-03-16 16-26-31.png

    To help out, I dug out from my MFC days an old app I used to debug similar problems, it's called DimTest, looks like this:
    0_1521217138698_Screenshot from 2018-03-16 17-00-26.png

    It's written in 2005, Visual Studio 2015 managed to load and convert it to .sln style. (Almost perfect, I had to fix where the linker created the .exe file, not in Release but in the source folder.)
    You can download the source, solution and .exe file here

    I've patched it for you to lookup 'hierarchyax.QParentWidget.1' you just have to press the "Check it out" button :-)



  • @hskoglund
    Now I have been doing something like this.
    I created a fresh Virtual Machine with Windows 7. Installed Qt5.8 and msvc2015 again.
    Then tried the hierarchy example and I did not see the DLL in the references.
    So since you have a Qt5.10, I installed the Qt 5.10.1, built the hierarchy example.
    One thing that i did different was i renamed the hierarchy dll by adding a few numbers to it.
    And.... the new dll showed itself in the references.
    Then I changed the name of the 5.8 compiled dll and now even that dll showed itself in the references.

    And then when i compiled my application dll, changed its name and registered it, even that dll showed itself in the references.

    I dont have a clue as to why it was not displaying earlier and why it has started displaying after installing 5.10.1
    And with such findings, I want to know what files I should distribute along with my application DLL.
    I am packaging all the files collected by windeployqt.exe and the vc++ redistributable 2015 setup for the 32 bit version. Do I need any more files to ensure that the DLL is shown in references on any other computer.



  • All the files from windeployqt.exe and the vc redistributable sounds good. And yes, one more thing: do a regsvr32.exe on your .dll to enter it into the registry of that computer. Good luck!



  • Thank You @hskoglund for all the help.


Log in to reply