Hi,
I have a Installer class used to install my windows service, it was created
by the
wizard that is in the VS, I just whent into the properties and set up the
properties of the ServiceInstaller member by using the properties windows.
But I choose the DinamicProperties, the wizard created into the
"InitializeComponents" two assignations of the ServiceInstaller properties
by instanciating the System.Configuration.AppSettingsReader this properties
are in the app.config file.
ie.
private void InitializeComponent()
{
System.Configuration.AppSettingsReader configurationAppSettings = new
System.Configuration.AppSettingsReader();
this.m_MonitorProcInstaller = new
System.ServiceProcess.ServiceProcessInstaller();
this.m_MonitorInstaller = new System.ServiceProcess.ServiceInstaller();
//
// m_MonitorProcInstaller
//
this.m_MonitorInstaller.StartType = ServiceStartMode.Manual;
this.m_MonitorProcInstaller.Account = ServiceAccount.LocalSystem;
//
// m_MonitorInstaller
//
this.m_MonitorInstaller.DisplayName =
((string)(configurationAppSettings.GetValue("key_D isplayName",
typeof(string))));
this.m_MonitorInstaller.ServiceName =
((string)(configurationAppSettings.GetValue("Key_S erviceName",
typeof(string))));
}
But at the time run the installutil in order to install the service I got
some errors:
An exception occurred during the Install phase.
System.InvalidOperationException: Unable to create an instance of the
MonitorService.Installer.MonitorInstaller installer type.
The inner exception System.Reflection.TargetInvocationException was thrown
with
the following error message: Exception has been thrown by the target of an
invoc
ation..
The inner exception System.InvalidOperationException was thrown with the
followi
ng error message: The key 'key_DisplayName' does not exist in the
appSettings co
nfiguration section..
I when into the .config file after I compiled the solution and the key is
there.
Could any of you advice why I cannot read the .config file.
Cheers...