为什么静态构造函数在引用另一个类中的 const 字符串时会抛出异常。
class MyClass
{
static MyClass()
{
ExamineLog();
}
static ExamineLog()
{
FilePath = HttpContext.Current.Server.MapPath(Helper.LogConfiguration);
}
}
class Helper
{
public const string LogConfiguration= "\rootpath\counters.txt";
}
抛出的异常是对象引用未设置为对象的实例。堆栈跟踪指向尝试读取常量值的行。有什么想法吗?