WCF 服务和 Silverlight 应用程序之间的共享数据对象 [英] Shared data object between WCF service and Silverlight app

查看:29
本文介绍了WCF 服务和 Silverlight 应用程序之间的共享数据对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过 WCF Web 服务公开的自定义数据实体(数据对象).WCF 服务位于 Web 应用程序中.然后我有一个 Silverlight 应用程序,其中包含对该 WCF 服务的服务引用.当我添加服务引用时,会生成一个代理,其中包含自定义数据实体的一个版本.

I have a custom data entity (data object) that is exposed via a WCF webservice. The WCF service lives in a web application. I then have a Silverlight application with a service reference to that WCF service. When i add the service reference a proxy is generated, and that includes a version of the custom data entity.

我应该如何构建我的代码,以便在一个地方声明数据实体,并在包含 WCF 服务的项目和引用它的任何 Silverlight 应用程序之间共享?我想消除使用代理生成的数据实体的版本.

How should i structure my code so that the data entity is declared in one place, and shared amongst the project containing the WCF service and any Silverlight applications that reference it? I want to eliminate the version of the data entity that is generated with the proxy.

推荐答案

有一个很好的例子 Pete Brown 在这里如何做到这一点.使用这种方法,您可以在 Silverlight 客户端和 WCF 服务中使用相同的类,而无需使用生成的对象.

There is a good example of how to do this here by Pete Brown. Using that approach you can use the same classes in both the Silverlight client and in the WCF service without having to use the generated objects.

这篇关于WCF 服务和 Silverlight 应用程序之间的共享数据对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆