开发者

Custom actions in a .NET Service Installer

I am writing a Windows Service in C# in Visual Studio 2010.

My service will require a registry key HKLM\system\currentcontrolset\services\myservicename\parameters. It will also require a custom event source. I can't create either of these from within the service because both of these actions require running elevated on Win7, and I don't want my service to run elevated.

The event source seems to be created automagically (I wish I knew how/where and could find this documentation) by the installer.

What is the correct place for me to create开发者_如何学Python and populate the Parameters registry key? Would it be the AfterInstall() event of the installer? I'd like to be able to roll back the installation if my actions fail and I'm not sure I can do that in AfterInstall().


AfterInstall is a good place; it happens after all Install methods, but before the Commit or Rollback logic, so if the install fails you can check to see if you created the key and remove it.

Remember to place similar logic to remove the key in the AfterUninstall event handler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜