Serialized list of <> classes declared with an internal modifier?

I am trying to add XML serialization to a rather trivial class structure in C #. Essentially, there is one instance of the root class (name it AClass) that contains a list of several instances of some other class (name it AnotherClass):

[XmlRoot("RootNode")]
public class AClass {
    [XmlElement("ListNode")]
    internal List otherObjects { get; set; }
}

public class AnotherClass {
    [XmlAttribute("Name")]
    internal string name { get; set; }
}

When serializing, I would like both of these classes to be serialized together - that is, if I serialize AClass, its AnotherClass list will also be serialized (see this question ).

This basically works for me, but the problem is that during serialization, the XmlSerializer seems to want to deal with publicclass properties - it does not serialize AnotherClass at all if the list is declared internal.

:

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("System.Xml")]

. XmlSerializer , ?

+5
2

... , System.Xml, . ( ), InternalsVisibleTo.

- XML-. , XML (Sgen.exe). "YourAssembly.XmlSerializers"; , InternalsVisibleTo.

+6

InternalsVisibleTo , , , Xml .
, XmlSerializer, , . , XmlSerializer , : " XML - public ( XML) ", .

+1

All Articles