WCF returns ArrayOfKeyValueOfintstringKeyValueOfintstring[] instead of Dictionary and Array instread of List

前端 未结 1 636
北恋
北恋 2020-12-15 02:14

So I\'ve spent the last several hours investigating this issue and it is clear that I am not the only one. Why are my Dictionaries and Lists being returned as Arrays?

相关标签:
1条回答
  • 2020-12-15 02:35

    Well I found out what was causing the serialization to be so crude.

    In my ServiceContract I had the following:

    [OperationContract]
    List<DataTable> ShowTables();
    [OperationContract]
    DataTable FetchContacts(string filter = "All");
    [OperationContract]
    DataTable FetchUsers();
    [OperationContract]
    DataTable FetchDrops();
    

    After commenting this out and recompiling my WCF Service Library, I found that everything serialized/ deserialized appropriately when generating the proxy.

    It seems that when svcutil.exe encounters something that it does not know how to serialize then all bets are off. Quite literally it will ignore your commands/settings and serialize everything as gibberish like ArrayOfKeyValueOfinttringKeyValueOfintstring. So if you receive this error, you should ask yourself if svcutil.exe is able to properly serialize all of what you are returning.

    I hope the identification of the source of my issue will help others in the future.

    0 讨论(0)
提交回复
热议问题