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

168 Views Asked by At

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);
1

There are 1 best solutions below

2
On

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)
{
   ...
}