库中的WCF客户端,可通过网站和控制台应用程序进行访问 [英] WCF Client in a library which is accessed by a Website and a Console app

查看:97
本文介绍了库中的WCF客户端,可通过网站和控制台应用程序进行访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行WCF服务,并且我的客户端代码位于库中.

I have a WCF service running, and my client code lives in a library.

此库需要由Windows应用程序和网站访问.这是我碰到砖墙的地方.

This library needs to be accessed by a Windows Application and a Website. This where I am hitting a brick wall.

当Windows应用程序使用该库时,一切正常(我通过构造函数传递了端点名称).

When the Windows application uses the library, everything works (I pass the endpoint name in through the constructor).

一旦我的Web应用程序尝试使用该库,就找不到一个异常通知我端点,或者找不到配置文件.

As soon as my web application attempts to use the library, an Exception informing me the Endpoint cannot be found, or the configuration file cannot be found.

我怀疑文件有问题.我什至将system.serviceModel部分复制到web.config中,但没有区别.

I suspect the file is the problem. I even duplicated the system.serviceModel section into the web.config but no difference.

这可能是由于app.config使用可执行文件名称来访问文件,并且在网站下没有可执行文件名称(即生成的文件)

Could this be due to the fact the app.config uses the executable name to access the file, and under a website, there is no executable name (ie its generated)

我无法将客户代码打包到库中并允许从网站访问它,这似乎很奇怪.

It seems strange that I cannot package up my client code into a library and allow it to be accessed from a web site.

如果有人对我在做什么错的建议或替代方法,将不胜感激.

If anyone has a suggestion of what I am doing wrong, or an alterantive approach, it would be appreciated.

预先感谢

史蒂芬

 

 

推荐答案

史蒂文

在Web应用程序中使用WCF客户端库时,WCF客户端将尝试从Web应用程序的web.config文件中读取端点配置.请确保在web.config文件中具有端点配置.

When utilizing wcf client library in web application, the wcf client would try to read endpoint configuration from the web app's web.config file. Please make sure you have the endpoint config in web.config file.

如果问题仍未解决,请共享您使用wcf客户端初始化的代码和< system.servicemodel>部分,我们将帮助您找到根本原因.

If problem not solved, please share the code which you initialize wcf client and the <system.servicemodel> section, we'll help to locate the root cause.

谢谢


这篇关于库中的WCF客户端,可通过网站和控制台应用程序进行访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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