我有Delphi应用程序(hostproject.exe),我想用register free tech使用.NET COM对象(netside.dll)。
应用程序启动时,显示并排配置错误和sxtrace日志:
无法解析引用mscorlib,publickeytoken=“b77a5c561934e089”,
版本=“4.0.0.0”。
hostproject.exe.manifest

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity type="win32" name="client" version="1.0.0.0" />
  <dependency>
      <dependentAssembly>
          <assemblyIdentity type="win32" name="NetSide.sxs" version="1.0.0.0" processorArchitecture="msil"/>
      </dependentAssembly>
  </dependency>
</assembly>

netside.sxs.manifest文件
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity type="win32" name="NetSide.sxs" version="1.0.0.0"  processorArchitecture="msil"/>
  <clrClass clsid="{E6C4A866-F58C-415E-9745-E0E7812B4386}" progid="NetSide.Class1" threadingModel="Both" name="NetSide.Class1" runtimeVersion="v4.0.30319"/>
  <file name="NetSide.dll" hashalg="SHA1"/>
  <dependency>
    <dependentAssembly>
        <assemblyIdentity name="mscorlib" version="4.0.0.0"  processorArchitecture="x86"  publicKeyToken="b77a5c561934e089"/>
    </dependentAssembly>
  </dependency>
</assembly>

sxstrace日志如下:
=================
Begin Activation Context Generation.
Input Parameter:
    Flags = 0
    ProcessorArchitecture = Wow32
    CultureFallBacks = en-US;en
    ManifestPath = G:\Debug\HostProject.exe.Manifest
    AssemblyDirectory = G:\Debug\
    Application Config File =
-----------------
    INFO: Parsing Manifest File G:\Debug\HostProject.exe.Manifest.
    INFO: Manifest Definition Identity is client11,type="win32",version="1.0.0.0".
    INFO: Reference: NetSide.sxs,processorArchitecture="msil",type="win32",version="1.0.0.0"
    INFO: Resolving reference NetSide.sxs,processorArchitecture="msil",type="win32",version="1.0.0.0".
    INFO: Resolving reference for ProcessorArchitecture msil.
        INFO: Resolving reference for culture Neutral.
            INFO: Applying Binding Policy.
                INFO: No binding policy redirect found.
            INFO: Begin assembly probing.
                INFO: Did not find the assembly in WinSxS.
                INFO: Attempt to probe manifest at G:\Debug\NetSide.sxs.DLL.
                INFO: Attempt to probe manifest at G:\Debug\NetSide.sxs.MANIFEST.
                INFO: Manifest found at G:\Debug\NetSide.sxs.MANIFEST.
            INFO: End assembly probing.
INFO: Resolving reference NetSide.sxs.mui,language="&#x2a;",processorArchitecture="msil",type="win32",version="1.0.0.0".
    INFO: Resolving reference for ProcessorArchitecture msil.
        INFO: Resolving reference for culture en-US.
            INFO: Applying Binding Policy.
                INFO: No binding policy redirect found.
            INFO: Begin assembly probing.
                INFO: Did not find the assembly in WinSxS.
                INFO: Did not find manifest for culture en-US.
            INFO: End assembly probing.
        INFO: Resolving reference for culture en.
            INFO: Applying Binding Policy.
                INFO: No binding policy redirect found.
        INFO: Begin assembly probing.
            INFO: Did not find the assembly in WinSxS.
            INFO: Did not find manifest for culture en.
        INFO: End assembly probing.
INFO: Parsing Manifest File G:\Debug\NetSide.sxs.MANIFEST.
    INFO: Manifest Definition Identity is NetSide.sxs,processorArchitecture="msil",type="win32",version="1.0.0.0".
        INFO: Reference: mscorlib,publicKeyToken="b77a5c561934e089",version="4.0.0.0"
        INFO: Resolving reference mscorlib,publicKeyToken="b77a5c561934e089",version="4.0.0.0".
        INFO: Resolving reference for ProcessorArchitecture mscorlib,publicKeyToken="b77a5c561934e089",version="4.0.0.0".
        INFO: Resolving reference for culture Neutral.
            INFO: Applying Binding Policy.
                INFO: No publisher policy found.
                INFO: No binding policy redirect found.
            INFO: Begin assembly probing.
                INFO: Did not find the assembly in WinSxS.
                INFO: Attempt to probe manifest at C:\Windows\assembly\GAC\mscorlib\4.0.0.0__b77a5c561934e089\mscorlib.DLL.
                INFO: Attempt to probe manifest at G:\Debug\mscorlib.DLL.
                INFO: Attempt to probe manifest at G:\Debug\mscorlib.MANIFEST.
                INFO: Attempt to probe manifest at G:\Debug\mscorlib\mscorlib.DLL.
                INFO: Attempt to probe manifest at G:\Debug\mscorlib\mscorlib.MANIFEST.
                INFO: Did not find manifest for culture Neutral.
            INFO: End assembly probing.
    ERROR: Cannot resolve reference mscorlib,publicKeyToken="b77a5c561934e089",version="4.0.0.0".
ERROR: Activation Context generation failed.
End Activation Context Generation.

最佳答案

从netside.sxs中删除对mscorlib的依赖,然后

<!-- We depend on the assembly NetSide.sxs -->
<dependency>
    <dependentAssembly>
        <assemblyIdentity type="win32"
            name="NetSide.sxs"
            version="1.0.0.0"
            language="*"/>
    </dependentAssembly>
</dependency>


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<asmv1:assembly manifestVersion="1.0" 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">
  <assemblyIdentity type="win32" name="NetSide.sxs" version="1.0.0.0" />

  <clrClass clsid="{E6C4A866-F58C-415E-9745-E0E7812B4386}" progid="NetSide.Class1" threadingModel="Both" name="NetSide.Class1">
  </clrClass>

  <file name="NetSide.dll">
  </file>
</asmv1:assembly>

07-25 23:45