如何配置WCF在一个单独的dll项目 [英] How to configure WCF in a separate dll project

查看:684
本文介绍了如何配置WCF在一个单独的dll项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Web应用程序(ASP.NET 3.5),将消耗了许多Web服务。我创建了一个单独的DLL项目的每个Web服务:这些项目包含了服务的参考和客户端code。

I'm developing a web application (ASP.NET 3.5) that will consume a number of web services. I have created a separate dll-project for each web service: these projects contains the service reference and client code.

不过,调用网站必须有< system.serviceModel> 信息(<绑定> <客户端>在它的web.config 节点),即使这些信息也是DLL的app.config文件!我曾尝试过复制serviceclass.dll.config到网站的bin目录,但这并没有帮助。

However, the calling website MUST have the <system.serviceModel> information (the <bindings> and <client> nodes) in it's web.config, even though this information is also in the dll's app.config file! I have tried copying the serviceclass.dll.config over to the bin directory of the website, but this didn't help.

有没有什么办法来集中WCF客户端的配置?

Is there any way to centralize the configuration of a WCF client?

推荐答案

我只有有限的WCF的经验,所有的BasicHTTP绑定。但我对WCF的XML文件过敏,并设法避免他们迄今。我一般不建议更换这一点,但我把配置的详细信息在我的应用程序的现有配置存储,然后通过程序应用它们。例如。随着Web服务代理我用的构造为带'bindings'and'端点'和编程应用设置的绑定和放大器客户端;端点。

I've only limited WCF experience, all with BasicHTTP bindings. But I'm allergic to WCF's xml files and have managed to avoid them thus far. I don't recomend this generally but I put the configuration details in my apps existing configuration store and then apply them programatically. E.g. With a Web service proxy I use the constructor for the Client that takes 'bindings'and 'endpoint' and programatically apply the settings to the bindings & endpoint.

一个更高贵的解决方案似乎这里descibed:<一href=\"http://www.paraesthesia.com/archive/2008/11/26/reading-wcf-configuration-from-a-custom-location.aspx\"相对=nofollow>阅读WCF配置从自定义位置,但我还没有尝试过。

A more elegent solution appears to be descibed here: Reading WCF Configuration from a Custom Location, but I haven't tried it yet.

这篇关于如何配置WCF在一个单独的dll项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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