-
February 6th, 2009, 09:31 AM
#1
config fiels in .Net
Hello All I am developing an application in C# and I have my project split the following way :
1. Windows project which contains all of the UI stuff
2. Core project which contains the core functinality
3. Service project which contains all the stuff related to a service which needs to be running in the backgroud
THe issue is that I need to have the user enter some data during installation and the application uses that data. ( all three of the projects need that data)
I have created a Settings file which has the fields that are needed and then during installation I
collect the information and override the config file.
So I have name.Windows.exe -
name.Service.exe
name.Core.dll projects
and they all need to use the data entered by the user during installation.
how can I achieve that?
I have tried creating two config files - one for the service and one for the WIndows
but HOw do I get the information to my Core.dll
There seems to be a problem when I do that - the .dll never updates with the user information but always uses the default values I had during design time.
THanks very much in advance....I really need help with this
Susan
-
February 6th, 2009, 09:56 AM
#2
Re: config fiels in .Net
I assume that the Windows application calls methods of the DLL core project. If that is the case, you could achieve it bij making an 'initializer/constructor' of the DLL. When the Windows application starts, pass the information from the windows config file to the DLL, thus somethin like this
core.dll
Code:
public void InitializeCore(int configValue1, string configValue2){
//do somethign with the values, store them in the rigth fields that you need to use
}
windows.exe
Code:
static void Main() {
// initialize the DLL
core.InitializeCore(Properties.Settings.Default.myIntConfig, Properties.Settings.Default.myStringConfig);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMain()); }
I don't know if there are other possibiltys to do this, but this is a working solution
-
February 6th, 2009, 01:08 PM
#3
Re: config fiels in .Net
I just wanna tell u that u saved my day....thank u like 1000 times.
I took your idea and implemented it a bit differently.
I created a static class in the core with all the properties that I needed and had that class parse the config file directly and assign the variables.
I still kept the configs for the Service and the UI projets and they still get updated from the install....but the core is not using a settings file anymore.
.dll libraries are supposed to work fine with settings but in reality they don't
Anyway ...thanks again for saving me lotsa trouble.
Susan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|