在Web服务中引用dll配置文件时加载dll配置文件的问题 [英] Problem with loading dll config file when it is referenced in web services

查看:189
本文介绍了在Web服务中引用dll配置文件时加载dll配置文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个WCF Web服务,它引用了一些类库(BO.dll,BLL.dll,DAL.dll),并调用了它们的方法。其中一个库(DAL.dll)需要一个配置文件来读取一些设置,如连接字符串。然后配置文件位于dll文件附近。但是当我使用该服务时,它有无法找到文件C:\windows \ microsoft.NET \FrameWork \v4.0.30319 \Temporary ASP.NET Files \SampleService(某些临时文件夹)的错误\ myConfigFile.config

我应该说dll代码将配置文件读作一个简单的xml文件。并提取设置。



为什么它在这个地址寻找?我应该把配置文件放在哪里才能被dll文件访问?

I have created a WCF web service which has references to some class library (BO.dll,BLL.dll,DAL.dll) ,and invoke their methods . one of the libraries(DAL.dll) need a config file to read some settings like connection string . then the config file is located near to the dll files . but when I use the service, it has error which the "could not find file C:\windows\microsoft.NET\FrameWork\v4.0.30319\Temporary ASP.NET Files\SampleService(some temp folder)\myConfigFile.config"
I should say that dll code read the config file as a simple xml file. and extract the settings.

why it looks for in this address ? where should I put the config file to be accessible by the dll file?

推荐答案

当你尝试使用.Net中的ConfigurationManager类从dll访问配置文件时实际上会引用dll托管地点的配置文件,在这种情况下你的web.config。



是的,对于dll,我建议你自己拥有用于读取xml文件的代码,并使用dll部署xml文件。另一种方法是将dll所需的设置添加到web.config。
When you try to access config files using the ConfigurationManager class in .Net from a dll it will actually reference the config file of wherever the dll is being hosted, in this case your web.config.

Yes, for dlls, I would recommend just having your own code for reading xml files and deploy the xml file with the dll. The alternative is to add the settings that the dll need into your web.config.


这篇关于在Web服务中引用dll配置文件时加载dll配置文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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