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 3210526
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:34:42+00:00 2026-05-17T14:34:42+00:00

In a typical winform program.cs contains the entry point: static void Main(string[] args) {

  • 0

In a typical winform program.cs contains the entry point:

     static void Main(string[] args) {

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        // the code goes on

I want to create my own framework which hide the plumbings of all stuffs that has nothing to do with application domain so I’d like to be able to create a base class in an another namespace something like this

namespace MyFramework
{
    public partial class Program
    {

        

        [STAThread]
        static void Main(string[] args)
        {

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            
            
            // the code goes on

And then in my app namespace program.cs inherit from the one above so that I can get rid off the Application.EnableVisualStyles and write only something like this

        static void Main(string[] args): base()
        {
           //only app domain code

I can inherit from base class if I remove static attrib from both class but I am not able to remove static from main entry method so I cannot really finalize.

I don’t want to use code behind to hide the plumbings because I need to port this to other languages that doesn’t have code behind.

So is there a way to achieve this simple and legitimate goal with OOP (inheritance or not, static or not) only without using some big external framework ?

For example is there a way I could delegate main entry point to another class in the framework namespace ?

  • 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-17T14:34:42+00:00Added an answer on May 17, 2026 at 2:34 pm

    The entry point method needs to be static so using inheritance (as perceived by you) would not work but there can be several ways to do what you want to do. For example,

    namespace MyFramework
    {
        public static class AppStarter
        {
    
            static EventHandler AppStarting;
    
            [STAThread]
            static void Run(string[] args)
            {
    
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
    
    
                // the code goes on
    
                if (null != AppStarting)
                {
                   AppStarting(null, EventArgs.Empty);
                }
    

    Now, you can use it

     public partial class Program
     {
            [STAThread]
            static void Main(string[] args)
            {
    
                AppStarter.AppStarting += new EventHandler(MyStartupCode);
                AppStarter.Run(args);
    

    Yet another inheritance based variation would be

    namespace MyFramework
    {
        public abstract class Application
        {
    
            protected abstract void OnBeforeInit();
            protected abstract void OnAfterInit();
    
            protected void Run(string[] args)
            {
                OnBeforeInit();
    
                // Do initialization
    
                OnAfterInit(); 
    
                ...
            }
    

    And you will use it as follows:

     public class MyApplication: MyFramework.Application
     {
            [STAThread]
            static void Main(string[] args)
            {
    
                (new MyApplication()).Run(args);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a typical business application with an Outlook-looking Winforms client talking to asmx
Typical way of creating a CSV string (pseudocode): Create a CSV container object (like
For a typical business application, should the focus be on client processing via AJAX
I have a User Control for typical CRUD like actions on my WinForm app.
I'm diong a typical Windows Integrated Connection from a .Net Winforms Application: Dim sqlConnetion
I have a typical Silverlight application with a WCF service and I am using
Imagine a typical CakePHP application, in which a Controller passes various bits of data
I have a win form UI that looks like a typical calculator. Naturally I
A typical stored procedure in our system accepts around 20 or so parameters. There's
A typical approach to avoid two instances of the same script running simultaneously looks

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.