c# - SideBySide Registration-Free COM 在加载时失败

标签 c# .net delphi com

我正在尝试创建一个 C# COM 服务器,它由没有 COM 注册的 Delphi 应用程序使用。

该过程在 ms blog - Registration-Free Activation of .NET-Based Components: A Walkthrough 上进行了描述

我创建了必要的 list 文件并将它们链接到程序集。

应用 list :

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

和程序集 list :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity type="win32" name="Vorg.WpfClient" version="1.0.0.0" />
    <clrClass
        clsid="{69A72676-8EA7-3C38-BFBC-F0DFE745C329}"
        progid="Vorg.WpfClient"
        threadingModel="Both"
        name="KundM.Vorg.WpfClient.VorgComClient">
    </clrClass>
</assembly>

那些工作正常(我认为)。 sxs 不报告任何错误。 clsid 对于 com 类也是正确的。 但是当启动应用程序时,它因 ole 异常 0x8013101b 而崩溃。

删除 list 并在类未找到异常中运行诅咒的应用程序结果。 注册 com 类后,应用程序正常启动,没有任何错误。

异常可能会说“错误的框架版本”。

我试图在类 list 中指定运行时。但这并没有解决问题。

是什么导致了异常?

我该如何解决这个问题?

最佳答案

已解决。

程序Fuslogvw.exe给了我正确的方向。 此工具显示程序集的加载过程。

要启用它,您需要创建一个注册 key 。

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion 双字 ForceLog=1

报告是在那里生成的,向我展示了这个(抱歉德国框架):

LOG: DisplayName = vorg.wpfclient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
===
LOG: Diese Bindung startet im default-Load-Kontext.
LOG: Der Assembly-Download wurde durchgeführt. Datei-Setup wird begonnen: E:\work\VOrg\bin\vorg.wpfclient.dll.
LOG: Die von der Quelle ausgeführte Setup-Phase beginnt.
LOG: Der Assemblyname ist: Vorg.WpfClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=174d633867192b66.
WRN: Der Vergleich des Assemblynamens führte zum Konflikt: PUBLIC KEY TOKEN.
ERR: Der Assemblyverweis entsprach nicht der gefundenen Assemblydefinition.
ERR: Das Setup der Assembly konnte nicht abgeschlossen werden (hr = 0x80131040). Die Suche wurde beendet.

我没有在 list 中指定公钥 token 。现在我知道了! 来自微软的 list 的模式文件是错误的!它显示版本和一些其他属性是可选的。

我还在 com list 中指定了运行时。 也可以通过 app.config 文件指定框架版本。

关于c# - SideBySide Registration-Free COM 在加载时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10501422/

相关文章:

c# - 如何添加对程序集的引用?

c# - Automapper 多对多 stackoverflowexception

C#:ToArray 性能

c# - 如何从工作流对话框中删除标题中的问号?

c# - Linq GroupBy 转换为条件?

c# - 如何使用 viewmodelocator 在 View 模型之间发送参数

c# - 这是一个大的表达式树吗? #4

delphi - 嵌入式 Firebird/Delphi 会导致防火墙 'hit' 吗?

delphi - 使用 PutBlock 并将字节数组全部设置为零的 EIPHTTPProtocolExceptionPeer 异常

azure - Delphi Web 应用程序为 Azure 提供可能性