Click here to Skip to main content
15,916,019 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

Here i developed one Windows Service and Web Application(asp.net) through web application i want to start the Windows Service.its Working fine in Development Server.When i run the Application through IIS to start the Windows Service its Showing this Error.


Error:
System.InvalidOperationException: Cannot open VMC_SMS_SERVICE service on computer '.'. ---> System.ComponentModel.Win32Exception: Access is denied --- End of inner exception stack trace --- at System.ServiceProcess.ServiceController.GetServiceHandle(Int32 desiredAccess) at System.ServiceProcess.ServiceController.Start(String[] args) at System.ServiceProcess.ServiceController.Start() at Sms_Service_Sms_SmsServiceStartStop.StartWindowsService()


This Error is Thrown by Service Controller

in Development Server its Working fine but In IIS its Getting Problem,So i want to know how to give Permission to Windows Service through IIS.and Wheather IIS will works for User Account or Administrator Account.


Regards,

AnilKumar.D
Posted
Updated 6-Aug-13 20:50pm
v2

1 solution

The application runs as Windows Service which is hosted by the Windows Service Controller, which is very different from other applications (you know, it allow the service running when the user logs out on logs on, without the desktop, and so on).

Even though you can configure different services to run under different user accounts, including "usual" user account, it does not normally run under any of such accounts. Also, you should understand the "Administrator" account is not essentially different from other user accounts; it's just set up by the OS installation first, assigned to "Administrators" group and some predefined sets of privileges are assigned to this group and member. Later on, you can create more accounts with exact same privileges and even remove "Administrator". The bottom line is: for most or all services, including IIS, such accounts are totally unsuitable. They are used to work on a desktop, in contrast to the Services.

So, the Services are usually run under special accounts like "Local System", "Local Service" or "Network Service".

You can see what account is used by IIS: show the "Administrative Tools" applet "Services". (By the way, you can start it from command line as %windir%\system32\services.msc.) You will find IIS service process running under the name like "World Wide Web Publishing Service".

See the privileges of the NetworkService account: http://msdn.microsoft.com/en-us/library/windows/desktop/ms684272%28v=vs.85%29.aspx[^].

This is just to answer your exact question (the answer is: none of them) and help to understand the service hosting and accounts.

I'm afraid you provided not enough information to actually fix the problem. To do this, you should study the runtime of your application and find out where the exception is thrown. Detailed logging can help.

—SA
 
Share this answer
 
Comments
Anil Honey 206 7-Aug-13 4:30am    
In Run Time only I got this

Error:
System.InvalidOperationException: Cannot open VMC_SMS_SERVICE service on computer '.'. ---> System.ComponentModel.Win32Exception: Access is denied --- End of inner exception stack trace --- at System.ServiceProcess.ServiceController.GetServiceHandle(Int32 desiredAccess) at System.ServiceProcess.ServiceController.Start(String[] args) at System.ServiceProcess.ServiceController.Start() at Sms_Service_Sms_SmsServiceStartStop.StartWindowsService()

When iam Running the Service Through Web application WHICH I Hosted in IIS
so please still i dont know where iam doing wrong.
Sergey Alexandrovich Kryukov 7-Aug-13 9:37am    
UAC is not the only possible reason. Web application run in sandboxes environment, for safety purpose...
—SA
Anil Honey 206 7-Aug-13 5:39am    
<system.web>
<identity impersonate="true" username="accountname" password="password">


i can use this to give Permission to windows service using web application

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900