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

  • Home
  • SEARCH
  • 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 346837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:12:53+00:00 2026-05-12T11:12:53+00:00

I am trying to figure out a way to pre-process few things before my

  • 0

I am trying to figure out a way to pre-process few things before my WinForm app loads. I tried putting static void Main() in a form within a class library project and commented it out from Program.cs. Which generated a compile time error: “…does not contain a static ‘Main’ method suitable for an entry point”. It makes sense since the program is not loaded, the DLL is not loaded either.

So the question is, is there a way to do this at all? I want the form in the DLL to be able to determine which form to launch the application with:

[STAThread]
static void Main()
{
   Application.EnableVisualStyles();
   Application.SetCompatibleTextRenderingDefault(false);

   if(condition1)
   {
      Application.Run(new Form1());
   }
   else if(condition2)
   {
      Application.Run(new Form2());
   }
}

This logic will be used in more than one app so it makes sense to put it in a common component.

  • 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-12T11:12:53+00:00Added an answer on May 12, 2026 at 11:12 am

    Can you just add a static method in your DLL that your application calls instead of doing the processing in main?

    // In DLL
    public static class ApplicationStarter
    {
         public static void Main()
         {
              // Add logic here.
         }
    }
    
    // In program:
    {
         [STAThread]
         public static void Main()
         {
              ApplicationStarter.Main();
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For the past few hours I've been trying to figure out a way to
Im trying to figure out a way to move a UILabel to different pre
I am trying to figure out some way to get actual time via JavaScript,
I'm trying to figure out a way of how to be able to assign
I am trying to figure out my way through c89 and now I ma
I am trying to figure out a way to cut out a certain region
I'm trying to figure out a way to limit the dragging option of the
I am trying to figure out a way for somehow fetching the all the
I'm trying to figure out a way to re-use the validation rules of Yii's
I'm trying to figure out a way to use tar+pipes on a Ubuntu Server

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.