Hello,
I've been following the previous thread "Windows Service Starts and
Immediately Stops" and I have a similar problem.
I've been trying to get started on a windows service and have followed the
following rather well known tutorial [1] (I also make some references to it
in this writeup):
Walkthrough: Creating a Windows Service Application in the Component
Designer
http://msdn2.microsoft.com/en-us/lib...8a(VS.80).aspx
Anyways, I've gone through all the steps to create the service and then run
it via the "Manage" services console. I then get this error when clicking
"start" on the service [this error and some ways to debug it is reported on
many search results of web search engines I have used to debug this, however
the results to me have not yet been helpful]:
"An unhandled exception ('System.Security.Exception') occurred in"
[myprogramname]
I have done the following steps:
1. Tried setting "Runtime Security Policy" to "Full Trust" on the Local
Intranet on both .NET framework 1.1 and 2.0 in "Administrative
Tools->Microsoft .NET framework 1.1 configuration" and "...2.0
configuration". [didn't work]
2. Tried surrounding the "MyNewService" constructor block in "service1.cs"
with try , catches to echo out some debugging output to the
console.writeline. Unfortunately, when I do so the service runs but reports
no output was generated by the service. [I can provide exact code if you'd
like]
3. Tried making the service "serviceProcessInstaller1" have the account
property be set to LocalSystem not LocalService... didn't work.
4. As #3, tried doing "user" but couldn't authenticate with just my username
and password [weird. I'm doing the development as the computer administrator
too... ?]
5. Tried setting permissions within the program level via:
"[System.Security.Permissions.PermissionSet(System.S ecurity.Permissions.SecurityAction.Demand,
Name = "FullTrust")] "
And still, no cigar. Also: I recently reformatted my computer and have
installed all security updates and visual studio updates that I could find.
I really want to thank who reads this, as this has been greatly frustrating
me.
[1] Though there is a newer version of the article which is for .NET 3.5,
viewing the about box in Visual Studio I find the program reports I am using
visual studio 2005 [v.8.0.507...] and .NET framework v. 2.0.507... SP1
(should anyone be interested).