Note that there are some explanatory texts on larger screens.

plurals
  1. POPublic Class - "is inaccessible due to its protection level. Only public types can be processed."
    primarykey
    data
    text
    <p>I am doing a test project to learn about XML serialization of an object, and I am getting an odd runtime error:</p> <pre><code>namespace SerializeTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void serializeConnection(Conn connection) { XmlSerializer serializer = new XmlSerializer(typeof(Conn)); TextWriter textWriter = new StreamWriter(@"serialized.xml"); serializer.Serialize(textWriter, connection); textWriter.Close(); } static List&lt;Conn&gt; deserializeConnection() { XmlSerializer deserializer = new XmlSerializer(typeof(List&lt;Conn&gt;)); TextReader textReader = new StreamReader(@"serialized.xml"); List&lt;Conn&gt; connectionList; connectionList = (List&lt;Conn&gt;)deserializer.Deserialize(textReader); textReader.Close(); return connectionList; } private void btnSerialize_Click(object sender, EventArgs e) { Conn conn = getConnection(); serializeConnection(conn); } private Conn getConnection() { Conn connection = new Conn(); connection.connectionName = txtName.Text; connection.address = txtAddress.Text; connection.height = 2542; connection.width = 4254; connection.password = txtPassword.Text; connection.smartSizing = false; connection.username = txtUsername.Text; connection.port = 474; return connection; } private void btnDeserialize_Click(object sender, EventArgs e) { int count = deserializeConnection().Count; lblStatus.Text = "Count: " + count; } } class Conn { public Conn() { } public string connectionName { get; set; } public int height { get; set; } public int width { get; set; } public string address { get; set; } public string username { get; set; } public string password { get; set; } public int port { get; set; } public bool smartSizing { get; set; } } } </code></pre> <p>The Class is public - I don't understand what could be causing this error. Any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload