Why am I getting this WCF Error Message?

后端 未结 4 1285
长发绾君心
长发绾君心 2021-01-12 04:54

I am getting the error below when I call my WCF service. What am I missing here?

\'System.String[]\' with data contract name
\'ArrayOfstring:http://schemas.         


        
4条回答
  •  一个人的身影
    2021-01-12 05:29

    From what I gather, you have a WCF function that has a parameter named 'myEntity'. I'm assuming that the type of myEntity is a user-defined class and is adorned with the DataContract attribute, as it should be. I'm also assuming that the type of myEntity has a member field that is a string array. Let's assume that all of this is true (again, it'd be really helpful if you could post your code).

    Ordinarily, string arrays, i.e., string[], will serialize just fine. But, in some cases (see here and here), you may have to add it to the list of known types in order for WCF to serialize everything correctly.

    To do this, add the following:

    [DataContract]
    [KnownType(typeof(string[]))]
    public class YourClassNameHere
    {
    }
    

提交回复
热议问题