简体   繁体   English

将string []对象从客户端传递到服务wcf

[英]Pass string[] object from client to service wcf

IService1.cs IService1.cs

    [OperationContract]
    string SendMessage(string[] contact, string message,CookieContainer con);

Service1.svc.cs Service1.svc.cs

  string SendMessage(string[] contact, string message,CookieContainer con);
  {
   .... ..... 
   .... 
   ... code
  }

Client Side 客户端

string[] contact;
svc.SendMessageCompleted += new EventHandler<SendMessageCompletedEventArgs>(svc_Send_Sms);
svc.SendMessageAsync(contact, txtsms.Text,con);

this gives error 这给了错误

The best overloaded method match for 'SmsApplication.ServiceReference1.Service1Client.SendMessageAsync(System.Collections.ObjectModel.ObservableCollection, string, System.Net.CookieContainer)' has some invalid arguments 'SmsApplication.ServiceReference1.Service1Client.SendMessageAsync(System.Collections.ObjectModel.ObservableCollection,string,System.Net.CookieContainer)'的最佳重载方法匹配具有一些无效的参数

Argument 1: cannot convert from 'string[]' to 'System.Collections.ObjectModel.ObservableCollection' 参数1:无法从“字符串[]”转换为“ System.Collections.ObjectModel.ObservableCollection”

I believe this solution should work. 我相信此解决方案应该有效。 Right click on the service reference Choose the configure service reference option Under the Data Type section change the Collection type from Array to the type you want in the drop down menu. 右键单击服务引用,然后选择“配置服务引用”选项。在“数据类型”部分下,将“集合类型”从“阵列”更改为下拉菜单中所需的类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM