我可以使用清单来指定 COM 服务器上的可选依赖项吗?
我想使用清单来指定对 COM 服务器的依赖关系 (reg-免费 COM)。
消费者应用程序在没有 COM 服务器的情况下大部分都可以正常工作 - 只有大约 1.7% 的功能使用 COM 服务器。因此,使用普通的旧 regsvr32
它将启动并正常工作,直到用户执行一些会触发 CoCreateInstance()
调用的操作,此时消费者将收到错误消息。
现在,我已经使用清单了一段时间,看起来消费者甚至不会启动,除非它所依赖的 COM 服务器程序集存在于文件系统中。那可不好。
我添加了包含以下内容的“附加清单”:
<?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="TheComServer.X"
version="1.0.0.0"/>
</dependentAssembly>
</dependency>
</assembly>
有没有办法将免注册 COM 与清单一起使用并使依赖项可选 - 以便消费者程序启动并正常工作,直到 CoCreateInstance()
实际上被称为?
I'd like to use manifests to specify a dependency on a COM server (reg-free COM).
The consumer application will mostly work fine without the COM server - only something like 1,7% of its functionality uses the COM server. So with plain old regsvr32
it would start and work fine until the user would do something that would trigger CoCreateInstance()
call and at that point the consumer would get an error message.
Now I've played with manifests for a while and it looks like the consumer wouldn't even start unless the COM server assembly it depends on is present in the file system. That's no good.
I added the "addiditional manifest" with the following content:
<?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="TheComServer.X"
version="1.0.0.0"/>
</dependentAssembly>
</dependency>
</assembly>
Is there a way to use reg-free COM with manifests and make the dependency optional - so that the consumer program starts and works fine until CoCreateInstance()
is actually called?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须至少提供免注册 COM 程序集的清单。
应用程序清单引用应用程序所需的程序集(组件清单在应用程序启动时进行处理)并指定程序集导出的 com 对象。
它们必须在加载激活上下文时指定。
您可以使用激活上下文 API 手动创建激活上下文并将程序集加载到其中,然后确保在尝试 CoCreateInstance 时该上下文是最新的。
You are going to have to provide at least the manifest for the reg-free COM assemblies.
The application manifest references the assemblies the application wants - the component manifests are processed at application startup - and specify the com objects the assembly exports.
They have to be specified as the activation context is loaded.
You can use the activation context API to manually create an activation context and load assemblies into it - and then ensure that that context is current when you try to CoCreateInstance.