Search code examples
c#xml-serializationxmlserializeraccess-levels

XmlSerializer treated as private, although is public


internal XmlSerializer wut = new XmlSerializer();

gives me compiler error cs0122. When mousing over XmlSerialzier it is listed as a public class. Any guesses?

I would provide relevant content, but I have no clue where the issue might be.


Solution

  • You are trying to instantiate a XmlSerializer object using the parameterless constructor.

    But when you look at the class you'll see that this particular constructor is protected which means you can't use it directly.

    You have to use one of the other public constructors to create on object of the XmlSerializer class.