Hi ,
I have created a Windows Service using Visual Studio .NET 2005. In the serviceInstaller1_AfterInstall method I have written some code for inserting some data in the database.
But when I am installing the service its throwing exception and my windows service is not installing .
Can any one please advice and help that is it possible to write any kind of code in the method serviceInstaller1_AfterInstall OR there are any limitations ?
Thanks and Regards
Prasad . G . Godbole
Prasad GodbolePosted Apr 20, 2009, 2:45 AM
Hi,
Actually I am calling static methods from userdefined class and accessing key value of connecting string from app.config file. And its throwing exception "Object reference not set" while installing the service. If I define the method in the ProjectInstaller class and then call them in the metod serviceInstaller1_AfterInstall , it works fine. Also If I hardcode the connection string in the ProjectInstaller class , it works fine. Not sure what I am doing wrong but its indicating that if I try to access anything outside of class ProjectInstaller, its throwing exception while installation. I will follow the steps given by you and will let you know the result. Thanks...
Many Thanks
Prasad . G . Godbole
Mahesh ChandPosted Apr 11, 2009, 10:57 AM
Do u know what error you are getting? Before I register as a service, I would run it as an exe and make sure exe is working fine. After that, you may want to try debug your Windows service. Here is a step by step tutorial on how to debug a Windows Service.
http://support.microsoft.com/kb/824344