使用 wix 注册标记为 COM 互操作的 .Net 程序集

发布于 2024-09-18 22:03:21 字数 973 浏览 1 评论 0原文

我有一个普通的 .net 类库,其中包含一些 [ComVisible] 类型,并且程序集本身标记为“注册 COM 互操作”。我正在尝试为应用程序构建一个 WIX 安装程序,它不仅需要将 .net 程序集复制到目标计算机上的 INSTALLATIONDIR,而且还需要注册该对象,以便一些旧版 VB6 应用程序可以使用.net 程序集的。

我一直在使用 heat.exe(更准确地说是 heat 文件任务)来获取一个片段,该片段是通过我的主 wix 文件中的 componentGroupRef 包含的。我的问题是 heat.exe 正在收集的文件应该是我的类库输出的 .tlb 文件还是 dll 本身?如果我在 .tlb 上使用 heat.exe,我不会在片段中得到任何注册表元素,但会在 dll 中得到任何注册表元素。如果我应该使用 dll,.tlb 在此过程中扮演什么角色?

我在 msbuild 中使用下面的 heat 任务

<HeatFile
  NoLogo="true"
  ToolPath="$(WixToolPath)"
  TreatWarningsAsErrors="false"
  AutogenerateGuids="true"
  GenerateGuidsNow="true"
  OutputFile="$(MSBuildProjectDirectory)\fragments\DemoTypeLib.wxs"
  File="$(SolutionDir)DemoClassLibrary1\bin\Debug\DemoClassLibrary1.dll"
  ComponentGroupName="DemoTypeLibComponent"
    PreprocessorVariable="var.DemoClassLibrary1.TargetDir"
  SuppressCom="false"
    DirectoryRefId="INSTALLLOCATION"
  SuppressRegistry="false"
  SuppressRootDirectory="true" />

I've got a vanilla .net class library which contains some types which are [ComVisible] and the assembly itself is marked "Register for COM Interop". I'm trying to build a WIX installer for the app which will need to not only copy the .net assembly to the INSTALLATIONDIR on the target machine, but also do the work of registering that the object so that some legacy VB6 applications can make use of the .net assembly.

I've been using heat.exe (the heat file task more precisely) to harvest a fragment which I've included via a componentGroupRef in my main wix file. My question is should the file that heat.exe is harvesting be the .tlb file output by my class library or the dll itself? If I use heat.exe on the .tlb I dont get any registry elements in the fragment but I do with the dll. If I ought to be using the dll what role does the .tlb play in this process?

Im using the below heat task in msbuild

<HeatFile
  NoLogo="true"
  ToolPath="$(WixToolPath)"
  TreatWarningsAsErrors="false"
  AutogenerateGuids="true"
  GenerateGuidsNow="true"
  OutputFile="$(MSBuildProjectDirectory)\fragments\DemoTypeLib.wxs"
  File="$(SolutionDir)DemoClassLibrary1\bin\Debug\DemoClassLibrary1.dll"
  ComponentGroupName="DemoTypeLibComponent"
    PreprocessorVariable="var.DemoClassLibrary1.TargetDir"
  SuppressCom="false"
    DirectoryRefId="INSTALLLOCATION"
  SuppressRegistry="false"
  SuppressRootDirectory="true" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无悔心 2024-09-25 22:03:21

您应该收获 .tlb 和 .dll 文件。有些工具只能使用 DLL 注册,但其他工具(如脚本语言)也需要类型库。只需加热它们,并将两个输出都包含在您的最终项目中即可。例如,python 的 win32com 和 Perl 的 Win32::OLE 库都需要注册类型库才能运行。

You should harvest both the .tlb and the .dll file. Some tools can use only the DLL registration, but others, like scripting languages, need the type library as well. Simply heat both of them, and include both outputs in your final project. For example, python's win32com and Perl's Win32::OLE libraries both need the type library registered to function.

美男兮 2024-09-25 22:03:21

只需将 Fragment 与 DLL 和 COM 一起发送即可。您不需要 TLB。

Just ship the Fragment with the DLL and the COM for it. You don't need the TLB.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文