Silverlight RIA 服务 - 客户端中服务器端项目的引用命名空间
我不知道如何标题这个问题。我正在创建一个 RIA 服务驱动的 Silverlight 4 应用程序。
我从 Silverlight 导航应用程序开始。我希望能够将解决方案中服务器端项目的命名空间添加到解决方案客户端项目中的 XAML 文件中。
当您创建 Silverlight 业务应用程序时,在创建解决方案时,两个项目之间就会建立“连接”,这将允许您执行我在上一段中解释的操作。
有没有办法修改我的 Silverlight 导航应用程序,以便我可以将解决方案中服务器端项目的命名空间添加到客户端项目中的 XAML 文件中?
I wasn't sure how to title this question. I'm creating an RIA Services driven Silverlight 4 application.
I started out with a Silverlight Navigation Application. I'd like to be able to add a namespace from the server side project in my solution into a XAML file in the client project of the solution.
When you create a Silverlight Business Application, the 'connection' is made between the two projects when the solution is created that will allow you to do what I explained in the previous paragraph.
Is there a way to modify my Silverlight Navigation Application so that I can add a namespace from the server side project in my solution into a XAML file in the client project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么要向客户端项目添加服务器端命名空间?您是否希望能够在客户端项目中使用服务器项目中定义的类型?
如果是这样,最简单的方法是将“.shared”添加到服务器项目中相关文件的名称中。与“MyCoolType.shared.cs”一样,当 RIA 服务看到“.shared”时,它会在代码生成期间将该类型复制到客户端项目。
您实际上最终得到了两种不同的类型,一种在服务器项目中定义,一种在客户端项目中定义,但从您的角度来看,它感觉像是一种类型。
Why do you want to add a server side namespace to your client side project? Do you want to be able to use a type defined in the server project in your client project?
If so, the easiest way to do this is to add ".shared" to the name of the file in question in the server project. Like "MyCoolType.shared.cs", when RIA services sees that ".shared", it will copy that type over to the client project during its code generation.
You really end up with two different types, one defined in the server project and one defined in the client project, but from your perspective it feels like one type.
解决方案是将客户端项目属性(Silverlight 选项卡)中的 WCF RIA 服务链接设置为服务器端项目。
The solution is to set the WCF RIA Services link in the client side project's properties (Silverlight tab) to the server side project.