I have created a service and I need to take the name of the service from the assembly file during installation. I need to do this because the user will need to run multiple instances of this service. I plan to allow the user to rename the executable and install the renamed service.
The only way I have found so far to do this is to use the Installer Context which, according to MSDN "Gets or sets information about the current installation" including the command line parameters passed to InstallUtil. However, whenever I attempt to get the Context.Parameters I get the following runtime error (during installation):
"Object Reference not set to an instance of an object."
Here are the lines that fail:
InstallContext ic = this.Context;
StringDictionary sd = ic.Parameters;
Only the second line fails. "ic" gets created with no errors.
Does anyone know how to get Context Parameters to work on an installer object? or how to get the "assemblypath" which is the parameter I believe I need. Or anyother way to get the file name of the installed file using the Installation technique implemented in C#?
Thanks for the help.
What you don't know can hurt you!