【问题标题】:Defining a function with argument of type System.Array in ASMX C# web service在 ASMX C# Web 服务中使用 System.Array 类型的参数定义函数
【发布时间】:2014-11-08 14:27:59
【问题描述】:

我收到以下错误 You must implement a default accessor on System.Array because it inherits from ICollection

以下是我的源代码,

 public string extractOutput(ref System.Array data)
    {
       obj.extractOuput(ref data);
    }

我将从客户端访问此网络服务,

System.Array bytes = System.IO.File.ReadAllBytes("path_to_file");
clientObj.extractOutput(ref bytes);

【问题讨论】:

  • 数组应该是字节[]

标签: c# web-services asmx system.array


【解决方案1】:

我相信这意味着需要在编译时知道对象的类型才能使用默认访问器(这基本上意味着能够访问数组中的项目)。通常是由于序列化。尝试使用ArrayList<type> 或仅使用List<type>

public string extractOutput(ref ArrayList<SomeType> data)
{
   ...
}

或者...

public string extractOutput(ref List<SomeType> data)
{
   ...
}

【讨论】:

  • 它基本上从作为项目引用添加的 dll 中调用一个函数。因此我得到没有匹配的重载函数可用。
  • 应该是字节[]而不是数组
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多