# .NET and More > WPF, WCF, WF >  [RESOLVED] Unable to cast object of type 'System.Collections.Generic.List`1[System.String]' to t

## sapator

Unable to cast object of type 'System.Collections.Generic.List`1[System.String]' to type 'WindowsApplication1.ServiceReferenceVSAPI.ArrayOfString'.
What is going on here? I cannot find a simple viable solution on Google.

Here is my WCF class:


```
Namespace MyTypes
    <DataContract(), KnownType(GetType(List(Of String))), XmlSerializerFormat()>
    <Serializable()>
    Public Class setorder
        <DataMember()>
        Public Property LoyaltyUserName() As String
            Get
                Return m_LoyaltyUserName
            End Get

            Set(value As String)
                m_LoyaltyUserName = value
            End Set
        End Property
        <DataMember()>
        Private m_LoyaltyUserName As String
        <DataMember()>
        Public Property LoyaltyPassword() As String
            Get
                Return m_LoyaltyPassword
            End Get
            Set(value As String)
                m_LoyaltyPassword = value
            End Set
        End Property
        <DataMember()>
        Private m_LoyaltyPassword As String

        <DataMember()>
        Public Property seats As List(Of String)
            Get
                Return m_seats
            End Get
            Set(value As List(Of String))
                m_seats = value
            End Set
        End Property
        <DataMember()>
        Private m_seats As List(Of String)
    End Class
End Namespace
```

here is the client code:


```
Dim vsetorder As New ServiceReferenceVSAPI.setorder        
        vsetorder.LoyaltyPassword = "asd"
        vsetorder.LoyaltyUserName = "g"
        Dim seats As New List(Of String)
        seats.Add("3")



        vsetorder.seats = seats
```

And i get the error on the vsetorder.seats = seats line.

I have tried every single model change on the wcf service (i thing system.collection.generic list is the most proper?) i have added and remove xml serialization features

alover and nothing works?

Any help?

P.S. I could care less if i use a list of or an arraylist but nothing works

----------


## sapator

Had to remove XmlSerializerFormat() from service contract. 
Seems if you declare this to 2 places it get crazy results! MS?!!!

----------


## techgnome

It's been a while but if I remember right, when exposing lists for xml serialization, they need to be marked up with xmlArray you then define what the individual elements are called for each item in the list.

-tg

----------


## sapator

Actually, this does the trick as shown in the OP :


```
 <DataContract(), KnownType(GetType(List(Of String))), XmlSerializerFormat()>
```

After that everything seems to fall into place and i don't need to mark anything else. It will work for simple arrays, arraylists and list(of), all fine.
Go figure :/

----------

