gpt4 book ai didi

c# - 函数在我的 WFC 服务和客户端中返回的问题

转载 作者:太空宇宙 更新时间:2023-11-03 21:13:55 24 4
gpt4 key购买 nike

我在我的客户端中定义了一些函数,例如

[OperationContract]
List<CustomObject> GetObject(string id);

如果我尝试从我的界面调用此函数时:

List<CustomObject> result = cvs.GetObject(5);我得到一个错误,我必须做的是 CustomObject[] result = cvs.GetObject(5);

另一个例子是当我定义一条消息时:

[MessageContract]
public class TestRequest
{
[MessageBodyMember]
public Int64 Id;

[MessageBodyMember]
public int row;
}

和我的界面的功能:

[OperationContract]
ResponseMessage GetMessage(TestRequest req);

当我尝试以同样的方式使用这么多时:

TestRequest req = new TestRequest();
req.Id = 2;
req.row = 1;
ResponseMessage resp = cvs.GetMessage(req);

我得到 there is no overload for method that takes one argument消息。

下面是引用文件的相关部分

[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
ResponseMessage MyService.GetMessage(TestRequest request)
{
return base.Channel.GetMessage(request);
}

public string GetMessage(long Id, int row, out long Length, out string Message, out System.IO.MemoryStream ReportMemoryStream)
{
TestRequest inValue = new ResponseMessage();
inValue.Id = Id;
inValue.row= row;
ResponseMessage retVal = ((MyService)(this)).GetMessage(inValue);
Length = retVal.Length;
Message = retVal.Message;
ReportMemoryStream = retVal.ReportMemoryStream;
return retVal.FileName;
}

为什么会发生客户端和 wfc 服务之间的断开连接,我该如何解决。

最佳答案

这里已经有一个问题和一些答案来解释您在客户端和服务之间所说的“断开连接”:

Why does WCF return myObject[] instead of List like I was expecting?

希望这就是您所追求的。

关于c# - 函数在我的 WFC 服务和客户端中返回的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35775652/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com