How to return TaskDefinition in WCF method?

Topics: Errors, Examples
Nov 11, 2015 at 12:36 AM
Edited Nov 11, 2015 at 12:37 AM
On version 2.5.1.0. Followed service definition would get error

Type 'Microsoft.Win32.TaskScheduler.TaskDefinition' cannot be IXmlSerializable and have DataContractAttribute attribute.
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        void DoWork();

        [OperationContract]
        TaskDefinition GetTask();    //this will fail
    }
Reads TaskDefinition's attributes
    /// <summary>
    /// Defines all the components of a task, such as the task settings, triggers, actions, and registration information.
    /// </summary>
    [XmlRootAttribute("Task", Namespace = TaskDefinition.tns, IsNullable = false)]
    [XmlSchemaProvider("GetV1SchemaFile")]
    [DataContract(Name = "Task", Namespace = TaskDefinition.tns)]
    public sealed class TaskDefinition : IDisposable, IXmlSerializable
Coordinator
Nov 11, 2015 at 3:20 PM
I believe this is the result of a bug I introduced in 2.5. I have removed it in 2.5.3 which is now available.
Marked as answer by dahall on 11/11/2015 at 8:20 AM