I cannot return an array from a WCF service. Any values assigned in my service are not returned to the client.
Here is my service interface:
public interface IMyService
void ReturnArray(byte a);
byte ReturnArrayEx(byte a);
Here is my concrete service class:
public class MyService : IMyService
public void ReturnArray(byte a)
a = 11;
a = 21;
public byte ReturnArrayEx(byte a)
byte temp = a;
a = 33;
a = 44;
I am self-hosting my service with the following code:
BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.None; // None is the default
address = @"http://localhost:12345/MyService";
channelFactory = new ChannelFactory<ChannelTest.IMyService>(binding, address);
m_service = channelFactory.CreateChannel();
I invoke my service as follows:
byte myArray = new byte;
On return, my array still contains its default zeroes rather than 11 and 21 assigned in the service.
An article suggested that the second method (ReturnArrayEx) is the way to return arrays, but there has to be a better way.
Do I need to assign more KnownTypes? Are there other attributes I must set? Is there a setting somewhwere I need to change?