WCF:必须在不在独立的exe内运行时指定exePath [英] WCF: exePath must be specified when not running inside a stand alone exe

查看:530
本文介绍了WCF:必须在不在独立的exe内运行时指定exePath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有我有WCF服务的问题。



管理WPF项目(exe)正在尝试读取配置文件之一的WCF服务(读取AppSettings)。 br />
应用程序正常工作,在调试模式下成功读取和写入App.config文件(作为VS主机服务自动(服务主机环境)),但是当我在IIS上部署服务时,我面临着异常。



以下是例外的详细说明





< b>当不在独立的exe内部运行时必须指定exePath。

类型:System.ArgumentException:

来源:

System.Configuration

数据:

堆栈跟踪:在System.Configuration.ConfigurationManager.OpenExeConfigurationImpl(ConfigurationFileMap fileMap,Boolean isMachine,ConfigurationUserLevel userLevel,String exePath,Boolean preLoad)<在E:\ Source \ MB服务\源代码\源代码\ Business \ NF.Business.COSService \\中的Business.XXXService.AdminService.ReadEmailConfiguration(GenericRequest`1请求)中的
\\ ServicesvicesImpl\AdminService.cs:388行




据我所知,在开发模式下,有一个服务的aap.config文件(WCF服务库)项目),但是当要在IIS上部署时,从Web.config读取配置

所以我实现了两个cas es。

这是阅读配置文件的实现,但仍然面临部署服务的问题。



Dear all i have problem with WCF Service.

Administration WPF project (exe) is trying to read config file one of WCF service (Read AppSettings).
Application works properly, successfully read and write App.config file while in debug mode (as VS host Services automatically (Service host environment)), but when i deploy services on IIS, I face bellow exception.

Here is detail description of Exception


exePath must be specified when not running inside a stand alone exe.
Type: System.ArgumentException:
Source:
System.Configuration
Data:
Stack Trace: at System.Configuration.ConfigurationManager.OpenExeConfigurationImpl(ConfigurationFileMap fileMap, Boolean isMachine, ConfigurationUserLevel userLevel, String exePath, Boolean preLoad)
at Business.XXXService.AdminService.ReadEmailConfiguration(GenericRequest`1 request) in E:\Source\MB Services\Source Code\Source Code\Business\NFS.Business.COSService\ServicesImpl\AdminService.cs:line 388


As I understand, In development mode, there is aap.config file for services (WCF Service library project), but when going to deploy on IIS, configuration read from Web.config
So I implemented both cases.
Here is implementation of reading config file, But still face issue on deployed Service.

Configuration configuration = null;

               if (HttpContext.Current != null)
                   configuration = WebConfigurationManager.OpenWebConfiguration("~");
               else
                   configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

               if (configuration == null)
               {
                   response.Status.Code = ReturnCode.DataNotFound.GetStringValue();
                   response.Status.Message = "Unable to read configuration";
                   return response;

               }





我认为无需在app / web.config中进行调查因此我没有附上配置文件







预付款谢谢

Kamran



I think there is no need to investigate in app/web.config therefore I am not attaching config File



Thanks in Advance
Kamran

推荐答案

WCF和系统。配置命名空间 [ ^ ]可以帮助你。






如果你不能或想要启用asp兼容性,请检查WebOperationContext .Current!= null而不是HttpContext.Current。



它位于System.ServiceModel.Web。



问候,

Patrik
Hi,

If you don't can or want to enable asp compability just check WebOperationContext.Current != null instead of HttpContext.Current.

It's located in System.ServiceModel.Web.

Regards,
Patrik


亲爱的,



问题解决。



你需要启用asp兼容性下面的步骤可以解决这个问题。



在web.config中设置AspnetCompatibilityEnabled true ServiceModel Node(如果你使用的是WCF服务库,那么添加AspnetCompatibilityEnabled在aap.config中的ServiceModel节点中)



Dear All,

Issue Solved.

You need to enable asp compatibility bellow steps can solve such issue.

set AspnetCompatibilityEnabled true in web.config ServiceModel Node (If you are using WCF service library then add AspnetCompatibilityEnabled in ServiceModel Node in aap.config)

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
.
.
.
</system.serviceModel





其次,您需要将AspNetCompatibilityRequirements属性添加到与asp.net兼容的服务中





Second you need to Add AspNetCompatibilityRequirements Attribute to compatible service with asp.net

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class AdminService : IAdminService
    {
.
.


这篇关于WCF:必须在不在独立的exe内运行时指定exePath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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