WCF返回而不是List数组即使集合类型== Generic.List数组、而不是、类型、WCF

2023-09-04 00:21:14 作者:干净的

我有项目,该项目是一个WCF服务(.SVC),看起来像下面这样:

I have project that is a WCF service (.svc) that looks like the following:

[ServiceContract]
public interface IAdminQueries
{

    [OperationContract]
    List<Color> GetColors();

    [OperationContract]
    List<PhoneType> GetPhoneTypes();

    ...

我还有一个项目是一个Web应用程序。我添加一个服务引用上述服务。单击高级按钮,并从集合类型选择Generic.List。一切似乎理所应当的。

I have another project that is a Web Application. I add a Service Reference to the above Service. Click the Advanced button and select Generic.List from the Collection Type. All seems as it should be.

我然后建立并获得与下面的code错误:

I then build and get errors with the code below:

    AdminQueriesClient db = new AdminQueriesClient();
    List<Color> s = db.GetColors();

下面是错误:

    Cannot implicitly convert type 'DogLicenseBO.DogLicenseServiceReference.Color[]' to 'System.Collections.Generic.List<DogLicenseBO.DogLicenseServiceReference.Color>'

时的东西挡住或覆盖正常的序列化/反序列化进程?

Is something blocking or overriding the normal serialization/deserialization process?

修改 我把它再次合作。不过,我想我需要什么,我拿出虽然。

EDIT I have it working again. However, I think I need what I took out though.

的修订的 这一切都开始因为我有一个VS 2012项目转换为VS 2010手,我用一个伟大的功能,但必须降级。无论如何,在VS 2012的参考值之一Newtonsoft.Json。我使用,在几个地方。当我把那在VS 2010和重建,一切正常。现在,我需要更多的测试,看看我能使用什么JSON序列化,而不是Newtonsoft。

The Fix This all started because I have to convert a VS 2012 project to VS 2010. Lots a great features I was using but have to downgrade. Anyway, one of the References in VS 2012 is Newtonsoft.Json. I am using that in a couple of places. When I took that out in VS 2010 and rebuilt, everything worked. Now I need more testing to see what I can use for the Json serialization instead of Newtonsoft.

有什么建议?

推荐答案

答案是在所谓的修补程序中的编辑后,我原来的职位。不过,我可能也张贴在这里了。

The Answer is up in my original post after the EDIT called Fix. But I may as well post it here too.

这一切开始,因为我有一个VS 2012项目转换为VS 2010手,我用一个伟大的功能,但必须降级。无论如何,在VS 2012的参考值之一Newtonsoft.Json。我使用,在几个地方。当我把那在VS 2010和重建,一切正常。现在,我需要更多的测试,看看我能使用什么JSON序列化,而不是Newtonsoft。

This all started because I have to convert a VS 2012 project to VS 2010. Lots a great features I was using but have to downgrade. Anyway, one of the References in VS 2012 is Newtonsoft.Json. I am using that in a couple of places. When I took that out in VS 2010 and rebuilt, everything worked. Now I need more testing to see what I can use for the Json serialization instead of Newtonsoft.