尝试从本机应用程序并行访问 .NET 程序集时出现 OLE 错误 80131522
我有一个应用程序(Delphi 本机代码)需要访问 .NET 程序集(公开一些 COM 类)。我想使用并排程序集和清单来执行此操作。我已经使用测试 .NET 程序集完成了此操作,但是我我需要访问的程序集有问题。
注册程序集后,我可以实例化 COM 类,然后尝试并行访问,我的本机应用程序出现上述错误。 我的程序
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32"
name="TestApplication.exe"
version="1.0.0.0"/>
<dependency>
<dependentAssembly>
<assemblyIdentity
name="TestAssembly"
version="1.0.0.0"
processorArchitecture="x86"
publicKeyToken="xxxxxxxxxxxxxxxx"
type="win32"/>
</dependentAssembly>
</dependency>
</assembly>
集清单(我已将其作为资源嵌入到我的 .net 程序集中)如下:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
name="TestAssembly"
version="1.0.0.0"
processorArchitecture="x86"
publicKeyToken="xxxxxxxxxxxxxxxx"
type="win32"/>
<clrClass
clsid="{F3F1623D-DB4A-4152-9A5D-5A465AD3A318}"
progid="TestAssembly.MyObject"
threadingModel="Both"
name="TestAssembly.MyObject"
runtimeVersion="v2.0.50727">
</clrClass>
<file name="TestAssembly.dll">
</file>
</assembly>
如果我更改应用程序清单的依赖项名称、版本,则清单似乎设置正确。或公钥令牌(顺便说一句,示例中的令牌不是我代码中的令牌),我收到有关应用程序配置不正确的常见 SxS 错误,
我在另一个(诚然更简单).NET 程序集上进行了此操作,但是。无法弄清楚出了什么问题。问题是我不确定该错误意味着什么。
I have an application (Delphi Native code) that needs to access a .NET assembly (exposes a few COM classes. I want to do this using side by side assemblies and manifests. I have done this with a test .NET assembly, but am having a problem with the assembly I need to access.
When the assembly is registered, I can instantiate the COM class. As soon as I unregister the assembly, and try to access side by side I get the above error. My native application has an application manifest, which has a simple dependency to the assembly.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32"
name="TestApplication.exe"
version="1.0.0.0"/>
<dependency>
<dependentAssembly>
<assemblyIdentity
name="TestAssembly"
version="1.0.0.0"
processorArchitecture="x86"
publicKeyToken="xxxxxxxxxxxxxxxx"
type="win32"/>
</dependentAssembly>
</dependency>
</assembly>
My Assembly manifest, which I have embedded as a resource into my .net assembly is the following :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
name="TestAssembly"
version="1.0.0.0"
processorArchitecture="x86"
publicKeyToken="xxxxxxxxxxxxxxxx"
type="win32"/>
<clrClass
clsid="{F3F1623D-DB4A-4152-9A5D-5A465AD3A318}"
progid="TestAssembly.MyObject"
threadingModel="Both"
name="TestAssembly.MyObject"
runtimeVersion="v2.0.50727">
</clrClass>
<file name="TestAssembly.dll">
</file>
</assembly>
The manifests seems to be setup correctly. If I change the application manifest's dependency name, version or public key token (the one in the example is not the one i have in my code btw), I get the usual SxS error about the application configuration is incorrect.
I have this working on another (admittedly simpler) .NET assembly, but cannot figure out what is wrong. Problem is I'm not sure what the error means.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要生成 .Net 程序集清单,请像这样使用
mt.exe
然后打开 temp_file.manifest 并在您的
dependency\dependentAssembly
标记下逐字复制assemblyIdentity 标记delphi 可执行文件清单。
仅供参考:您必须将可执行文件和所有依赖的 .net dll 保存在同一文件夹中。
To generate .Net assembly manifest use
mt.exe
like thisThen open temp_file.manifest and copy
assemblyIdentity
tag verbatim underdependency\dependentAssembly
tag of your delphi executable manifest.FYI: You have to keep both the executable and all dependent .net dlls in the same folder.