tags:

views:

552

answers:

2

Hi all,

I've tried to look everywhere to find an answer to this problem, but no luck.. so i've turned to the experts here for some help!

I have a wcf service in c# is fully working... it does some magic and it sends a List to the server. The server can read these PO objects fine. However, i now have a problem when inside PO there is a list...

public class PO
{
    /* omitted */
    [DataMember]
    public Object BasicContent { get; set; }
}

When BasicContent is a List i get the following error:

"There was an error while trying to serialize parameter http://tempuri.org/:objectToPersist. The InnerException message was 'Type 'System.String[]' with data contract name 'ArrayOfstring:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details."

I have tried adding [ServiceKnownType(typeof(List<string>))] or [ServiceKnownType(typeof(string[]))] all over the place by no avail...

Can anyone give me a hand on what I can do?

A: 

Try adding a ServiceKnownType for just String

[ServiceKnownType(typeof(string))]
JaredPar
I can send strings over - they work in the 'BasicContent' bit OK
simonjpascoe
+1  A: 

Have you tried changing the type to String or String[] or List depending on what your setting it to.

d1k_is
tried, didnt seem to work as over the write i think that the string[] and list<string> are both handled as ArrayOfString
simonjpascoe