© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
3 replies
Foomf

❔ ServiceBase question: is Main() or OnStart() my entry point?

I have a program that extends
ServiceBase
ServiceBase
. I am given a method to override called
OnStart()
OnStart()
. When my app is running as a windows service, is this the entry point? The tutorial I followed also has me calling
ServiceBase.Run()
ServiceBase.Run()
in my
Main()
Main()
method.

The reason I'm asking is because I'm trying to decide where I should set up my logger. My app also needs to run as a console app. My
Main()
Main()
method has a
Environment.UserInteractive
Environment.UserInteractive
branch. If user interactive, I run as a console app. If not user interactive, I call
ServiceBase.Run()
ServiceBase.Run()
. If this is the incorrect approach, feedback would be much appreciated!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

The entry point of the program is global code; ignoring 'Program.Main(string[])' entry point.
C#CC# / help
3y ago
Debugger Error: No Main method suitable for entry point in .csproj
C#CC# / help
16mo ago
❔ Why is PointF not simply Point<float>?
C#CC# / help
3y ago
MAUI Entry Point - MauiProgram.cs [Answered]
C#CC# / help
4y ago