把配置信息在DLL [英] Putting configuration information in a DLL

查看:175
本文介绍了把配置信息在DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目,我有被用作一个Web应用程序,并作为控制台应用程序功能(可从任务计划程序启动)。为了做到这一点,我把常见的code在正在使用的Web应用程序和控制台应用程序既是一个DLL。这工作得很好。

In my project I have functionality that is being used as a web application and as a console application (to be started from the task scheduler). To do that I put the common code in a DLL that is being used by both the web application and the console application. This works fine.

不过,控制台和Web应用程序现在有一个app.config和Web.config中的大多是相同的。是否有可能把这个配置中的DLL以及使之既应用程序中提供?

However, the console and web applications now have an App.config and Web.config that are mostly the same. Is it possible to put this configuration in the DLL as well and make it available to both applications?

推荐答案

是的,你可以而且应该把常见的配置设置为您的DLL中的配置文件。只需添加一个app.config文件到DLL项目,并确保您从DLL中读取配置设置。在部署时,您的配置文件需要有名称为MyDLL.dll.config(假设你的DLL被命名为MYDLL.DLL),并在同一文件夹中的DLL。

Yes, you can and should put the common configuration settings in the config file for your DLL. Just add an app.config file to the DLL project, and make sure you read the configuration settings from inside the DLL. When deployed, your config file needs to have the name "MyDLL.dll.config" (assuming your DLL is named "MyDLL.dll") and be in the same folder as the DLL.

这篇关于把配置信息在DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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