Hi,
I'm developing a Windows Service in VB.Net and set the
Account property of the
ServiceProcessInstaller as "User", which is my security requirement. So whenever I tried to install the service using INSTALLUTIL.exe, it is prompting to enter user id and password information. To avoid that I have written below code:
| PublicOverridesSubInstall(ByValstateSaverAsSystem.Collections.IDictionary) |
| Try |
| Upload_ServiceProcessInstaller.Username="Srikanth" |
| Upload_ServiceProcessInstaller.Password="C))lB0y" |
| MyBase.Install(stateSaver) |
| CatchArgExAsArgumentException |
| LogError_ErrorLog("ArgumentExceptioninInstall()methodofProjectInstaller.vb"&ArgEx.Message.ToString()&vbCrLf&ArgEx.InnerException.ToString()) |
| CatchexAsException |
| LogError_ErrorLog("ErrorinInstall()methodofProjectInstaller.vb"&ex.Message.ToString()&vbCrLf&ex.InnerException.ToString()) |
| EndTry |
| EndSub |
|
This is working fine. But now my requirement is to get the user name and password from the config file. So I have updated the above code like shown below:
| ImportsSystem.Configuration |
| PublicOverridesSubInstall(ByValstateSaverAsSystem.Collections.IDictionary) |
| Try |
| Upload_ServiceProcessInstaller.Username=System.Configuration.ConfigurationManager.AppSettings("ServiceUser").ToString() |
| Upload_ServiceProcessInstaller.Password=System.Configuration.ConfigurationManager.AppSettings("ServiceUserPassword").ToString() |
| MyBase.Install(stateSaver) |
| CatchArgExAsArgumentException |
| LogError_ErrorLog("ArgumentExceptioninInstall()methodofProjectInstaller.vb"&ArgEx.Message.ToString()&vbCrLf&ArgEx.InnerException.ToString()) |
| CatchexAsException |
| LogError_ErrorLog("ErrorinInstall()methodofProjectInstaller.vb"&ex.Message.ToString()&vbCrLf&ex.InnerException.ToString()) |
| EndTry |
| |
| EndSub |
|
Compiled the code and tried to install the service using INSTALLUTIL but getting below errors:
| 1 |
Microsoft(R).NETFrameworkInstallationutilityVersion2.0.50727.1433 |
| 2 |
Copyright(c)MicrosoftCorporation.Allrightsreserved. |
| 3 |
|
| 4 |
|
| 5 |
Runningatransactedinstallation. |
| 6 |
|
| 7 |
BeginningtheInstallphaseoftheinstallation. |
| 8 |
SeethecontentsofthelogfilefortheC:\ProgramFiles\TFSUpload\TFSUpload.exeassembly'sprogress. |
| 9 |
ThefileislocatedatC:\ProgramFiles\TFSUpload\TFSUpload.InstallLog. |
| 10 |
Installingassembly'C:\ProgramFiles\TFSUpload\TFSUpload.exe'. |
| 11 |
Affectedparametersare: |
| 12 |
logtoconsole= |
| 13 |
assemblypath=C:\ProgramFiles\TFSUpload\TFSUpload.exe |
| 14 |
logfile=C:\ProgramFiles\TFSUpload\TFSUpload.InstallLog |
| 15 |
|
| 16 |
AnexceptionoccurredduringtheInstallphase. |
| 17 |
System.NullReferenceException:Objectreferencenotsettoaninstanceofanobject. |
| 18 |
|
| 19 |
TheRollbackphaseoftheinstallationisbeginning. |
| 20 |
SeethecontentsofthelogfilefortheC:\ProgramFiles\TFSUpload\TFSUpload.exeassembly'sprogress. |
| 21 |
ThefileislocatedatC:\ProgramFiles\TFSUpload\TFSUpload.InstallLog. |
| 22 |
Rollingbackassembly'C:\ProgramFiles\TFSUpload\TFSUpload.exe'. |
| 23 |
Affectedparametersare: |
| 24 |
logtoconsole= |
| 25 |
assemblypath=C:\ProgramFiles\TFSUpload\TFSUpload.exe |
| 26 |
logfile=C:\ProgramFiles\TFSUpload\TFSUpload.InstallLog |
| 27 |
AnexceptionoccurredduringtheRollbackphaseoftheTFSUpload.ProjectInstallerinstaller. |
| 28 |
System.ArgumentException:ThesavedStatedictionarydoesnotcontaintheexpectedvaluesandmighthavebeencorrupted. |
| 29 |
AnexceptionoccurredduringtheRollbackphaseoftheinstallation.Thisexcept |
| 30 |
ionwillbeignoredandtherollbackwillcontinue.However,themachinemightnotfullyreverttoitsinitialstateaftertherollbackiscomplete. |
| 31 |
|
| 32 |
TheRollbackphasecompletedsuccessfully. |
| 33 |
|
| 34 |
Thetransactedinstallhascompleted. |
| 35 |
Theinstallationfailed,andtherollbackhasbeenperformed. |
| 36 |
Theservicenameisinvalid. |
| 37 |
|
| 38 |
MorehelpisavailablebytypingNETHELPMSG2185. |
Read the line numbers 16, 17, 27 & 28 for the error details. And also I'm not getting any error information in the log files (the code is there in the catch block).
Could some one assist me to resolve this issue.
Thanks,
Srikanth