C# Static Contstructor Not Called When Referencing Static Object

by dcurtis 1/16/2010 12:40:00 PM
I had a situation today where I had a static constructor that was never getting initialized and setting some of the default values.  As a result, other content within my code suffered from the same issue.  I searched in vain for a solution and couldn't find anything until I finally revised my search terms.  It turns out that Visual Studio was firing the constructor the first time it would run, but then it encountered an error and would never fire again.  I found a reference in the .Net Development Center that mentioned shutting down the development web server; however, I had already tried that and it didn't do anything for me.  What did work, though, was changing something within the class as the author of that post said (adding a comment, inserting a space, deleting something) and then recompiling and I was finally able to get the static constructor to fire so I could continue to debug the code.  

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Visual Studio 2008 | C#

Powered by BlogEngine.NET 1.3.0.0
Theme by Mads Kristensen

About the author

Derek Curtis Derek Curtis
President, Plaid Pony Technology Solutions LLC

E-mail me Send mail

Calendar

<<  November 2017  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Pages

    Recent comments

    Authors

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2017

    Sign in