Serialize an object that has an interface
<p>I'm having quite the problem with my XML serialization issue. I've been working on my project to (de) serialize an object that has an interface as an attribute. I know that you can't serialize an interface and that is what my error tells me.</p>

<p>Here is an example of the object that I want to save to a file:</p>

<pre><code>public class Task
{
    public int id;
    public string name;
    public TypeEntree typeEntree;
    public int idRequired;
    public string code;
    public int waitTime;
    public string nameApp;
    // ... Constructors (empty and non-empty) and methods ...
}
</code></pre>

<p>TypeEntree is an empty interface, it's only to relate different objects and use them easily around my application. For instance, here are two of the objects that uses this interface:</p>

<pre><code>[Serializable]
public class Mouse : TypeEntree
{
    public Point point;
    public IntPtr gaucheOuDroite;
    public string image;
    // ... Constructors (empty and non-empty) and methods ...
}

[Serializable]
public class Sequence : TypeEntree
{
    public List&lt;Tuple&lt;string, Point, long, IntPtr&gt;&gt; actions;
    // ... Constructors (empty and non-empty) and methods ...
}
</code></pre>

<p>The interface TypeEntree also has the [Serializable] attribute and also the [XmlInclude (typeof (Mouse)] for each of my classes that uses this interface.</p>

<p><strong>Here is my question:</strong> Why does when I try to serialize, it cannot detects the type of my object (typeEntree in Task) since I added the [XmlInclude (typeof (Mouse)] attributes?</p>

<p><strong>Also, how should I fix this issue?</strong></p>

<p>Additionnally, here are the methods of serializing/deserializing I found that seems to works very well without interface: <a href="https://stackoverflow.com/a/22417240/6303528">https://stackoverflow.com/a/22417240/6303528</a></p>