为什么CultureTableRecord会抛出异常?

时间:2015-04-03 13:27:18

标签: c# exception nullreferenceexception cultureinfo culture

比较String时,我收到NullReferenceException。这只发生在一个客户身上,但发生在他所在地的几台计算机上。我们无法在内部重现这一点。

这是异常的部分堆栈跟踪:

System.NullReferenceException: Object reference not set to an instance of an object.  
at System.Globalization.CultureTableRecord.GetCultureTableRecord(String name, Boolean useUserOverride)
at System.Globalization.CultureTableRecord.GetCultureTableRecord(Int32 cultureId, Boolean useUserOverride)
at System.Globalization.CultureInfo..ctor(Int32 culture, Boolean useUserOverride)
at System.Globalization.CultureInfo.GetCultureByLCIDOrName(Int32 preferLCID, String fallbackToString)  
at System.Globalization.CultureInfo.InitUserDefaultCulture()
at System.Globalization.CultureInfo.get_UserDefaultCulture()
at System.Threading.Thread.get_CurrentCulture()
at System.String.Equals(String value, StringComparison comparisonType)  

什么可能导致CultureTableRecord腐败?


编辑: 这是调用String.Equals的方法。

public override bool Equals(object obj)
{
    var other = obj as MyObject;
    return other != null && this.FileName.Equals(other.FileName, StringComparison.CurrentCultureIgnoreCase);
}

0 个答案:

没有答案