2

So i have a dll which i want to use with com. It was made in c# and i want to use the dll in delphi. My user is so restricted that registering a dll may be a real pain. And i've been told that something like registration free com exsits so i tried this is what i did:

Create a manifest file for my exe in delphi with this inside:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
 <dependency>
   <dependentAssembly>
     <assemblyIdentity
       type="win32"
       name="Microsoft.Windows.Common-Controls"
       version="6.0.0.0"
       publicKeyToken="6595b64144ccf1df"
       language="*"
       processorArchitecture="*"/>
   </dependentAssembly>
 </dependency>
 <dependency>
    <dependentAssembly>
        <assemblyIdentity 
          name="Calc.X" 
          version="1.0.0.0" 
          type="win32" 
          processorArchitecture="x86">
        </assemblyIdentity>
    </dependentAssembly>
 </dependency>
 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
   <security>
     <requestedPrivileges>
       <requestedExecutionLevel
         level="asInvoker"
         uiAccess="false"/>
       </requestedPrivileges>
   </security>
 </trustInfo>
</assembly>

I added this manifest in Project > options > application > manifest > custom > pointed to my file path.

My c# dll is called Calc.dll (it's jsut a test dll of a calculator example).

Then i added an rc file in my delphi project with right click on the exe (in the ide) Add > rc with this inside:

#define RT_MANIFEST 24 
#define APP_MANIFEST 1

APP_MANIFEST RT_MANIFEST Project2.exe.manifest

I called the manifest file of my project : Project2.exe.manifest

I then created the manifest for my dll

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

  <assemblyIdentity 
    name="Calc.X" 
    version="1.0.0.0" 
    type="win32"
    processorArchitecture="x86">
  </assemblyIdentity>

  <file name="Calc.dll">
    <comClass
            progid="Calculator"
            clsid="{96D7B70E-A084-4EE5-9FDE-AEEDB0C61B9B}"
            threadingModel="Apartment">
    </comClass>
  </file>
</assembly>

Called it Calc.X.manifest.

I used sxsTrace to fix an issue i had (Side by side comparison error or something like that, basicly the versions didn't match and it wouldn't start the exe but now it's fixed).

Then unregistered my dll (i registered in the first place to test if it works). And started the exe but now i get the message that the class is not registered. It gives me the GUID key and i made sure that it's the same as in my manifest.

This is now where i am. I can't make my app use the dll defined in the manifest.

EDIT

I added this to the manifest:

<comClass
            progid="Calculator"
            clsid="{96D7B70E-A084-4EE5-9FDE-AEEDB0C61B9B}"
            threadingModel="Apartment">
    </comClass>

This is my class in the c# dll. I also tried defined the interface (ICalculator) the same way. And now i get another message in my delphi app:

EOleSysError: Error in the DLL, ClassID: {96D7B70E-A084-4EE5-9FDE-AEEDB0C61B9B}

Community
  • 1
  • 1
John
  • 261
  • 2
  • 16
  • 2
    Isn't this a duplicate of https://stackoverflow.com/questions/5074563/registration-free-com-dll – David Heffernan Jul 18 '18 at 08:58
  • There's no answer to my question in that topic. @DavidHeffernan – John Jul 18 '18 at 08:59
  • I honestly never fully understood what I was doing, but I when I enabled my Delphi application to use "registration free COM" with a 3rd party dll, this dll already came with a manifest embedded. This manifest not only has a `tylelib` node, but also `comClass`. It also specified a `asmv2:size` attribute for the `file node` and added a `hash` node as a subnode as well. – Günther the Beautiful Jul 18 '18 at 09:17
  • 1
    It looks like you are trying stuff at random here. I was hoping you'd take more time to read the documentation. Perhaps start from a working example using C++ and then map that across to your Delphi code. – David Heffernan Jul 18 '18 at 09:18
  • @GünthertheBeautiful I removed tylelib actually and put comClass and i get another message (put in the edit). Do you have any idea how is the prog id related to the dll in the manifest in the typelib? Is that a random one? – John Jul 18 '18 at 09:19
  • Sorry - As I said, I have zero experience with COM and barely understood what these GUIDs were for. I was just lucky the DLL I had to implement already had everything set up in its manifest file. Is `sxsTrace` completely satisfied? Pay extra attention to its output, it helped me a lot. – Günther the Beautiful Jul 18 '18 at 09:45
  • Yeah the sxsTrace doesn't add any more detail @GünthertheBeautiful Iti's just empty. – John Jul 18 '18 at 09:50

0 Answers0