必须指定C#exePath错误. [英] C# exePath must be specified error.

查看:62
本文介绍了必须指定C#exePath错误.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的控制台程序将dll加载到其他appdomain.
该dll与Web服务通信,但它提供了一个例外:
在GetWebRequest()
不在独立exe中运行时必须指定exePath.
在System.ConfigurationManager.OpenExeConfigurationInternal(.....).

据我在网上阅读的内容,因为dll尝试读取.config文件,但是由于dll位于不同的appdomain中,因此它失败了.

因此,如何禁用dll尝试访问.config文件.我的项目没有任何.config文件,不需要它们.

谢谢.
安蒂


dll尝试执行Web服务功能时会给出异常.

代码示例:

My console program loads a dll to different appdomain.
That dll communicates with webservice but it gives a exception :
On GetWebRequest()
"exePath must be specified when not running inside stand alone exe.
at System.ConfigurationManager.OpenExeConfigurationInternal(.....)".

As far as I read on web its because dll tries to read .config file but as dll is in different appdomain it fails.

So how to disable dll trying to access to .config file. My project dont have any .config files and dont need them.

Thank you.
Antti


Exception is given when dll is trying execute webservice function.

Code example :

Server.WebService myWebService = new Server.WebService();
myWebService.Url = "http://blaaah/Service.svc";
myWebService.TestFunction(); // <--- exception is thrown.

推荐答案

您的DLL调用ConfigurationManager.OpenEXEConfiguration()吗?如果是这样,请尝试在其周围放置一个try/catch块,然后吃掉异常.
Does your DLL call ConfigurationManager.OpenEXEConfiguration()? If so, try putting a try/catch block around it and just eat the exception.


尝试从您的应用中删除Web服务引用,然后重新添加它.
Try removing the web service reference from your app, and then re-adding it.


这篇关于必须指定C#exePath错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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