生成无注册COM的清单文件 [英] Generate manifest files for registration-free COM

查看:204
本文介绍了生成无注册COM的清单文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些应用程序(一些本机,一些.NET)使用清单文件,以便它们可以是部署完全隔离,而不需要任何全局COM注册。例如,在与myapp.exe位于同一文件夹中的myapp.exe.manifest文件中声明对dbgrid32.ocx com服务器的依赖性如下:

 <?xml version =1.0encoding =utf-8standalone =yes?> 
< assembly manifestVersion =1.0xmlns =urn:schemas-microsoft-com:asm.v1>
< assemblyIdentity type =win32name =myapp.exeversion =1.2.3.4/>
<依赖关系>
< dependentAssembly>
< assemblyIdentity type =win32name =dbgrid32.ocxversion =5.1.81.4/>
< / dependentAssembly>
< / dependency>
< / assembly>

将dbgrid32.ocx部署到同一个文件夹,以及它自己的dbgrid32.ocx.manifest文件:

 <?xml version =1.0encoding =utf-8standalone = ? 是 > 
< assembly manifestVersion =1.0xmlns =urn:schemas-microsoft-com:asm.v1>
< assemblyIdentity type =win32name =dbgrid32.ocxversion =5.1.81.4/>
< file name =dbgrid32.ocx>
< typelib
tlbid ={00028C01-0000-0000-0000-000000000046}
version =1.0
helpdir =/>
< comClass progid =MSDBGrid.DBGrid
clsid ={00028C00-0000-0000-0000-000000000046}
description =DBGrid Control/>
< / file>
< / assembly>

这一切都很好,但手动维护这些清单文件有点痛苦。有没有办法自动生成这些文件?理想情况下,我只想声明应用程序对COM服务器(本机和.NET)列表的依赖性,然后让其余部分自动生成。是否可能?

解决方案

看起来完美的解决方案还不存在。总结一些研究:



Make My Manifest 链接



此工具扫描VB6项目以查找COM依赖关系,但它还支持手动声明后期的COM依赖关系(即有趣的是,此工具将所有关于依赖关系的信息放在应用程序清单内。应用程序exe及其依赖关系被描述为由多个文件组成的单个程序集。我以前没有意识到这是可能的。



看起来是一个非常好的工具,但从0.6.6版起,它有以下限制:




  • 仅适用于VB6应用程序,从VB6项目文件启动
    。耻辱,因为
    a很多它真正没有什么可做的
    与VB6。

  • 向导样式应用程序,而不是
    适合集成在一个构建
    进程。如果您的
    依赖关系不会发生很大变化,这不是一个巨大的问题。

  • 没有源代码的免费软件,有可能依赖它,因为它可能随时变为放弃软件。 / li>


我没有测试是否支持.NET com库。



regsvr42 codeproject link



此命令行工具为本机COM库生成清单文件。它调用DllRegisterServer,然后在注册表中添加信息时自动注册。它也可以为应用程序生成客户端清单。



此实用程序不支持.NET COM库,因为这些不会公开DllRegisterServer例程。



该实用程序是用C ++编写的。源代码可用。



mt.exe



部分窗口SDK(可以从 MSDN下载),如果您安装了visual studio,那您已经有了。 在这里记录
您可以生成本地COM库的清单文件,如下所示:

  mt.exe -tlb:mycomlib。 ocx -dll:mycomlib.ocx -out:mycomlib.ocx.manifest 

您可以生成清单文件.NET COM库如下所示:

  mt.exe -managedassemblyname:netlib.dll -nodependency -out:netlib.dll .manifest 

但是,这个工具有一些问题:




  • 第一个代码片段不会生成
    progid属性,破坏客户端
    ,它使用带有progids的CreateObject。

  • 第二个片段将生成
    < runtime> < mvid> 元素

  • 不支持生成
    应用程序的客户端清单



也许未来的SDK版本会改进这个工具,我测试了一个在Windows SDK 6.0a(vista)中。


I have some applications (some native, some .NET) which use manifest files so that they can be deployed in complete isolation, without requiring any global COM registration. For example, the dependency on the dbgrid32.ocx com server is declared as follows in the myapp.exe.manifest file which sits in the same folder as myapp.exe:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
  <assemblyIdentity type="win32" name="myapp.exe" version="1.2.3.4" />
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="dbgrid32.ocx" version="5.1.81.4" />
    </dependentAssembly>
  </dependency>
</assembly>

The dbgrid32.ocx is deployed to the same folder, along with it's own dbgrid32.ocx.manifest file:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
  <assemblyIdentity type="win32" name="dbgrid32.ocx" version="5.1.81.4" />
  <file name="dbgrid32.ocx">
     <typelib
        tlbid="{00028C01-0000-0000-0000-000000000046}"
        version="1.0"
        helpdir=""/>
    <comClass progid="MSDBGrid.DBGrid"
       clsid="{00028C00-0000-0000-0000-000000000046}"
       description="DBGrid  Control" />
  </file>
</assembly>

This all works fine but maintaining these manifest files manually is a bit of a pain. Is there a way to generate these files automatically? Ideally I would just like to declare the application's dependency on a list of COM servers (both native and .NET) and then let the rest be generated automatically. Is it possible?

解决方案

It looks like the perfect solution does not yet exist. To summarize some research:

Make My Manifest (link)

This tool scans a VB6 project to look for COM dependencies, but it also supports manual declaration of late-bound COM dependencies (i.e. those used via CreateObject).

Interestingly enough, this tool puts all information about the dependencies inside the application manifest. The application exe and its dependencies are described as a single assembly consisting of multiple files. I hadn't realized before that this was possible.

Looks like a very good tool but as of version 0.6.6 it has the following limitations:

  • only for VB6 applications, starts from VB6 project file. Shame, because a lot of what it does really has nothing to do with VB6.
  • wizard style application, not suitable to integrate in a build process. This is not a huge problem if your dependencies don't change a lot.
  • freeware without source, risky to rely on it because it could become abandonware at any moment.

I did not test whether it supports .NET com libraries.

regsvr42 (codeproject link)

This command line tool generates manifest files for native COM libraries. It invokes DllRegisterServer and then spies on the self-registration as it adds information into the registry. It can also generate a client manifest for applications.

This utility does not support .NET COM libraries, since these don't expose a DllRegisterServer routine.

The utility is written in C++. The source code is available.

mt.exe

Part of the windows SDK (can be downloaded from MSDN), which you already have if you have visual studio installed. It is documented here. You can generate manifest files for native COM libraries with it like this:

mt.exe -tlb:mycomlib.ocx -dll:mycomlib.ocx -out:mycomlib.ocx.manifest

You can generate manifest files for .NET COM libraries with it like this:

mt.exe -managedassemblyname:netlib.dll -nodependency -out:netlib.dll.manifest

However, there are some problems with this tool:

  • The first snippet will not generate progid attributes, breaking clients which use CreateObject with progids.
  • The second snippet will generate <runtime> and <mvid> elements which need to be stripped out before the manifests actually work.
  • Generation of client manifests for applications is not supported.

Maybe future SDK releases will improve this tool, I tested the one in the Windows SDK 6.0a (vista).

这篇关于生成无注册COM的清单文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆