使用WiX安装程序复制Visual Studio COM注册 [英] Replicating Visual Studio COM registration with a WiX Installer

查看:207
本文介绍了使用WiX安装程序复制Visual Studio COM注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间,一个年轻,天真的工程师认为,将他的应用程序的一些功能分离成用C#编写的COM组件是一个好主意。 Visual Studio有所有的工具,这样做,对吧? .NET实际上是为此做的,对吧?哈!他说,这很容易。我会有正确的组件分离,保持业务逻辑远离前端,并与COM,我将能够使用它从任何地方!他愉快地检查了项目属性中的注册中的COM interop 复选框,公开了他想要的类,然后继续。

Once upon a time, a young, naive engineer thought it would be a good idea to separate out some of the functionality for his app into a COM component, written in C#. Visual studio had all the tools to do that, right? .NET was practically made for this, right? HA! He said, this will be easy. I'll have decent separation of components, keeping business logic away from the front end, and with COM, I'll be able to use it from anywhere! He merrily checked the register for COM interop checkbox in the project properties, exposed the classses he wanted, and went on his way.

哦,试试这样的选择。现在,年轻的工程师,更有经验,现在不希望这对任何人。但是,他的肩膀上有负担,负担仍然沉重。他希望减轻负载。

Oh, the trials such a choice made. The young engineer now, more experienced, would not now wish this upon anyone. However, the burden had been placed upon his shoulders, and the burden remained heavy. He looked to lighten the load.

WiX是一种用于从XML生成Windows Installer文件的工具。这引起了他的兴趣 - 它可以复制,很简单地,大多数代码需要一个正确的Windows安装程序文件,只是从一些配置文件。他的目光向上看。

Along came WiX, a tool for generating Windows Installer files from XML. This intrigued him - it could replicate, quite simply, most of the code needed for a proper windows installer file simply from a handful of configuration files. His sights were looking up.

使用WiX 2.0,他可以很容易地生成注册一个C#COM对象所需的文件。这涉及使用工具牛油。他会做如下:

With WiX 2.0, he could generate quite easily the files needed to register a C# COM object. This involved using the tool tallow. He'd do something like the following:

tallow -c -nologo MyComExposedLibrary.dll > MyComExposedLibrary.wxs

这将被修复(首先这是手动完成,步骤变成一个小工具,设置最终目录ref id,组件ID,fileID,GUID和codebase)。

which would then be fixed up (at first this was done manually, but eventually I recorded the steps into a small tool set the final directory ref id, component ID, fileID, GUID and codebase).

然后,随后的安装程序将安装,欢乐的庆祝活动,如果应用程序工作。

Then, the ensuing installer would install, and there would be joyous celebration, if the app worked.

这没有。

他的开发PC和测试安装PC的差异。 所有注册表项都是一样的!他会大叫。

For days the young engineer poured over the differences on his development PC and that of the test install PC. "All the registry keys are the same!" He would exclaim. "Everything for MyComExposedLibrary is registerd, I swear!"

除了,它不是。

在MyComExposedLibrary的所有内容都已注册,我发布!第三天的黎明,在许多山露水后,他意识到有一个更多的对象,Visual Studio注册,他的安装程序不是:MyComExposedLibrary.tlb文件。

On the dawn of third day, after many a mountain dew, he realized there was one more object that Visual Studio was registering that his installer was not: the MyComExposedLibrary.tlb file.

Visual Studio显然一直在注册此文件,在 HKLM \Software \Classes \Interface 注册表项中创建其他子项,并将typelib注册到 HKLM\SOFTWARE\Classes\TypeLib

Visual Studio, apparently, had been registering this file all along, creating additional subkeys in the HKLM\Software\Classes\Interface registry key, and registering the typelib in HKLM\SOFTWARE\Classes\TypeLib.

Tallow没有帮助,抱怨.tlb wasn'一个文件它groked。也不是WiX 3.0 beta - 这似乎有更多的问题让事情工作。

Tallow gave no help, complaining that a .tlb wasn't a file it groked. Nor the WiX 3.0 beta - this seemed to have even more issues getting things working.

我也试过热。这生成了注册表元素和类元素。我清理了heat的输出,然后去编译它,但有一个不同的错误:错误LGHT0130:主键< uuid here>被复制在表'Registry'中。问题是,据我所知,uuid实际上不存在于我的任何wxs源文件。如果我在我的要素元素中改变组件的ref顺序,一个不同的dll组件给出该错误。由于我没有成功获得编译的项目的WiX 3.0版本,我无法确认热是否给出正确的输出。

I also gave Heat a try. This generated registry elements and class elements. I cleaned up heat's output, and then went to compile it, but got a different error: error LGHT0130 : The primary key <uuid here> is duplicated in table 'Registry'. Problem is, as far as I can tell, that uuid doesn't actually exist in any of my wxs source files. If I change around the component ref order in my feature element, a different dll component gives that error. Since I have been unsuccessful at getting a WiX 3.0 version of the project to compile, I haven't been able to confirm whether or not heat gives the right output.

我从安装程序中删除所有内容,除了导致此错误出现并尝试再次编译的程序集之一。我有同样的错误。 Arrugh!

I removed everything from the installer except for one of the assembly that cause this error to appear and tried compiling again. I got the same same error. Arrugh!

所以,我的好伙伴,Windows爱好者和WiX用户,有两个问题:

So, my good fellows, Windows enthusiasts, and WiX users, there falls two questions:


  • 一个typelib是什么,WiX可以本地注册?

另外,我想作为这个的另一部分,Visual Studio如何确定如何注册typelib? (编辑:查看 MSDN库中关于typelib注册的文章所需的键名称,但我仍然需要弄清楚如何获取uuid的。(这是从这篇博客文章在typelib和COM注册由Larry Osterman )))更多一点,可能会落在我手动注册这些位,但我希望不是...

Also, I guess as another part of this, how does Visual Studio determine how to register the typelib? ( looks the MSDN library article on typelib registration has the names of the keys needed, but I still need to figure out how to get the uuid's. (This is from this blog post on typelib and COM registration by Larry Osterman.) ) Reading a bit more, It may fall to me to register these bits manually, but I hope not...

我评估了 regasm /regfile:MyDll.dll MyDll.dll 的输出。看起来这些是wix为dll生成的相同的键。 Regasm的其他模式, regasm / tlb:< filename> 生成并注册了汇编的typelib,但

I evaluated the output from regasm /regfile:MyDll.dll MyDll.dll. It looks like these are the same keys that wix generates for the dll. Regasm's other mode, regasm /tlb:<filename> generates and registers the typelib for the assembly, but,

/ regfile [:FileName]生成一个具有指定名称
的reg文件,而不是注册类型。这个选项
不能用于/ u或/ tlb选项

/regfile[:FileName] Generate a reg file with the specified name instead of registering the types. This option cannot be used with the /u or /tlb options

似乎/ regfile开关与/ tlb开关。 Khaaaaaaaan!

seems the /regfile switch is incompatible with the /tlb switch. Khaaaaaaaan!

进一步更新:看起来您实际上并不需要包含.tlb档案。 根据这篇文章关于wix的typelib元素,则MSI可以创建/注册它作为设置过程的一部分。这一切都归结于配置WiX文档,通过获得正确的属性来实际安装它。

Further update: It looks like you don't actually need to include the .tlb file. According to this post on wix's typelib element, an MSI can create/register this as part of the setup process. It all comes down to configuring the WiX document to actually install it by getting the right attributes.

我发现后来你可以使用热获得正确的属性。 tlb直接!有关详情,请参见此SO问题

I found out later that you can get the right attributes using heat on the .tlb directly! See this SO question for more information.

推荐答案

您应该使用位于您正在使用的版本的bin目录中的Heat(WIX 3.0)。
请查看此博客的帖子,我们使用它来注册我们的所有COM对象,通过创建一个wix片段...

You should use Heat (WIX 3.0) located in the bin directory of the version you are using. Have a look at this blog post, we use it here to register all our COM objects, by creating a wix fragment...

/ p>

something like

heat file MyComExposedLibrary.dll -out MyComExposedLibrary.wxs

之后,阅读你的编辑,我会创建一个基本的msi与wix只安装com对象,看看是否有效...那么你会知道攻击哪个战场。 ..

After, reading your edit, I would create a basic msi with wix that installs the com object only, see if that works ... then you'll know which battlefield to attack ...

这篇关于使用WiX安装程序复制Visual Studio COM注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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