Silverlightt WCF 支持 Prism 服务
我需要使用 WCF 编写 Silverlight 应用程序。
我还需要使用依赖注入来访问另一个库中的此服务。
(我添加了启用 Silverlight 的 WCF 服务)
问题在于尝试使用依赖注入(在本例中为 Prism/MEF)。当我创建一个包含该服务接口的 Silverlight 共享库时,我无法在 ASP.Net 项目中添加该库,因为它是 Silverlight 库。如果我创建一个非 Silverlight 库,我无法将该库添加到其他项目以共享该通用接口。
基本上我需要一个我认为可以在 Silverlight 中的项目之间共享的库,以便我可以执行此服务注入。
任何信息表示赞赏
Im required to write a Silverlight application using WCF.
I'm also required to use Dependency Injection to gain access to this service in another library.
(I add a Silverlight enabled WCF Service)
The problem is in trying to use Dependency Injection (Prism/MEF in this case). When I make a Silverlight Shared library that will have interfaces for this service, I cannot add this library in the ASP.Net project due to the fact that it is Silverlight library. If I make a non-Silverlight library I cannot add that library to other projects to share that common interface.
Basically I need a library I think to share between projects in Silverlight so I can do this service injection.
Any information is appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 slugster 所说 - 这是通过链接到 silverlight 库中的 Windows 库文件来完成的。
您可以按照此处所述进行操作: http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/01/20/linking-files-in-visual-studio.aspx
我只是想添加..既然你去了那里 - 你需要的是另一个框架/技术。通常,您谈论的那些类依赖于仅存在于 Windows 或仅 silverlight 世界中的其他类/命名空间。然后您需要通过线路传输对象数据。
Microsoft 对此的解决方案是 RIA 服务。它的作用 - 它获取您的 Windows 类并在 Silverlight 端生成代理类。正是您所需要的。它与 WCF 服务配合使用。
有 CSLA 和 DevForce 等 3rd 方解决方案。
我使用 DevForce,它会自动执行许多操作,但不是生成代理类 - 它会创建像您想要的那样的链接。
As slugster said - this done via linking to windows library files from silverlight library.
You do it as described here: http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/01/20/linking-files-in-visual-studio.aspx
I just wanted to add.. Since you go there - what you need is another Framework/Technology. Usually those classes you talking about depend on other classes/namespaces that live in windows only or silverlight only world. And then you need to transfer object data via wire.
Microsoft's solution to this - RIA Services. What it does - it takes your Windows classes and generates proxy classes on Silverlight side. Kind of what you need. And it works with WCF services.
There is 3rd party solutions like CSLA and DevForce.
I use DevForce and it does many things automatically, but instead of generating proxy classes - it creates links just like what you want.
无论您是否意识到,您的问题都是这个问题的重复: WCF 服务和 Silverlight 应用程序之间共享数据对象 虽然没有以相同的方式询问,但答案是相同的。
您需要创建一个单独的项目,并将代码文件(作为链接)从一个项目共享到另一个项目。您的问题是 Silverlight 项目是针对与 ASP.NET/WCF 项目不同的运行时进行编译的。由于它们无法引用公共库,因此链接上述共享文件是在针对不同运行时的两个项目之间共享代码的最简单方法。
Whether you realise it or not, your question is a duplicate of this one: Shared data object between WCF service and Silverlight app While not asked the same way, the answer is the same.
You need to create a separate project, and share the code files (as links) from one project to the other. Your problem is that the Silverlight project is compiled for a different runtime to the ASP.NET/WCF project. Because they cannot reference a common library, linking the shared files as mentioned is the easiest way to share code between the two projects targetting different runtimes.