首先是代码:
if (Global.SaveDevice.FileExists(Global.containerName, Global.Challenges))
{
Global.SaveDevice.Load(
Global.containerName,
Global.Challenges,
stream =>
{
using (StreamReader reader = new StreamReader(stream))
{
Challenges.CompleteCount = int.Parse(reader.ReadLine());
Challenges.Colorist = bool.Parse(reader.ReadLine());
Challenges.ConsecutiveI = bool.Parse(reader.ReadLine());
Challenges.ConsecutiveII = bool.Parse(reader.ReadLine());
Challenges.ConsecutiveIII = bool.Parse(reader.ReadLine());
Challenges.ConsecutiveIV = bool.Parse(reader.ReadLine());
Challenges.CountDownWizardI = bool.Parse(reader.ReadLine());
Challenges.CountDownWizardII = bool.Parse(reader.ReadLine());
Challenges.CountDownWizardIII = bool.Parse(reader.ReadLine());
Challenges.MultiplierI = bool.Parse(reader.ReadLine());
Challenges.MultiplierII = bool.Parse(reader.ReadLine());
Challenges.MultiplierIII = bool.Parse(reader.ReadLine());
Challenges.MultiplierIV = bool.Parse(reader.ReadLine());
Challenges.OneUpI = bool.Parse(reader.ReadLine());
Challenges.OneUpII = bool.Parse(reader.ReadLine());
Challenges.OneUpIII = bool.Parse(reader.ReadLine());
Challenges.OneUpIV = bool.Parse(reader.ReadLine());
Challenges.PongWizardI = bool.Parse(reader.ReadLine());
Challenges.PongWizardII = bool.Parse(reader.ReadLine());
Challenges.PongWizardIII = bool.Parse(reader.ReadLine());
Challenges.ScoreI = bool.Parse(reader.ReadLine());
Challenges.ScoreII = bool.Parse(reader.ReadLine());
Challenges.ScoreIII = bool.Parse(reader.ReadLine());
Challenges.ScoreIV = bool.Parse(reader.ReadLine());
Challenges.ScoreV = bool.Parse(reader.ReadLine());
Challenges.StarShifterWizardI = bool.Parse(reader.ReadLine());
Challenges.StarShifterWizardII = bool.Parse(reader.ReadLine());
Challenges.StarShifterWizardIII = bool.Parse(reader.ReadLine());
}
});
我在第 12 行(Challenges.ConsecutiveI = bool.Parse(reader.ReadLine()); )得到一个“在 mscorlib.dll 中发生 System.FormatException”,如果我将其注释掉,我也会在解析时收到以下行的它,但是我在前两行解析中没有得到异常。我在这里尝试做的是使用 Nick Gravelyn 的 EasyStorage 示例加载一堆东西,它可以很好地保存具有不同错误的不同类中的对象,我认为它们称为“子容器”,例如 Global.Challenges,然后是 Global。选项等,但是是的,我对问题的根源感到困惑。
这里也是调用堆栈的最后两行:
GameStateManagementSample.exe!GameStateManagement.ChallengesScreen..ctor.AnonymousMethod__0(System.IO.Stream stream) 第 42 行 + 0x6 字节 C# EasyStorage.dll!EasyStorage.SaveDevice.Load(string containerName, string fileName, EasyStorage.FileAction loadAction) 第 75 行 + 0x7 字节 C#
谢谢你的帮助!