You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using System.Xml.Serialization;using System.IO;[XmlRoot("root")]publicclassMyXml{[XmlAttribute]publicstringName{get;set;}=string.Empty;}vartext= File.ReadAllText("file.xml");using(var stream =newStringReader(text)){vardeserialized=new XmlSerializer(typeof(MyXml)).Deserialize(stream);varvalue= deserialized is not null?(MyXml)deserialized:default;
Console.WriteLine(value);}
I get the error
System.ArgumentException: Identifier 'Submission#0' is not CLS-compliant. (Parameter 'ident')
at System.Xml.Serialization.CodeIdentifier.CheckValidIdentifier(String ident)
at System.Xml.Serialization.CodeIdentifier.EscapeKeywords(String identifier, StringBuilder sb)
at System.Xml.Serialization.CodeIdentifier.GetCSharpName(Type t, Type[] parameters, Int32 index, StringBuilder sb)
at System.Xml.Serialization.CodeIdentifier.GetCSharpName(Type t, Type[] parameters, Int32 index, StringBuilder sb)
at System.Xml.Serialization.CodeIdentifier.GetCSharpName(Type t)
at System.Xml.Serialization.TypeDesc.get_CSharpName()
at System.Xml.Serialization.SourceInfo.CastTo(TypeDesc td)
at System.Xml.Serialization.XmlSerializationWriterILGen.WriteElements(SourceInfo source, String enumSource, ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, String arrayName, Boolean writeAccessors, Boolean isNullable)
at System.Xml.Serialization.XmlSerializationWriterILGen.WriteMember(SourceInfo source, String choiceSource, ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, TypeDesc memberTypeDesc, Boolean writeAccessors)
at System.Xml.Serialization.XmlSerializationWriterILGen.GenerateTypeElement(XmlTypeMapping xmlTypeMapping)
at System.Xml.Serialization.TempAssembly.GenerateRefEmitAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location)
at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace, String location)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
at Submission#0.<<Initialize>>d__0.MoveNext() in main.csx:line 15
--- End of stack trace from previous location ---
at Dotnet.Script.Core.ScriptRunner.Execute[TReturn](String dllPath, IEnumerable`1 commandLineArgs) in C:\Users\runneradmin\AppData\Local\Temp\tmpFE4C\Dotnet.Script.Core\ScriptRunner.cs:line 110
The text was updated successfully, but these errors were encountered:
If I try to execute code like
I get the error
The text was updated successfully, but these errors were encountered: