Search code examples
c#c++.netdelphitypelib

Registration free COM interop. assembly B reference assembly A?


#import Directive is used in C++ to import a Type Library. "no_registry" attribute Tells the compiler not to search the registry for type libraries.

Ex:

#import "XXX.tlb" no_namespace named_guids no_registry

Quastion: I want to do the exact same thing in delphi: I know TLIBIMP is used, but i can not find any attribute like no_registry.

Ex:

TLIBIMP "XXX.tlb" ????

How is this done, or is this even possible?

UPDATE:

I have a Side-by side Side-by-side Assemblies. An COM assembly(B) that references a COM assembly(A). the error might be in the manifest file. How can I define a dependency in the manifest? How can i use Tlbexp.exe to define the dependency? I have already tried:

<?xml version="1.0" encoding="utf-8"?>

<asmv1:assembly
 xmlns="urn:schemas-microsoft-com:asm.v1"
 xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
 xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  manifestVersion="1.0">
   <assemblyIdentity
     type="win32"
     name="CommonInteropB"
     version="1.0.0.0"
     publicKeyToken="" />

   <clrClass
   clsid="{XXXXXXXXX}"
   progid="CommonInteropB.SomeFactory"
    name="CommonInteropB.SomeFactory"
   threadingModel="Both" tlbid="{XXXXXXXXXXXXXXXX}"
    runtimeVersion="v4.0.30319" />

  <dependency>
    <dependentAssembly>
       <assemblyIdentity type="win32"
                    name="CommonInteropA"
                    version="1.0.0.0"
                    publicKeyToken="" />
     </dependentAssembly>
  </dependency>

</asmv1:assembly>

and to create the type library:

tlbexp.exe CommonInteropB.dll /tlbreference:"CommonInteropA.tlb" /tlbreference:"C:\Windows\System32\stdole2.tlb" /tlbreference:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.tlb" /out:CommonInteropB.tlb 

Solution

  • Your manifest looks fine. The dependency is specified by the dependency element.

    tlibimp seems to check for dependencies in the registry and in the working directory (although I can find no documentation for this). If your setup requires side-by-side execution and you want to avoid registering your DLLs, make sure both assembly A and assembly B reside in the working directory and run tlibimp B.tlb [options].