app-config

Problem loading assembly via Reflection and accessing configuration

坚强是说给别人听的谎言 提交于 2019-12-10 09:56:40
问题 I'm trying to load a .NET assembly with Reflection (using the Assembly.LoadFrom method), and instantiate some types within this assembly. This all seems to work fine, but one type I'm trying to instantiate accesses the assembly's configuration within its type initializer: it does ConfigurationManager.GetSection(sectionName) . The assembly is then throwing an exception because the configuration section cannot be found. The config file for the assembly I'm loading is in the same directory, and

nUnit tests looking for {assembly-name}.dll.config

心不动则不痛 提交于 2019-12-10 09:22:10
问题 I have a PowerShell script that shells-out to nunit-console-x86.exe to run tests in assemblies ( DLLs ) that were built earlier in the script by shelling to MSBuild to compile a VS .sln Exec { invoke-expression "$BUILD_DIR\Tools\NUnit.2.5.10.11092\nunit-console-x86.exe $full_test_assembly_name /xml:test-results/$test_results_file_name" } Some of these tests utilize System.Configuration.ConfigurationManager to load config settings. nunit-console-x86.exe searches for these config-settings in {

F# Type Providers and Continuous Integration, Part 2

╄→尐↘猪︶ㄣ 提交于 2019-12-10 03:28:59
问题 This is a (actually it is several) follow-up question to my previous question on F# Type Providers and Continuous Integration. It seems to me that it would be a good idea to use the SqlDataConnection type provider as a compile-time check that the code/database integrity remains intact in feature-branch driven development; you would know at every commit/build that no changes have been made to the code that has not also been applied to the database, assuming that building the database is also a

Give app.config another name after build?

橙三吉。 提交于 2019-12-10 03:05:07
问题 As you all know, when you build a project with an app.config file it gets copied to the bin directory and renamed $(targetFileName).config. Is it possible for it to be called something else? For example if my executable is called myApplication.exe, can I have the config file called settings.config as opposed to myApplication.exe.config? Cheers 回答1: An application by the name of 'myApplication.exe' expects the configuration file to be named 'myApplication.exe.config'. If it's named anything

Configuration System Failed To Initialize

十年热恋 提交于 2019-12-10 02:15:58
问题 In my application when I try to get the connection string by using this code : System.Configuration.ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString; It throws an exception that "Configuration System Failed To Initialize". Where is the format of app.config wrong ? <?xml version="1.0"?> <configuration> <connectionStrings> <add name="ConStr" connectionString="Integrated Security=false;Persist Security Info=False;User ID=funny;password=veryfunny;Initial Catalog=vegimanager;Data

How to make ConfigurationManager read a config file other than app.config?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 01:52:21
问题 I need to parse a config file that is situated in another project. I know that ConfigurationManager reads the app.config file by default, but how to make it read that particular config file? 回答1: // Create a filemap refering the config file. ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); fileMap.ExeConfigFilename = configFilePath; // Retrieve the config file. Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);

How do I encrypt app.config file sections during install with WiX?

余生长醉 提交于 2019-12-09 16:50:39
问题 I have found an example for encrypting a web.config during installation here, but my app is a windows service. The aspnetreg_iis method works only for web.config files. I know how to programatically encrypt the config file, but I don't think I can do that using WiX. Am I wrong? Any ideas? 回答1: Here is what I ended up with... I used WiX and DTF to created a managed code Custom Action to encrypt a given section of a config file: public static void EncryptConfig(Session session) { var configPath

App.Config errors with “Configuration system failed to initialize”

隐身守侯 提交于 2019-12-09 16:15:46
问题 I have a console application written in C# under .net 4.0 It has a bunch of variables which I want to move into App.Config (so it will be all in one place). Added this part of code to App.Config (between configuration tags): <configuration> <appSettings> <add key="RemoteDirectory" value="Some Text Here"/> </appSettings> </configuration> In my program trying to test it with this code Console.WriteLine(ConfigurationManager.AppSettings["RemoteDirectory"]); but I keep getting "Configuration

Load configuration file from stream instead of file

為{幸葍}努か 提交于 2019-12-09 12:53:22
问题 I use OpenMappedExeConfiguration with ExeConfigurationFileMap to load configuration files. Their overloads suggest that they only work with filenames. Is there a way to load a configuration file from a stream? Background: I want to load configuration files that are stored as embedded resources. There is no file representation! 回答1: No. The problem is that this class itself do not read the configuration. The file path itself is eventually used by the Configuration class to load the

How do I create a Solution Wide Connection String

房东的猫 提交于 2019-12-09 12:33:45
问题 Does anyone know if it is possible to create a single connection string that will be accessible to all the projects in a solution (we have about 6). I can create a text file with this information, but we need design time support as well, and it is not practical to have a connection string in every App.Config and Web.config file in the solution. We basically want a Single connection string that is easy to change should the location of the db change, that will also be used by the IDE for design