Monday, February 21, 2011

HOWTO: specify in app.config to call a function before Main() is called?

I really want to put in some sort of section handler into App.config that will execute some code before the application actually starts executing at Main. Is there any way to do such a thing?

From stackoverflow
  • Why dont you put that call as the first instruction in your main function?

    Otherwise you can define another entry point for your program and call your main from there but its basicaly the same

  • Not sure what you're trying to accomplish...but, I'm not aware of anyway you can have a console application run any other method before Main(). Why not do something like this:

    static void Main(string[] args)
    {
        //read your app.config variable
        callAlternate = GetConfigSettings(); 
        if(callAlternate)
            AltMain();
    
        ///...rest of Main()
    }
    

0 comments:

Post a Comment