2013-09-27 3 views
0

Lorsque je tente d'ajouter un type personnalisé pour l'action de réception des messages que je reçois cette erreur:WF 4.5 Workflow Service reçoit le message «Impossible de convertir implicitement type 'objet' en 'type.x.' Une existe conversion explicite

"Cannot implicitly convert type 'object' to 'type.x.' An explicit conversion exists. 

voici mon objet:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 

namespace TestWorkflowService 
{ 
    public abstract class Duck 
    { 
     public string Name { get; set; } 
     public string Type { get; set; } 

     public Duck(string name,string type) 
     { 
      this.Name = name; 
      this.Type = type; 
     } 

     public virtual string Quack() 
     { 
      return "Quack Quack!"; 
     } 
    } 

    public class Mallard : Duck 
    { 
     public Mallard(string name) 
      : base(name, "Mallard") 
     { 

     } 
    } 

public class RubberDuck : Duck 
    { 
     public RubberDuck(string name) 
      :base(name, "Rubber Duck") 
     { 

     } 

     public override string Quack() 
     { 
      return "Squeek Squeek"; 
     } 
    } 
} 

enter image description here

enter image description here

enter image description here

Répondre

0

Ah, les mystères de .Net

Vous devez utiliser des objets 'Serializable'.

http://msdn.microsoft.com/en-us/library/ee358739.aspx

enter image description here

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Runtime.Serialization; 


namespace TestWorkflowService 
{ 
    [Serializable] 
    public abstract class Duck 
    { 
     public string Name { get; set; } 
     public string Type { get; set; } 

     public Duck(string name,string type) 
     { 
      this.Name = name; 
      this.Type = type; 
     } 

     public virtual string Quack() 
     { 
      return "Quack Quack!"; 
     } 
    } 
} 
Questions connexes