Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 使用WinForms中列表(字符串)的WCF返回值_Vb.net_Winforms_Wcf - Fatal编程技术网

Vb.net 使用WinForms中列表(字符串)的WCF返回值

Vb.net 使用WinForms中列表(字符串)的WCF返回值,vb.net,winforms,wcf,Vb.net,Winforms,Wcf,我刚刚开始摆脱Web服务,转而实现WCF。但是,当我尝试添加以下带有ListOf字符串返回值的方法时,我的WCF ServiceReference(已成功添加)在我的WinForms客户端应用程序代码中变得无法读取。i、 e.它没有定义 场景非常简单: 我正在创建名为ServerMessages的OperationContract,其中包含字符串返回值列表。 这是接口: <ServiceContract()> Public Interface ICommunicationHandle

我刚刚开始摆脱Web服务,转而实现WCF。但是,当我尝试添加以下带有ListOf字符串返回值的方法时,我的WCF ServiceReference(已成功添加)在我的WinForms客户端应用程序代码中变得无法读取。i、 e.它没有定义

场景非常简单: 我正在创建名为ServerMessages的OperationContract,其中包含字符串返回值列表。 这是接口:

<ServiceContract()>
Public Interface ICommunicationHandler
<OperationContract()>
    Function ServerMessages() As List(Of String)
End Interface
这是我的客户端应用程序代码:

Dim locServ As New LocalReference.CommunicationHandlerClient
TextBox1.Text += "First Server Messages:" & vbLf & locaServ.ServerMessages(0) 
我尝试从项目中删除服务引用并重新添加,但这并没有解决问题。另一方面,删除特定的方法ServerMessages会使ServiceReference在我的代码中再次可用。我甚至尝试通过添加以下属性在服务接口中定义ListOf String类型:

<ServiceKnownType(GetType(List(Of String)), ServiceContract()>
但一切都没有改变

编辑

我在客户端应用程序错误窗口中注意到以下警告:

警告2自定义工具警告:无法导入wsdl:端口详细信息:存在 导入wsdl:端口依赖的wsdl:绑定时出错 在…上XPath到wsdl:绑定: //wsdl:definitions[@targetNamespace=]/wsdl:binding[@name='BasicHttpBinding_ICommunicationHandler'] XPath到错误源: //wsdl:definitions[@targetNamespace=]/wsdl:service[@name='CommunicationHandler']/wsdl:port[@name='BasicHttpBinding\u ICommunicationHandler']D:\WCTApp\service References\LocalReference\Reference.svcmap


提前感谢。

通过取消选中我的客户端应用程序的WCF ServiceReference配置中的[Reuse types in referenced Assembly]来解决我的问题。谢谢史蒂夫让我再检查一下

在本例中,问题是我在服务Google Drive references中添加了一些引用,而这些引用在我的应用程序中没有定义,因此导致ServiceReference无法正确读取服务。既然我决定不使用这些引用,我就应该从我的客户端应用程序和WCF服务中删除它们。现在我停止在我的客户机应用程序中使用这些引用,一切都正常工作了


这是我的错误,但可能其他人也会遇到同样的问题,并发现这种情况很有帮助。

您是否在web参考的配置中将收集类型设置为System.Collection.Generic.List?是的,Steve。我也试过了。但不幸的是,这并没有起到任何作用。我在原始帖子中添加了一条警告消息,我在客户端应用程序错误列表中注意到了这条消息。
<ServiceKnownType(GetType(List(Of String)), ServiceContract()>