Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Windows Service stopping immediately
Message
From
02/09/2013 23:31:41
 
 
To
02/09/2013 00:54:41
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01581778
Message ID:
01581855
Views:
33
>I'm glad you finally got it working, Michel!

BTW, this has created a downsize effect. Lets take a look back at the main class:
Imports System.ServiceProcess

Public Class Main
    Inherits WindowsService

    Public Sub New()
    End Sub

    Shared Sub Main()

        ' If this from the Windows Service
        If Not Environment.UserInteractive Then
            Dim loWindowsService As ServiceBase()
            loWindowsService = New ServiceBase() {New WindowsService()}
            ServiceBase.Run(loWindowsService)
        Else
            oWindowsService = New WindowsService()
            oWindowsService.Start()
            Console.ReadLine()
            oWindowsService.Stop2()
        End If

    End Sub

    Public Overrides Function Initialize() As Boolean
        oApp.cMemberTable = "Member"
        Return True
    End Function
As you can see, I have an Overrrides on Initialize(). This does not get called anymore. It took me a while to find a weird situation and this was due to this. This main class inherits from WindowsService. But, because the Main() method is instantiating an instance of the WindowsService class on its own, this cancelled the default behavior of the WindowsService base class which contains something like this:
    ' Allow the client to set up custom code in the initialization
    Public Overridable Function Initialize() As Boolean
        Return True
    End Function
For this one, I have to say, I have no idea on how to rearchitect the design so it would be called. Have you ever done something like that?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform