应可在 Silverlight 中访问的 DTO 的 Visual Studio 项目类型
我应该选择什么 VS 项目类型,以便在我的 Silverlight 项目和 WCF 服务项目中都可以访问我在其中创建的数据传输对象。
(我希望能够重用我在两个项目中定义的 DTO,而不是在创建对 WCF 服务的 Web 服务引用时让 VS 在我的 Silverlight 项目中生成新的集合)。
IE,我的问题是该项目可以是 Windows 类库,还是应该是 Silverlight 类库(以便在我的 Silverlight 项目和 WCF 项目中引用它)。
What VS project type should I choose so that the data-transfer-objects that I create in it can be accessible in both in my Silverlight project as well as my WCF service project.
(I want to be able to reuse the DTOs that I define in both projects instead of having VS generate a new set in my Silverlight project when I create a web-service reference to the WCF service).
IE, my question is can the project be a Windows class library, or should it be a Silverlight class library (so as to reference it in both my Silverlight project as well as the WCF project).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有三个主要选项:
创建两个类库项目(一个针对 Silverlight,另一个针对 .NET Framework),并在它们之间共享文件,正如我在本文中讨论的那样:http://www.silverlightshow.net/items/Building- a-Silverlight-Line-Of-Business-Application-Part-3.aspx
将您的类库创建为 Silverlight 类库。 Framework 的应用程序(例如 WCF 服务)可以(通常)引用面向 Silverlight 运行时的类库。
尝试便携式库工具(目前处于测试阶段):http://blogs.msdn.com/b/sburke/存档/2011/01/23/3-screen-coding-is-here-portable-library-tools-allow-you-to-target-multiple-net-platforms-with-one-binary.aspx< /p>
有您考虑过使用 RIA 服务(或 WCF 数据服务)而不是普通的 WCF 服务吗? RIA 服务/WCF 数据服务可以为您处理这个问题,并添加其他强大的功能。
希望这有帮助......
克里斯·安德森
You've got three main options:
Create two class library projects (one targeting Silverlight, the other the .NET Framework), and share the files between them, as I discuss in this article: http://www.silverlightshow.net/items/Building-a-Silverlight-Line-Of-Business-Application-Part-3.aspx
Create your class library as a Silverlight class library. Silverlight applications can't reference class libraries that target the full .NET Framework, but applications targeting the full .NET Framework (such as you WCF Service) can (generally) reference class libraries that target the Silverlight runtime.
Try out the Portable Library Tools (currently in beta): http://blogs.msdn.com/b/sburke/archive/2011/01/23/3-screen-coding-is-here-portable-library-tools-allow-you-to-target-multiple-net-platforms-with-one-binary.aspx
Have you thought of using RIA Services (or WCF Data Services) instead of a plain WCF service? RIA Services / WCF Data Services handles this problem for you, and adds other great functionality into the mix.
Hope this helps...
Chris Anderson