2013-09-27 37 views
0

當我嘗試添加自定義類型接收消息的動作我不斷收到此錯誤:WF 4.5工作流服務收到消息「不能隱式地將類型'對象'轉換爲'type.x.'顯式轉換存在

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

這裏是我的對象:

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

回答

0

啊,神祕的.Net

你必須使用'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!"; 
     } 
    } 
} 
相關問題