【发布时间】:2012-09-21 18:57:36
【问题描述】:
MVC 4.0
我在服务上运行以下内容:
[OperationContract(Name = "GetHierarchyReportContents")]
[FaultContract(typeof(InvalidHierarchyNameException))]
[ServiceKnownType(typeof(Node))]
MemoryStream GetContents();
此函数提供一个内存流,其中包含一个节点列表(APINode 因为别名)。本质上,它所做的一切如下:
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream stream = new MemoryStream();
formatter.Serialize(stream, data.ToList<APINode>());
stream.Seek(0, SeekOrigin.Begin);
return stream;
以下是Node的定义,定义在一个命名空间中,防止与其他节点冲突。
[DataContract (Name="Node",Namespace="API")]
[Serializable]
public class Node
{
public Node()
{
}
[DataMember]
public string Name { get; private set; }
}
在我的客户端应用程序上,我执行以下操作:
BinaryFormatter bf = new BinaryFormatter();
List<Node> nodes = (List<Node>) bf.Deserialize(client.GetContents());
我收到错误消息:
找不到程序集'API,版本=1.0.0.0,文化=中性, PublicKeyToken=null'。
我使用wsHttpBinding 进行客户端连接。
我一定遗漏了一些东西,也许命名空间搞砸了。有什么想法吗?
【问题讨论】:
标签: asp.net-mvc wcf