在库项目净的app.config [英] .Net app.config in library project

查看:143
本文介绍了在库项目净的app.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个解决方案控制台应用程序项目和库项目(DLL)。图书馆项目app.config文件在哪里存储连接字符串的数据库。 控制台应用程序引用这个DLL。

I have a console application project and library project (dll) in one solution. The library project has app.config file where I store a connection string to database. The console application references this dll.

当我编译控制台应用程序,并与我不能够访问属于该dll,当我需要更改连接字符串的应用程序部署后app.config文件库中部署它。

When I compile the console application and deploy it with the library I am not able to access the app.config file that belongs the dll when I need to change the connection string after the application is deployed.

这是我看到这些文件,但不config文件:

This are the files that I see, but not .config file:

  • library.dll
  • library.pdb
  • console.application
  • console.exe
  • console.exe.manifest
  • console.pdb
  • console.vshost.application
  • console.vshest.exe

我上哪儿去了?

推荐答案

在默认情况下,只有1的.config文件正在运行的应用程序。这是启动该程序的EXE文件关联的.config文件。你或许应该从DLL的配置文件到控制台应用程序的配置文件复制配置值。如果你真的想要让他们分开,那么你不能使用默认ConfigurationSettings.AppSettings字典。请参见这个问题获取更多的信息。

By default, there is only 1 ".config" file for a running application. It is the ".config" file associated with the EXE that started the program. You should probably copy the config values from the DLL's config file into the console app's config file. If you really want to keep them separate then you can't use the default ConfigurationSettings.AppSettings dictionary. See this question for more info.

这篇关于在库项目净的app.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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