Wrox Programmer Forums
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 9th, 2005, 09:43 AM
Registered User
 
Join Date: Jun 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Installing Windows Service

>>>> I can install a service as localsystem successfully as follows:

Dim context As New System.Configuration.Install.InstallContext("insta ll.log", Nothing)
context.Parameters.Add("assemblyPath", ServicePath)


Dim serviceProcessInstaller1 As New System.ServiceProcess.ServiceProcessInstaller
serviceProcessInstaller1.Account = ServiceProcess.ServiceAccount.LocalSystem
'serviceProcessInstaller1.Account = ServiceProcess.ServiceAccount.User
'serviceProcessInstaller1.Username = "User1"
'serviceProcessInstaller1.Password = "pw1"



Dim serviceInstaller1 As New System.ServiceProcess.ServiceInstaller


With serviceInstaller1
.StartType = ServiceStartMode.Automatic
.Context = context
.ServiceName = ServiceName
.DisplayName = ServiceName
.Parent = serviceProcessInstaller1
End With

serviceInstaller1.Install(New Hashtable)

>>>>> But when I try to use a user account instead I get this error:

An unhandled exception of type 'System.NullReferenceException' occurred in system.serviceprocess.dll

Additional information: Object reference not set to an instance of an object.

>>>>>> Here's the code I'm trying to run:

Dim context As New System.Configuration.Install.InstallContext("insta ll.log", Nothing)
context.Parameters.Add("assemblyPath", ServicePath)


Dim serviceProcessInstaller1 As New System.ServiceProcess.ServiceProcessInstaller
' serviceProcessInstaller1.Account = ServiceProcess.ServiceAccount.LocalSystem
serviceProcessInstaller1.Account = ServiceProcess.ServiceAccount.User
serviceProcessInstaller1.Username = "User1"
serviceProcessInstaller1.Password = "pw1"



Dim serviceInstaller1 As New System.ServiceProcess.ServiceInstaller


With serviceInstaller1
.StartType = ServiceStartMode.Automatic
.Context = context
.ServiceName = ServiceName
.DisplayName = ServiceName
.Parent = serviceProcessInstaller1
End With

serviceInstaller1.Install(New Hashtable)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing windows service in remote machine dotnetprogrammer VS.NET 2002/2003 1 July 13th, 2007 01:17 PM
Troubleshoot in installing windows service srkarthik_82 General .NET 2 January 9th, 2007 02:10 AM
Accessing Windows service from a windows app sajid08 C# 1 October 6th, 2006 10:25 AM
running an .exe API without installing a service taunon C# 0 June 10th, 2006 09:37 AM
Installing windows service avats General .NET 1 June 9th, 2005 09:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.