当我尝试为接收消息操作添加自定义类型时,我一直收到以下错误:
"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";
}
}
}



发布于 2019-06-02 15:55:40
我遇到了同样的问题,我发现的变通方法如下:
ReceiveRequest中的

发布于 2013-09-28 02:36:14
啊,.Net的奥秘
你必须使用“Serializable”对象。
http://msdn.microsoft.com/en-us/library/ee358739.aspx

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!";
}
}
}https://stackoverflow.com/questions/19057438
复制相似问题