目前,我有我使用混淆,用於跟蹤高分的遊戲我工作的一個靜態類的輔助類。我在發佈時使用了Eazfuscator,發現當我的分數被序列化時,拋出了這個異常。 ArgumentException標識符''不符合CLS。連載混淆類C#
有沒有一種方法我可以存儲我的高分名單在我的助手類,仍然能夠混淆後的序列化?
try
{
GameHighScore highScoreHelper = new GameHighScore();
highScoreHelper.CreateGameHighScore(highScore);
XmlSerializer serializer = new XmlSerializer(typeof(GameHighScore));
serializer.Serialize(stream, highScoreHelper);
}
catch(Exception e)
{
Logger.LogError("Score.Save", e);
}
我的助手類:
public class GameHighScore
{
public List<HighScoreStruct<string, int>> highScoreList;
private HighScoreStruct<string, int> scoreListHelper;
[XmlType(TypeName = "HighScore")]
public struct HighScoreStruct<K, V>
{
public K Initials
{ get; set; }
public V Score
{ get; set; }
public HighScoreStruct(K initials, V score) : this()
{
Initials = initials;
Score = score;
}
}
public GameHighScore()
{
highScoreList = new List<HighScoreStruct<string, int>>();
scoreListHelper = new HighScoreStruct<string, int>();
}
public void CreateGameHighScore(List<KeyValuePair<string, int>> scoreList)
{
for (int i = 0; i < scoreList.Count; i++)
{
scoreListHelper = new HighScoreStruct<string, int>(scoreList[i].Key, scoreList[i].Value);
highScoreList.Add(scoreListHelper);
}
}
}
在我的結構體中添加'[Obfuscation(Exclude = True)]'就像一個魅力一樣工作,現在分數正確地序列化成一個xml文件。謝謝! – NexAddo 2012-03-20 17:43:20