all groups > visual studio .net enterprise tools > october 2003 >
You're in the

visual studio .net enterprise tools

group:

System.Configuration.Install.Installer class issue


System.Configuration.Install.Installer class issue Erick
10/26/2003 10:39:00 AM
visual studio .net enterprise tools:
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_DisplayName",
typeof(string))));
this.m_MonitorInstaller.ServiceName =
((string)(configurationAppSettings.GetValue("Key_ServiceName",
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...

Re: System.Configuration.Install.Installer class issue John Saunders
10/26/2003 5:58:00 PM
[quoted text, click to view]

Erick, I hit the same problem and found a nasty workaround for it. I hope
Microsoft can tell us a better way to do it.

The problem is that the config file is for your application, not for
InstallUtil. InstallUtil and the installers it instantiates and runs will
never see your config file.

I don't know how I got this idea, but I realized that InstallUtil is glad to
read InstallUtil's config file. So you can copy InstallUtil.exe into your
binaries directory, copy your config file with the name
InstallUtil.exe.config, and then run ".\InstallUtil.exe yourAssembly".
InstallUtil and the objects it instantiates (which include your installer)
will then read from InstallUtil's config file.
--
John Saunders
Internet Engineer
john.saunders@surfcontrol.com

Re: System.Configuration.Install.Installer class issue Erick
10/26/2003 7:09:46 PM
Hi, John

Thanks a lot for your comments and suggestions, I will try this workaround.

As a comment I was thinking in write some code into the same class service
so the service can self-register base on a paramenter /install or /unistall
by this it will use the app.config because is in the same domain. I have not
tryed yet but
I will post the results.

Cheers...


[quoted text, click to view]

AddThis Social Bookmark Button