WMI 提供程序程序集中的 RunInstaller 属性

发布于 2024-07-05 20:54:03 字数 631 浏览 7 评论 0原文

我正在类库中创建一个解耦的 WMI 提供程序。 我读到的所有内容都指向包含以下内容:

[System.ComponentModel.RunInstaller(true)]
public class MyApplicationManagementInstaller : DefaultManagementInstaller { }

我认为此安装的目的是因为 Windows WMI 基础结构需要在使用之前了解我的 WMI 提供程序的结构。

我的问题是 - 这个“安装程序”何时运行? MSDN 说安装程序将在“程序集安装期间”被调用,但我不确定这意味着什么,或者它何时会在包含 WMI 提供程序的类库上下文中发生。

我的印象是,这是对包含 WMI 提供程序的程序集手动运行 InstallUtil.exe 的自动替代,但我对提供程序所做的更改不会被 Windows WMI 基础结构识别,除非我手动从命令提示符运行 InstallUtil。 我可以在开发过程中在自己的计算机上执行此操作,但如果使用提供程序的应用程序部署到其他计算机上 - 那么怎么办?

看来这个 RunInstaller / DefaultManagementInstaller 组合无法正常工作 - 对吗?

I am creating a decoupled WMI provider in a class library. Everything I have read points towards including something along these lines:

[System.ComponentModel.RunInstaller(true)]
public class MyApplicationManagementInstaller : DefaultManagementInstaller { }

I gather the purpose of this installation is because the Windows WMI infrastructure needs to be aware of the structure of my WMI provider before it is used.

My question is - when is this "installer" ran? MSDN says that the installer will be invoked "during installation of an assembly", but I am not sure what that means or when it would happen in the context of a class library containing a WMI provider.

I was under the impression that this was an automated replacement for manually running InstallUtil.exe against the assembly containing the WMI provider, but changes I make to the provider are not recognised by the Windows WMI infrastructure unless I manually run InstallUtil from the command prompt. I can do this on my own machine during development, but if an application using the provider is deployed to other machines - what then?

It seems that this RunInstaller / DefaultManagementInstaller combination is not working properly - correct?

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

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

发布评论

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

评论(3

月牙弯弯 2024-07-12 20:54:03

据我了解,DefaultManagementInstaller 由 installutil.exe 运行 - 如果您不包含它,则该类不会安装在 WMI 中。 也许可以创建一个运行它的“安装项目”或“安装程序项目”,但我不确定,因为我不使用 Visual Studio。

[编辑]

对于远程安装,一个选项可能是使用带有 /MOF 选项的 Installutil 为程序集生成 MOF,并使用 mofcomp 将其移动到 WMI。

As I understand, DefaultManagementInstaller is ran by installutil.exe - if you don't include it, the class is not installed in WMI. Maybe it is possible to create a 'setup project' or 'installer project' that runs it, but I'm not sure because I don't use Visual Studio.

[edit]

for remote instalation, an option could be to use Installutil with /MOF option to generate MOF for the assembly and use mofcomp to move it to WMI.

几味少女 2024-07-12 20:54:03

我使用类似这样的方法以编程方式调用 InstallUtil:

    public static void Run( Type type )
    {
        // Register WMI stuff
        var installArgs = new[]
                                   {
                                       string.Format( "//logfile={0}", @"c:\Temp\sample.InstallLog" ), "//LogToConsole=false", "//ShowCallStack",
                                       type.Assembly.Location,
                                   };

        ManagedInstallerClass.InstallHelper( installArgs );
    }

从 Main() 方法中调用此方法。

-戴夫

I use something like this to call InstallUtil programmatically:

    public static void Run( Type type )
    {
        // Register WMI stuff
        var installArgs = new[]
                                   {
                                       string.Format( "//logfile={0}", @"c:\Temp\sample.InstallLog" ), "//LogToConsole=false", "//ShowCallStack",
                                       type.Assembly.Location,
                                   };

        ManagedInstallerClass.InstallHelper( installArgs );
    }

Call this from your Main() method.

-dave

执笏见 2024-07-12 20:54:03

谢谢乌罗斯。 看起来 RunInstaller 和 DefaultManagementInstaller 所做的只是让您能够针对程序集成功运行 InstallUtil。 这很奇怪,因为我几乎可以肯定,在我编译并使用第一个 WMI 提供程序时我并不了解 InstallUtil。

我将考虑使用 MOF 文件,并且为了我自己的使用,我可以将 InstallUtil 命令行作为 VS 中的构建后事件运行。

Thanks Uros. It does look like all that RunInstaller and DefaultManagementInstaller do is enable you to run InstallUtil successfully against the assembly. This is strange because I'm almost certain that I didn't know about InstallUtil at the point where I'd compiled and played with my first WMI provider.

I will look in to using the MOF file and for my own use I can just run the InstallUtil command line as a post build event in VS.

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