Search code examples
c#visual-studio-2012cache-control

Visual Studio does not run function after first execution


In my c# file, I have a line:

if (request.Message.Version != Manager.Version)

On the first execution, it does go to Manager() and executes the code in the function. However, if I run the program afterwards, it just skips calling the Manager() and continues running the line after it. Interestingly, I found that if I restart the visual studio, it does run that Manager() function again.

The Manager() Function is for assigning values from configuration appsettings to my queue

Any ideas are appreciated.


Solution

  • My crystal ball says that Manager() is a static constructor:

    static Manager()
    {
        // some code
    }
    

    The whole point of static constructors is that they are run only once per application lifetime, so everything is working as expected here.

    Further reading:
    http://msdn.microsoft.com/en-us/library/k9x6w0hc.aspx