I have a static class called Helpers which contains a good number of simple helper methods including some simple extension methods on ‘string’ and the like:
public static string AddSquareBrackets(this string str)
{
return "[" + str + "]";
}
I have a test class and method as follows:
[TestMethod()]
public void AddSquareBracketsTest()
{
Assert.AreEqual("[NAME]", "NAME".AddSquareBrackets());
}
Static class declared with default (no coded) constructor:
namespace Equinoxe.Utilities.Helpers
{
public static class HELPERS
{
The call to the AddSquareBrackets throws the following:
System.TypeInitializationException was unhandled by user code
Message=The type initializer for 'XXX.Utilities.Helpers.HELPERS' threw an exception.
Source=XXX.Utilities
TypeName=XXX.Utilities.Helpers.HELPERS
StackTrace:
at XXX.Utilities.Helpers.HELPERS.AddSquareBrackets(String str)
at XXX.Utilities.Test.HELPERSTest.AddSquareBracketsTest() in C:\DEVELOPMENT\PROJECTS\XXX.NavEgate\XXX.Utilities.Test\HELPERSTest.cs:line 77
InnerException: System.NullReferenceException
Message=Object reference not set to an instance of an object.
Source=XXX.Utilities
StackTrace:
at XXX.Utilities.Helpers.HELPERS..cctor() in C:\DEVELOPMENT\PROJECTS\XXX.Utilities\XXX.Utilities\Helpers\HELPERS.cs:line 44
InnerException:{System.NullReferenceException: Object reference not set to an instance of an object.
at XXX.Utilities.Helpers.HELPERS..cctor() in C:\DEVELOPMENT\PROJECTS\XXX.Utilities\XXX.Utilities\Helpers\HELPERS.cs:line 44}
I have also looked
Im running VS2010