我有一个有效的 XmlSerializer 类型:
public class MyItem
{
public MyItem() {
Values = new List<string>();
}
public List<string> Values { get; private set; }
}
它成功地序列化和反序列化(完整代码示例在这里http://ideone.com/s2PvSB)。但是,我无法为这种类型生成 .XmlSerializers.dll,SGen 失败:
Microsoft (R) Xml Serialization support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.33440]
Copyright (C) Microsoft Corporation. All rights reserved.
EXEC : error : Unable to generate a temporary class (result=1).
EXEC : error CS0200: Property or indexer 'TestSGen.MyItem.Values' cannot be assigned to -- it is read only
从 PostBuild 事件中调用的 SGen 为
"$(TargetFrameworkSDKToolsDirectory)SGen.exe" /Assembly:"$(TargetFileName)" /Type:"TestSGen.MyItem" /Force
它是 SGen 中的错误还是 [某处] 记录的行为?