用于COM Interop的WiX寄存器组件 [英] WiX register assemblies for COM Interop

查看:300
本文介绍了用于COM Interop的WiX寄存器组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很努力与WiX。我有要安装的.NET程序集,需要注册COM Interop,并且它们必须注册到另一个需要在GAC中的.NET程序集中调用Register()方法的框架。这种注册方法是一个带有隐藏存储机制的黑盒子,所以我不能以声明方式执行这个操作。

I'm really struggling with WiX. I have .NET assemblies to install that require registration for COM Interop, AND they must be registered with another framework that requires calling a Register() method in a .NET assembly that's in the GAC. This registration method is a 'black box' with a hidden storage mechanism so I can't perform this operation declaratively.

我认为声明方法最适合COM注册,但我使用heat.exe有两个问题:

I get that the declaritive approach is best for COM registration, but I have two problems with using heat.exe:


  1. RegAsm工作,但Heat.exe阻塞在我的程序集与消息:

  1. RegAsm works, but Heat.exe chokes on my assembly with the message:


heat.exe:警告HEAT5151:可能
不能从
文件中获取数据是一个程序集:
C:[...]。
如果此文件不是程序集,则
可以忽略此警告。否则,
这个错误的详细信息可能对
有帮助诊断失败:异常有

调用的回调抛出。

heat.exe : warning HEAT5151 : Could not harvest data from a file that was expected to be an assembly: C:[...].dll. If this file is not an assembly you can ignore this warning. Otherwise, this error detail may be helpful to diagnose the failure: Exception has been thrown by the t arget of an invocation.


  • 我需要做的辅助注册依赖于[ComRegisterFunction]属性,通常会在组件注册COM Interop时触发进一步的操作。这通常发生在通过RegAsm.exe或通过调用System.Runtime.InteropServices.RegistrationServices注册程序集时。所以,我需要ComRegisterFunction在我的程序集中执行安装期间。

  • The secondary registration that I need to do relies on the [ComRegisterFunction] attribute, which normally triggers further actions at the time the assembly is registered for COM Interop. This normally happens when the assembly is registered by RegAsm.exe or by calling System.Runtime.InteropServices.RegistrationServices. So, I need that ComRegisterFunction in my assembly to execute during the installation.

    我不介意用COM注册的声明式方法(或者我不介意如果热工作我的程序集),但我需要调用ComRegisterFunction作为安装的一部分。理想情况下,我想看看我安装的所有可执行文件,反映他们的任何方法与[ComRegisterFunction]属性,并调用这些方法,这将完成所有文件安装后。

    I don't mind taking the declarative approach to COM registration (or I wouldn't mind if heat worked on my assembly) but I need to call that ComRegisterFunction as part of the install. Ideally, I'd like to look at all of the executables I'm installing, reflect on them for any methods with the [ComRegisterFunction] attribute and call those methods, this would be done after all files are installed.

    如何在WiX中实现?还是有另一种方法吗?如果它有什么区别,我使用VotiveVisual Studio与项目引用的集成。

    How can I achieve this in WiX? Or, is there another approach? If it makes any difference, I am using the 'Votive' Visual Studio integration with project references.

    推荐答案

    使用声明方法的观点是不是使用Regasm.exe或Regsvr32.exe来调用注册函数。换句话说,你的[ComRegisterFunction]属性方法不会被调用。

    These are opposing goals. The point of using the declarative approach is to not use Regasm.exe or Regsvr32.exe to call the registration function. In other words, your [ComRegisterFunction] attributed method won't be called. You can't have both.

    heat.exe死机的例外并不健康,它表示您的注册功能或类别结构有问题。通过使DLL成为启动项目来调试。 Project + Properties,Debug选项卡,并使heat.exe成为启动程序。将命令行设置为您的DLL。 Debug +异常并勾选Thrwn框用于CLR异常,调试器将在抛出异常时停止。

    The exception that heat.exe dies on isn't healthy, it indicates that there's something wrong with your registration function or class contructor. Debug this by making your DLL the startup project. Project + Properties, Debug tab and make heat.exe the startup program. Set the command line to your DLL. Debug + Exceptions and tick the Thrown box for CLR exceptions, the debugger will stop when the exception is thrown.

    哦,不要忘记调用RegistrationServices.RegisterAssembly您的注册功能。 Regasm.exe不会自动做,因为你使用的属性。

    Oh, and don't forget to call RegistrationServices.RegisterAssembly in your register function. Regasm.exe won't do it automatically anymore since you used the attribute.

    这篇关于用于COM Interop的WiX寄存器组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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