在 WCF 和 WCF 之间动态公开服务引用银光

发布于 2024-11-03 15:48:36 字数 436 浏览 4 评论 0原文

几天来,我一直在用头撞砖墙,试图解决我在使用 WCF 服务和 Silverlight 时遇到的问题。

我的问题是我有 5 个 Silverlight 项目模块,我将它们动态读取到一个主 Silverlight 应用程序中。这些模块中的每一个都有自己的业务层和 DAL,因此它会对其 WCF 服务进行自己的调用,但是当我将模块加载到并尝试运行 WCF 命令时,我收到一条错误消息,指出我的 ServiceReference 不存在,这是因为该服务是模块“ServiceReference.config”的一部分,而不是主项目服务参考的一部分。

我是否可以动态获取 Master Silverlight 项目以获取 ChannelFactory 列表,然后创建通道并读取所有元数据并完全摆脱服务引用?您如何避免使用服务参考?

非常感谢您的所有帮助,我认为我对此感到疯狂。

谢谢

罗比

For days i have been banging my head against a brick wall, trying to work out a problem that i am having with WCF Services and Silverlight.

My problem is that i have 5 Silverlight Project modules that i read dynamically into one Master Silverlight Application. Each one of these modules has their own Business Layer and DAL so it makes its own calls to its WCF Services, yet when I load the modules into and try to run a WCF command i get an error message saying that my ServiceReference does not exist, this is because the Service is part of the Modules "ServiceReference.config" isntead of the Master projects Service Reference.

Is there are away that i can dynamically get the Master Silverlight project to take in a list of ChannelFactory's and then create the channels and read in all the metadata and get rid of the Service Refences totally? How do you get around having to use the Service References?

All of your help is greatfully appreciated, i think im going insane over this one.

Thanks

Robbie

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁吢 2024-11-10 15:48:36

是的,你可以这样做。您可以复制生成的文件“Reference.cs”,为此,您必须:

  1. 显示项目中的所有文件。
  2. 展开服务引用并查找 Reference.cs。

现在您可以复制它并将其作为普通类添加到您的项目中,并删除应用程序的服务引用。对于 ChannelFactory,是的,您可以通过以下代码创建:

   ChannelFactory<IServiceContract> factory = new ChannelFactory<IServiceContract>(endpoint);
   IServiceContract channel = factory.CreateChannel();

Yes you can do that. You can copy the generated file "Reference.cs", to do this, you have to:

  1. Show all files in your project.
  2. Expand the service reference and look for the Reference.cs.

Now you can copy this and add to your project as a normal class and remove the service reference of your application. For the ChannelFactory, yes you can create through this code:

   ChannelFactory<IServiceContract> factory = new ChannelFactory<IServiceContract>(endpoint);
   IServiceContract channel = factory.CreateChannel();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文