C# currentcultureinfo is different than defined - c#

I have a problem where my CurrentCulture is is-IS while I dont have that configured not in my web.config, not on my windows xp, and for some reason this is the locale that is taken into my applications...
where can it be?

It could be in the project (.csproj) file. In VS, unload the project and then edit the project file.
There could be a an XML element named this:
<UICulture>en-US</UICulture>
This sets the default culture.
Other places it could be are configuration files, it could be set in code somewhere when the application starts, or it could be set in the host HTML page if this is a web application.

Related

Why wont my application read my DataAccessLayer.dll.config file?

I'm trying to use application settings with a C#.NET project I am working on. But I can't seem to get it to return anything other then the default values. Through the project properties I've added a single setting, DBConnectionString, and set its value to a connection string I want to use. Its scope is set to "application".
Doing this created a number of files including Settings.settings, Settings.Designer.CS, and app.config. The Settings class then has custom, type safe, properties that can be used to set and retrieve each setting. The app.config file is a XML file that stores the actual settings values.
When I build my project it looks like the app.config file is copied to the target directory as DataAccessLayer.dll.config. My program runs fine and is able to use the default connection string.
Next I tried to edit the DataAccessLayer.dll.config file to change the connection string. I ran my program again, but it continued to use the default value.
This project is a class library that use to a Web project and sometimes the connection string can changes.
Builds will output config files named after the dll however those aren't actually what's read on app start up. You could put the setting in the web apps config (example here Equivalent to 'app.config' for a library (DLL)), those are the settings you'll actually be running with in this case.
If you want your library to be portable you'll have to either; 1) make your own config class/file 2) Read your dll's app config manually (example in the answer I linked to above) or 3) Put your setting in the importing projects app.config
In this case I would just put your connection string data in the web apps config. If DataAccessLayer.dll is only for internal use, this is in my experience the most common pattern, and doesn't really have many cons. Ultimately I would have these values set during my build or by a deploy utility like Salt or Chef. If you're manually editing the web apps config on or after deploy then you're doing it wrong.

Configuration file in .net windows application

I am new in .net.
I am actually converting a Console application into Windows application in .net. And I want to include some configuration files in the windows application.
I know that for web application there is Web.config and for Console application there is App.config to have the configuration details.
But I don't have any ideas about the configuration file in windows application. I have to include the configuration details in my windows application that included in the console application that i want to convert.
UPDATE
Problem Fixed.
It is a fault from my part. I also copied startup tag. Can anyone please tell me for what this tag.??
Thant you all for the replay.
A windows application is a WinForms or WPF application and use the same App.Config renamed in yourappname.exe.config as in Console Applications. So just go on with that
An excellent series of articles on configuration files (I will dare to say the reference)
Unraveling the Mysteries of .NET 2.0 Configuration
Go to the project's properties and change to the "Settings" tab. You might see a message that no settings file is present right now. If you click the link, one will be created.
Add one setting as a dummy so that all sections in the app.config file are created (<applicationSettings> or <userSettings> and the respective section for your namespace). Then, open the original config file in a text edit, copy the settings lines (not the lines containing the <namespace.properties.settings> start and end tags) and then paste them into the new app.config. Make sure that you copy application settings to the <applicationSettings> section and user settings to the <userSettings> sections accordingly.
The next time you open the Settings tag, you'll be asked whether you'd like to import the new settings.
There’s a really simple way to do this.. simply go to the File \ Add New Item menu, or hit Ctrl+Shift+A
You’ll notice that it’s already set to App.config for you. Just hit the Open button.
If you look in the Solution Explorer, you will see that the config file is in your project:
Now build your application, and take a look in the \bin\debug\ folder. You’ll see that the configuration file has automatically been generated and named correctly for your executable:
Reference taken from HERE
Right click on your project go to -->Add --> New Item and then you will find a dialog as shown

Use ConfigurationManager with custom path to config file

I see many solutions to reading in values from an external configuration file in a C# console application, but I can't find a solution for my particular circumstances:
Due to reasons of deployment (mainly that this is for a console application that is packed for deployment as part of an MVC website using the Visual Studio web Publish method), the exe does not get packaged with its app.config file.
I'm dependent on libraries that make use of the ConfigurationManager.AppConfig["blah"] syntax, and I can't very well pass in my own AppSettingsSection to these libs.
My console application's .exe file is in the MVC app's bin directory. As both the website and the console app use the same config values, I was trying to simply load the site's Web.config file into the console app, but I haven't found a way of doing this.
The default configuration file is loaded once the AppDomain is loaded. For console applications, the configuration file must be located in the same place as the executable.
I believe that one possible solution is loading an AppDomain as a child of the console application and setting up the AppDomainSetup.ConfigurationFile property rightly to load the configuration file from the custom location, and then execute the whole console application's logic inside the child AppDomain.
You can use this AppDomain.CreateDomain overload for this case (the MSDN article contains a sample code on how to provide the AppDomainSetup):
http://msdn.microsoft.com/en-us/library/aehss7y0.aspx
As far as I know, you can't change the default behavior of where the executable AppDomain looks for the configuration file once it's loaded, but as I suggested you, you can create your own AppDomain with your own requirements!

Change setting in user control 's configuration file has no effect

I have a problem: change setting in user control's configuration file has no effect.
I can add "setting" to a user control project and can make following code work:
label1.Text = Properties.Settings.Default.DisplayName;
The output of this usercontrol project is "usercontorl1.dll" and "usercontrol1.dll.config".
When I test it in other project, I found that change the value in config file has no effect to its display. And even if there is no config file, it works fine!
How can I solve this problem , I really need a configurable user control.
Thank you.
Windows 7 64 bits
VS 2008
.Net 3.5
Ref:
http://social.msdn.microsoft.com/Forums/da-DK/msbuild/thread/cbbd893c-8d5d-4699-bf51-bdd110946c94
https://stackoverflow.com/questions/6505252/winform-store-configuration-data-for-user-control
Writing/Reading User-Defined settings in app.config file
You need to copy the config section to the App.Config of the using project.
The (only) file used at runtime is AppName.exe.config
When I test it in other project, I found that change the value in
config file has no effect to its display. And even if there is no
config file, it works fine!
Add the configuration of the user control in the "other project" i.e. the driving project.
ConfigurationManager class visualizes things in the current AppDomain and since your user control loads in the driving application's App Domain, the ConfigurationManager code would refer to the App.Config of the current AppDomain.
I believe that should help!
regds,

Deploy user.config file

I'm having problems deploying a config file.
I have a set of default configurations, which are altered at the moment of installation (custom installer class).
But strangely, my settings keep being reset. In VS2005 all settings are defined with default value, but it's just not getting into my deploy software.
What can i do?
Thanks!
Could it be that you are somehow altering the wrong user.config file?
Each new version of your application gets a new folder under the folder below (Windows 7):
C:\Users>username>\AppData\Local\\App.exe_Url_fdtzgjq\
Each subfolder contains a separate user.config:
\0.5.0.0\user.config
\0.9.0.0\user.config
\1.0.0.0\user.config
etc.

Categories