WCF pass integer array through object parameter

123 views Asked by At

I am trying to send an int array over a WCF connection using a method call that takes an object. But i am receiving this error

'System.ServiceModel.CommunicationException' in mscorlib.dll ("There was an error while trying to serialize parameter http://tempuri.org/:Data. The InnerException message was 'Type 'System.Object[]' with data contract name 'ArrayOfanyType:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Consider using a DataContractResolver if you are using DataContractSerializer or add any types not known statically to the list of known types.

Here is my interface

<ServiceContract()>
Public Interface myServiceContract
    <OperationContract(IsOneWay:=True)>
    Sub DoStuff(ByVal str As String, ByVal Data As Object)
End Interface

Here is how I'm using the interface

Dim data(2) As Object
data(0) = 20
data(1) = 22
data(2) = 255
remoteContext.DoStuff("Hello", data) ' this line throws the exception

How do i get the data array to be sent over the wcf connection without it throwing an exception?

This is com exposed so changing the parameter type would cause me a lot of trouble.

0

There are 0 answers