app-config

How to create a file in the AppData folder using log4net

大憨熊 提交于 2019-11-29 13:12:04
How to create the log file in appData folder. The path is C:\Users\MYNAME\AppData\Roaming\Project\My Project\Application. As soon as my project starts, the project folder is created on this path where this path is hard coded. How can I add my log file in this folder using log4net? I have made changes in the config file <?xml version="1.0"?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> </configSections> <log4net> <appender name="Console" type="log4net.Appender.ConsoleAppender"> <layout type="log4net.Layout

Couchbase multiple buckets in .NET app.config

末鹿安然 提交于 2019-11-29 11:41:56
Couchbase .Net manual says that I can configure my client in this way: <couchbase><servers bucket="default" bucketPassword=""> <add uri="http://192.168.0.2:8091/pools/default"/> <add uri="http://192.168.0.3:8091/pools/default"/> </servers></couchbase> Is there any way to define sevral buckets in app.config and then switch between them in my app? According to John's suggestion, I used such configuration: <configuration> <configSections> <sectionGroup name="couchbase"> <section name="bucket-1" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/> ... <section name="bucket-N" type=

how to define a connection string using an app.config file in C# [duplicate]

戏子无情 提交于 2019-11-29 11:07:50
This question already has an answer here: Get connection string from App.config 18 answers Currently i manually define my connection string in my C# code: string ConnectionString = "Data Source=C;Initial Catalog=tickets;Integrated Security=True"; SqlConnection Conn = new SqlConnection(ConnectionString); Conn.Open(); In my project i have an app.config file and i can see that it has a connection string. It looks like this: <?xml version="1.0"?> <configuration> <configSections> </configSections> <connectionStrings> <add name="ticketNotification.Properties.Settings.ticketsConnectionString"

Run service with administrator privileges

℡╲_俬逩灬. 提交于 2019-11-29 11:05:15
I am developing an application that runs as a windows service. I really need the service to have administrator privileges. I tried with the LocalSystem user, and it does not have enough rights. Is this possible? I tried setting requireAdministrator in the app.config. When I do this, the service starts and then immediately stops. I have tried with other administrator accounts as well, but I get the same results. You just need to run it as an admin user - set the login correctly in the services properties for the service. Usually though it's best to run as an ordinary user and give it explicit

app.config “Could not find schema information” after converting to Visual Studio 2010 / .Net 4.0

孤街浪徒 提交于 2019-11-29 10:50:33
问题 After upgrading my project to Visual Studio 2010 and .Net 4.0, my app.config file generates these messages upon building the project: Could not find schema information for the element 'supportedRuntime'. Could not find schema information for the attribute 'version'. Could not find schema information for the attribute 'sku'. Here is my entire app.config file: <?xml version="1.0"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/> <

Fetching connection string from appconfig file in c#

二次信任 提交于 2019-11-29 10:21:45
I have the following connection string declared in my app.config file: <connectionStrings> <add name="SqlConnectionString" connectionString="Data Source=xxx.xx.xx.xx;Initial Catalog=xxxxx;User Id=xx;Password=xxx;" providerName="System.Data.SqlClient" /> </connectionStrings> When I try to fetch this connection string using the following C# code snippet, I get the value null . I am not able to obtain the connection string. Is there anything wrong in the syntax? First attempt: var settings = ConfigurationManager.ConnectionStrings["SqlConnectionString"]; string result = settings.ConnectionString;

Is switching app.config at runtime possible?

六眼飞鱼酱① 提交于 2019-11-29 10:13:55
Is there a way at runtime to switch out an applications app.config (current.config to new.config, file for file). I have a backup/restore process which needs to replace its own application.exe.config file. I have seen this post but it does not answer how to do this at runtime. Turns out I can swap the .config file for the new one and do a ConfigurationManager.RefreshSection(...) for each section. It will update from the new .config file. Microsoft .NET's app.config is not designed for your scenario, as well as many others. I often encounter a similar need, so I have spent a lot of effort

How can I debug a VB6 project that has a .net interop project which uses an app.config file?

痞子三分冷 提交于 2019-11-29 09:38:06
I have a .net interop project that uses an app.config file. When I am running the VB6 project that is using the interop control in Debug mode, the ConfigurationManager cannot find the app.config file. When I make the VB6 project into an exe and rename the app.config file to (VB6 binary name).exe.config, the ConfigurationManager can find the file. Is there a way to rename the app.config file or change a setting so ConfigurationManager can find the app.config file while VB6 is running in debug mode? A dirty hack is to place the app.config file into the VB6 folder and rename it to vb6.exe.config

Do I need to escape backslash in a config file?

久未见 提交于 2019-11-29 09:04:41
I have a config file, myapp.exe.config. In the file I have an attribute with a fullpath filename as the value. <add key="InfoFile" value="c:\temp\info.txt" /> It seems to work if I use a single or double backslash. That is, <add key="InfoFile" value="c:\\temp\\info.txt" /> works also. What is the correct way to do this? You don't need that. Anything within an attribute value is character data. Since you're reading these values using C#, they'll get escaped as if they would be a literal path string in code. Anyway, you might want to know that C# has @ operator to declare verbatim strings,

ConnectionString from app.config of a DLL is null

血红的双手。 提交于 2019-11-29 08:21:16
I have a class library that contains a valid connectionString inside the app.config. Inside that class library I want to use it with ConfigurationManager.ConnectionStrings["NAME"].ConnectionString My ASP.net 4.0 framework application references that DDL and retrieves data from it. I want create a Entity Framework 4 DataContext within my DDL with the ConnectionString from the App.config. (I do not want to pass the connectionString from my ASP.net application in every single method. (I'm using ObjectDataSources)) However, this line inside my DLL throws a NullReferenceException.