gubbalasree
asked on
Not able to start windows service written in vb.net
Hi All,
I have written windows service in vb.net that will read the registry entires from Current User. Code was working fine on windows application but same code is not working while trying to start the service. Its giving the following error
Could not start the FileConverter(name of my service) service on Local computer.
The service did not return an error. This could be an internal windows error or an internal service error. If the problem persists, contact your system administrator.
Here is my code:
Imports System.ServiceProcess
Imports System.IO
Imports Microsoft.Win32
Imports System.Security.Permission s
<Assembly: RegistryPermissionAttribut e(Security Action.Req uestMinimu m, All:="HKEY_CURRENT_USER")>
Protected Sub InitializeService()
Dim rk As RegistryKey = Registry.CurrentUser.OpenS ubKey("Sof tware\VB and VBA Program Settings\File Convertor\Inbox", False)
Dim cnt As Int32
cnt = rk.GetValue("Source") ' Source is the value under Inbox key
End Sub
Thanks in advance
Srinivas
I have written windows service in vb.net that will read the registry entires from Current User. Code was working fine on windows application but same code is not working while trying to start the service. Its giving the following error
Could not start the FileConverter(name of my service) service on Local computer.
The service did not return an error. This could be an internal windows error or an internal service error. If the problem persists, contact your system administrator.
Here is my code:
Imports System.ServiceProcess
Imports System.IO
Imports Microsoft.Win32
Imports System.Security.Permission
<Assembly: RegistryPermissionAttribut
Protected Sub InitializeService()
Dim rk As RegistryKey = Registry.CurrentUser.OpenS
Dim cnt As Int32
cnt = rk.GetValue("Source") ' Source is the value under Inbox key
End Sub
Thanks in advance
Srinivas
ASKER
I have tried with administrator acct but getting the same error.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Desp that key exists in the registry and if the service starts then i can debug by attaching the process to the debugger.
If i remove the registry access code then the service is starting and i m able to debug by attaching to the debugger.
If i remove the registry access code then the service is starting and i m able to debug by attaching to the debugger.
You can try getting the permissions imperatively.
Put the following as first lines of InitializeService():
Dim f As New RegistryPermission(Registr yPermissio nAccess.Re ad, "HKEY_CURRENT_USER\Softwar e\VB and VBA Program Settings\File Convertor\Inbox")
Are you sure this is where your error is coming from?
Have you tried hardcoding a value instead of reading from registry? Did it work?
Hope this helps some,
ZRH
Put the following as first lines of InitializeService():
Dim f As New RegistryPermission(Registr
Are you sure this is where your error is coming from?
Have you tried hardcoding a value instead of reading from registry? Did it work?
Hope this helps some,
ZRH
Recommendation: Delete/Not refund
(I believe that you need full permits in order to start a service)