Good morning,
I got a class DirObserver with a custom event:
public EventHandler<FileDetectedEventArgs> NewFileDetected;
I try to serialize this class in a other class with:
private XmlSerializer serializer = new XmlSerializer(typeof(List<DirObserver>));
But i get an exception: FileDetectedEventArgs cannot be serialized because it does not have a parameterless constructor.
But the FileDetectedEventArgs-Class have a parameterless constructor:
public class FileDetectedEventArgs : EventArgs
{
public String Source { get; set; }
public String Destination { get; set; }
public String FullName { get; set; }
public FileDetectedEventArgs(String source, String destination, String fullName)
{
this.Source = source;
this.Destination = destination;
this.FullName = fullName;
}
public FileDetectedEventArgs() { }
}
Nevertheless the exception will be raised. Whats the problem here?
Thanks and greets
Thomas
Change
to