Serializing an XML in c# with type class showing error

1
 Public class Test{
   public string name {get;set;}
   }

Trying to serialize this class

XmlSerializer serlzer = new XmlSerializer(typeof(Test));

is showing error as The filename, directory name, or volume label syntax is incorrect. (Exception from HRESULT: 0x8007007B) + System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(int, System.IntPtr) + Microsoft.Win32.Fusion.ReadCache(System.Collections.ArrayList, string, uint) + System.Reflection.RuntimeAssembly.EnumerateCache(System.Reflection.AssemblyName) + System.Reflection.RuntimeAssembly.LoadWithPartialNameInternal(System.Reflection.AssemblyName, System.Security.Policy.Evidence, ref System.Threading.StackCrawlMark) + System.Reflection.Assembly.LoadWithPartialName(string, System.Security.Policy.Evidence) + System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly(System.Type, string, out System.Xml.Serialization.XmlSerializerImplementation) + System.Xml.Serialization.XmlSerializer..ctor(System.Type, string) + System.Xml.Serialization.XmlSerializer..ctor(System.Type)

Done all these in C# interactive in visual studio 2015 in .NET 4.6.1 environment

c#
.net
xml
serialization
asked on Stack Overflow Nov 28, 2017 by Hemanth Krishna

1 Answer

0

the issue is that generated assembly name for script assemblies contains an invalid character for the file system (#), and when the serializer attempts to load a serialization assembly, it fails.

try to reinstall the assembly again and see if that works, it happens sometimes that the assembly contains invalid characters.

answered on Stack Overflow Nov 28, 2017 by Barr J

User contributions licensed under CC BY-SA 3.0