问题标签 [configurationmanager]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
4466 浏览

c# - C# ConfigurationManager 问题

我已将项目从 framework3.5 升级到 framework4.0。现在我正在使用 Visual Studio 2010。这是我的 app.config 文件

在这里,当我使用框架 3.5 时,我将配置文件用作

当我升级到框架 4.0 时,这条线

显示警告消息为

'System.Configuration.ConfigurationSettings.AppSettings' 已过时:'此方法已过时,已被 System.Configuration!System.Configuration.ConfigurationManager.AppSettings 取代'。

我试过 ConfigurationManager.AppSettings["DBConnectionString"]; 但它显示一个错误

任何人都可以解决这个问题。在此先感谢。

0 投票
1 回答
364 浏览

file - ConfigurationManager.Appsettings[""] 共享配置文件

目前,我有 2 个 Windows 服务,我希望它们从单个 app.config 文件中共享。

我如何告诉 ConfigurationManager 类从将由 2 个服务共享的单个文件加载设置?

使用 ConfigurationManager.Appsettings[""] 要求,每个服务都需要有自己的配置文件。如果用户可以只配置一个文件而不是两个具有类似设置的文件,那就太好了。

干杯

0 投票
3 回答
24395 浏览

c# - 如何在 Visual Studio 2010 中将项目输出平台设置为 x86

在我的几个项目的解决方案中,我试图将Platform任何 CPU 更改为 x86。但是 x86 不在下拉列表中。我需要做什么才能选择 x86?

由于出现错误,我需要更改为 x86 System.BadImageFormatException,根据这个问题:What cause System.BadImageFormatException when construction System.Data.SQLite.SQLiteConnection

在此处输入图像描述

而且,在一个可能相关的问题中,解决方案中的最新项目缺少配置下拉列表中的配置之一:

在此处输入图像描述

它应该像所有其他项目一样具有“暂存”配置,但没有。我该如何添加它?

编辑:

如果我选择“New ...”选项,那么它会要求我从“Any CPU”复制。如果我从“Any CPU”复制,那与首先使用“Any CPU”不一样吗?

在此处输入图像描述

0 投票
1 回答
991 浏览

web-config - 使用 XSD 生成的类反序列化 web.config 自定义部分

我在 Web.Config 文件中有一个自定义部分,并通过 configSource 引用另一个 .config 文件。我已经为我的架构使用 XSD 生成了 .cs 文件。如何使用我生成的类来反序列化配置。当我尝试使用 .GetSection() 方法加载 configsection 时,它给了我该类应该从 ConfigurationSection 实现的错误。由于我使用 xsd 生成了这些类,因此它们不是从 ConfigurationSection 或 ConfigurationElement 继承的。提前致谢!!

0 投票
1 回答
493 浏览

configurationmanager - ConfigurationManager 读取错误的文件

我有一个解决方案分为两个项目,一个用于类库,另一个用于单元测试(使用 NUnit 2.5)。现在,在类库项目的 App.config 文件中,我添加了几行,例如

我在类库代码中阅读

问题是,当我运行单元测试时,类库无法访问这些值,因为即使在库中使用了该代码,它也会在单元测试项目的 App.config 中查找它们。如果我将这些行添加到该文件中,一切都会顺利进行,但这当然不是我想要的。我怎么知道ConfigurationManager在正确的应用程序路径中寻找密钥?

0 投票
1 回答
538 浏览

mocking - 模拟索引属性的摩尔

我正在寻找一种方法来使用 Moles 在配置文件中“绕道”单个项目。我可以做这个:

这很好用,但是我尝试测试的类使用了一些其他配置设置,包括 ConfigSections 和 Moles detour 似乎已经打破了这一点。我只想替换一个特定的值,而不是整个部分。在 TypeMock 中,我可以这样做:

Isolate.WhenCalled(() => ConfigurationManager.AppSettings["MyKey"]).WithExactArguments().WillReturn("MyValue");

当我使用 TypeMock 模拟 configurationManager 时,我的测试通过了,但是当我使用 Moles 版本(看起来它应该做同样的事情)时它失败了,这意味着 Moles 必须以 TypeMock 没有的方式影响 ConfigurationManager 类。

任何有关我如何使用痣以按照 TypeMock 的方式行事的帮助将不胜感激。

0 投票
1 回答
141 浏览

svn - Getting strucked with merging from dev branch to test merge in svn & tips required for instant release mechanism

We had a ten developers who do commits in the dev branch. After a week once all the tasks are through, i need to merge all the commits to test branch for rebasing before i tag and merge the releases to trunk. While merging a range of revisions i am getting strucked and time consuming to resolve with svn conflicts. When i get conflict : I used to do the following :

  1. I allways consider the latet revision file for eg: .r500 is the latest revision which i need, and removing the extension it generate like filename.java.rev500, and deleting the remaining like mine,base file and previsous revision files which it genrates when the conflicts occur. Is this a best practise and advisable.I allways use diff in the log and check the latest version file manually while considering a revision when i get the conflict.

  2. While merging most of the conflicted, updated files i am getting these symbols, <<<<<<< .working and >>>>>>> .merge-right.r500. Do we need to manually remove this in the files, when we perform releases. Even some times these symbols effect my build, resolving after i manually remove them.

  3. Is it advisable to merge 15 to 20 revisions at a time, for eg: consisting 70 files in the entire release, is it better to merge 4 to 5 revisions solve the conflicts and move forward with remaning revisions, but if i merge few revisions and again after with remaining revisions its conumes a lot of time. When ever i do merge, i should allways manually edit, or any best methods and practises i need to follow.

0 投票
2 回答
12979 浏览

vb.net - ConfigurationManager 未声明 - 有 dll

快速背景:我有一个 VB.NET 应用程序,我之前使用 ConfigurationSettings.AppSettings 从 app.config 读取,并收到一条错误消息,将其更改为 System.Configuration.ConfigurationManager.AppSettings(因为第一种方法现在已过时)

我这样做了,我什至在顶部引用了 System.Configuration.dll 和 Imports 语句,但我收到“未声明名称 ConfigurationManager”错误消息。有什么建议么?

代码:这很简单——我只是检查是否存在某些东西,如果存在,我会从中读取:

0 投票
1 回答
1519 浏览

c# - 根据 providername 从 web.config 中获取 connectionStrings

我试图弄清楚如何从具有特定提供程序但卡住的 web.config 中获取所有连接字符串。

我的方法的基础看起来像这样

任何建议都非常感谢!

0 投票
1 回答
110 浏览

vb.net - 从 VB2005 应用程序中删除配置

在项目属性的编译选项卡上:

如果您查看配置下拉菜单,它通常会显示 debug/release/active/all。

我试图在构建->配置管理器窗口中添加另一个选项,但决定我不想保留它。我在那里删除了它,但它一直显示在属性的下拉列表中,并以该名称生成一个文件夹。

有谁知道如何删除这个?我找不到任何“删除”或其他选项。