I need to find a way to return a set of data in a WCF OperationContract. The data I am returning can be any rows and any number of columns.
My WCF (library) is hosted by a Windows Service. Thus far I get the usual error "Service cannot be started. System.NotSupportedException: Multi-dimensional arrays are not supported." I have tried jagged arrays, string[], DataSet, DataTable...any suggestions on how to return rows and columns of data?
FYI - Clearly I am new at WCF so please be gentle :-)
Here is some of my WCF Library code (some of it):
[ServiceContract]
public interface IOperationsDataService
{
[OperationContract]
ReturnResults ExecuteStoredProcedure(string connectionKey, string procedureName, SpParameter[] spParameter, bool pleaseReturnRecords);
}
[DataContract]
public class ReturnResults
{
[DataMember]
public String[][] ReturnedResultsArray { get; set; }
}
*** Here is the entire error from the Event Viewer:
Service cannot be started. System.NotSupportedException: Multi-dimensional arrays are not supported.
at System.Runtime.Serialization.CollectionDataContract.CollectionDataContractCriticalHelper..ctor(Type type)
at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.CreateDataContract(Int32 id, RuntimeTypeHandle typeHandle, Type type)
at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.GetDataContractSkipValidation(Int32 id, RuntimeTypeHandle typeHandle, Type type)
at System.Runtime.Serialization.XsdDataContractExporter.GetSchemaTypeName(Type type)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.ValidateDataContractType(Type type)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.CreatePartInfo(MessagePartDescription part, OperationFormatStyle style, DataContractSerializerOperationBehavior serializerFactory)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.CreateMessageInfo(DataContractFormatAt...
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="HostedService" />
<EventID Qualifiers="0">0</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2013-01-04T18:52:14.000000000Z" />
<EventRecordID>4359</EventRecordID>
<Channel>Application</Channel>
<Computer>ntvdeva235.apsc.com</Computer>
<Security />
</System>
<EventData>
<Data>Service cannot be started. System.NotSupportedException: Multi-dimensional arrays are not supported.
at System.Runtime.Serialization.CollectionDataContract.CollectionDataContractCriticalHelper..ctor(Type type)
at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.CreateDataContract(Int32 id, RuntimeTypeHandle typeHandle, Type type)
at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.GetDataContractSkipValidation(Int32 id, RuntimeTypeHandle typeHandle, Type type)
at System.Runtime.Serialization.XsdDataContractExporter.GetSchemaTypeName(Type type)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.ValidateDataContractType(Type type)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.CreatePartInfo(MessagePartDescription part, OperationFormatStyle style, DataContractSerializerOperationBehavior serializerFactory)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.CreateMessageInfo(DataContractFormatAt...</Data>
</EventData>
</Event>