Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 539253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:07:01+00:00 2026-05-13T10:07:01+00:00

EDIT: I’m starting a bounty on this question. For the moment, I’ve moved on

  • 0

EDIT: I’m starting a bounty on this question. For the moment, I’ve moved on and am developing my application using VS2010 Pro Beta, but I’d really like it to be able to be built with express edition, since we are generally not a .net shop and even if one or two developers have VS PRO it will not be available to our entire team.

To be the accepted answer and claim the bounty, you must provide sample code and instructions that will allow a Windows Service to be installed and uninstalled using vb 2008 express edition. You don’t necessarily need to start with my code (but the essentials of it are included below).


I’ve written a VB.NET application which I would like to run as a service. Currently I’m using VB.net Express Edition (2008) which does not ship with the “Service” template, but I’ve added a Service class (inheriting from ServiceBase) and an Installer class (inheriting from Installer); in both cases I’m following sample code from MSDN. Unfortunately I haven’t been able to get this code to install and run as a service.

The meat of this code is a TCP Listener class called sampleListener. If I set the sampleListener class as the startup object and run my project, it runs fine as a console application.

There’s a service class (below) which simply starts the sampleListener.

Public Class sampleSocketService
    Inherits System.ServiceProcess.ServiceBase

    Public Sub New()
        Me.ServiceName = "sample Socket Service"
        Me.CanStop = True
        Me.CanPauseAndContinue = True
        Me.AutoLog = True
    End Sub

    Shared Sub Main()
        System.ServiceProcess.ServiceBase.Run(New sampleSocketService)
    End Sub

    Protected Overrides Sub OnStart(ByVal args() As String)
        sampleListener.Main()
    End Sub

End Class

There’s also an installer class which I think is the source of my problems. Here’s the installer class as I initially wrote it.

Imports System
Imports System.Collections
Imports System.Configuration.Install
Imports System.ServiceProcess
Imports System.ComponentModel

<RunInstallerAttribute(True)> _
Public Class sampleSocketServiceInstaller
    Inherits Installer
    Private serviceInstaller1 As ServiceInstaller
    Private processInstaller As ServiceProcessInstaller

    Public Sub New()
        ' Instantiate installers for process and services.
        processInstaller = New ServiceProcessInstaller()
        serviceInstaller1 = New ServiceInstaller()

        processInstaller.Account = ServiceAccount.LocalSystem
        serviceInstaller1.StartType = ServiceStartMode.Automatic

        ' ServiceName must equal those on ServiceBase derived classes.            
        serviceInstaller1.ServiceName = "sample Socket Service"

        ' Add installers to collection. Order is not important.
        Installers.Add(serviceInstaller1)
        Installers.Add(processInstaller)
    End Sub
End Class

Running installutil.exe on this produces the following message:

An exception occurred during the Install phase.
System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.

This looks like a security problem, but I’m running in a cmd window that was opened using Run As Administrator.

I tried a much simplified Installer class based on an online example:

Imports System.ComponentModel
Imports System.Configuration.Install

<RunInstaller(True)> Public Class ProjectInstaller
    Inherits System.Configuration.Install.Installer

End Class

This seems ridiculously simple, and I couldn’t figure out how it could possibly work, and in fact it didn’t. However, when running installutil.exe on the project with this version of the installer class, installutil.exe does not throw an error message and reports that the service has been installed successfully.

I suspect I need code in my installer class that does some of what’s in my first example, but doesn’t do whichever part is causing the error.

Any suggestions?

(This has been edited extensively for clarity and to add code examples which were not originally included)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:07:01+00:00Added an answer on May 13, 2026 at 10:07 am

    This seems to work for me but I haven’t added in your own code.

    Create two files a Service1.vb and a ProjectInstaller.vb. Normally the Service1 and ProjectInstaller are setup as Partial classes but for the sake of posting here they are not. I dont think it has any side affects but someone else can comment on that.

    I normally handle Install/Uninstall with a bat file.

    Add two references to the project

    System.ServiceProcess
    System.Configuration.Install

    Service1.vb

    Imports System.ServiceProcess
    
    Public Class Service1
    Inherits System.ServiceProcess.ServiceBase
    
    Protected Overrides Sub OnStart(ByVal args() As String)
    End Sub
    
    Protected Overrides Sub OnStop()
    End Sub
    
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub
    
    <MTAThread()> _
    <System.Diagnostics.DebuggerNonUserCode()> _
    Shared Sub Main()
        Dim ServicesToRun() As System.ServiceProcess.ServiceBase
    
        ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service1}
    
        System.ServiceProcess.ServiceBase.Run(ServicesToRun)
    End Sub
    
    Private components As System.ComponentModel.IContainer
    
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        components = New System.ComponentModel.Container()
        Me.ServiceName = "Service1"
    End Sub
    
    End Class
    

    ProjectInstaller.vb

    Imports System.ComponentModel
    Imports System.Configuration.Install
    
    <System.ComponentModel.RunInstaller(True)> _
    Public Class ProjectInstaller
    Inherits System.Configuration.Install.Installer
    
    Public Sub New()
        MyBase.New()
    
        InitializeComponent()
    
    End Sub
    
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub
    
    Private components As System.ComponentModel.IContainer
    
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller
        Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller
    
        Me.ServiceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem
        Me.ServiceProcessInstaller1.Password = Nothing
        Me.ServiceProcessInstaller1.Username = Nothing
    
        Me.ServiceInstaller1.ServiceName = "Service1"
        Me.ServiceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic
    
        Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceProcessInstaller1, Me.ServiceInstaller1})
    
    End Sub
    Friend WithEvents ServiceProcessInstaller1 As System.ServiceProcess.ServiceProcessInstaller
    Friend WithEvents ServiceInstaller1 As System.ServiceProcess.ServiceInstaller
    
    End Class
    

    Install Bat

    C:
    CD \WINDOWS\Microsoft.NET\Framework\v2.0.50727
    installutil "C:\Visual Studio 2008\Projects\....\Temp.exe"
    pause
    NET START Service1
    

    Unstall Bat

    C:
    CD \WINDOWS\Microsoft.NET\Framework\v2.0.50727
    NET STOP Service1
    installutil /u "C:\Visual Studio 2008\Projects\....\Temp.exe"
    

    Hopefully that’ll work for you

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: This question was written in 2008, which was like 3 internet ages ago.
EDIT: This question is more about language engineering than C++ itself. I used C++
EDIT: upgraded this question to MVC 2.0 With asp.net MVC 2.0 is there an
Edit: This is technically a 2 part question. I've chosen the best answer that
EDIT: had to retag this, because, it's rather a Sweave / R question since
Edit: From another question I provided an answer that has links to a lot
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE
edit #2: Question solved halfways. Look below As a follow-up question, does anyone know
Edit: This was accidentally posted twice. Original: VB.NET Importing Classes I've seen some code
Edit: I have solved this by myself. See my answer below I have set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.