WCF Service Reference as array vs. List

We have an asp website with service references to a WCF project. We have set the configuration of the service collection type to System.Collection.Generic.List, yet the reference.cs is showing arrays. We can see

<CollectionMappings>
      <CollectionMapping TypeName="System.Collections.Generic.List`1" Category="List" />
</CollectionMappings>

in the reference.svcmap.

We would prefer to work with List if possible. What are we missing? Why is it insisting to build a reference full of arrays when it has been told to convert them to Lists?

Visual Studio 2019, asp.net 4.8

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Set in the Add Service Reference tool:

WCF Service Reference as array vs. List<T>

WCF Service Reference as array vs. List<T>

Finally, apply this setting to generate a proxy class.

Method 2

For those that run across this: It’s actually an “undocumented feature” of visual studio… thank you Microsoft. When using the XML Serializer instead of the DataContract serializer, the service connection tool in visual studio doesn’t create the classes as requested. You can manually alter the reference.cs, or move to webAPI using .net core.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x