我正在尝试使用采用对象的方法调用通过 WCF 连接发送一个 int 数组。但我收到此错误
'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.
这是我的界面
<ServiceContract()>
Public Interface myServiceContract
<OperationContract(IsOneWay:=True)>
Sub DoStuff(ByVal str As String, ByVal Data As Object)
End Interface
这是我使用界面的方式
Dim data(2) As Object
data(0) = 20
data(1) = 22
data(2) = 255
remoteContext.DoStuff("Hello", data) ' this line throws the exception
如何在不引发异常的情况下通过 wcf 连接发送数据数组?
这是 com 暴露的,因此更改参数类型会给我带来很多麻烦。