简体   繁体   中英

Defining a function with argument of type System.Array in ASMX C# web service

I am getting the following error You must implement a default accessor on System.Array because it inherits from ICollection

Following is my source code,

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

I will access this webservice from the client as,

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

I believe this means that the type of the object needs to be known at compile time in order to use the default accessor (which basically means the ability to access an item in the array). Usually due to serialization. Try using an ArrayList<type> or just a List<type> instead.

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

or...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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