Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Maybe I am missing something really obvious but I am at a loss on this.

1.Went into my 2.0 win app and got to the properties page (vs2005).

2.Added a few string settings on the settings tab (application scope).

3. this results in the following xml bit in the app.config file (which i spawned earlier):

 
  <applicationSettings>
       <Myapp.Properties.Settings>
           <setting name="LogOutputFilePath" serializeAs="String">
               <value>C:\\Temp\\ErrorLog\\</value>
           </setting>
       </Myapp.Properties.Settings>
   </applicationSettings>

 

4.In code I want to pull this value out using:

string path = ConfigurationManager.AppSettings.Get("LogOutputFilePath");

 

 

The string is always null. i can never get the value. I have a ref to System.Configuration and I have the using. What am I missing here?

Wanna-Be C# Superstar
Posted

Thank you, thank you, thank you.

 

I'm very happy to have a solution.

 

That said.

Holy Cr*p why does ms make this so difficult?

I googled this for like an hour and didn't come up with any ideas.

Even msdn was refering to appSettings. Unbelievable.

Wanna-Be C# Superstar
Posted

Perhaps I spoke too soon.

 

I can use this method to access settings in my win app - no worries.

However I also have a class library in this solution with business logic. This project cannot see the Properties namespace so the method doesn't work.

When I built stuff like this in 1.0 I was able to use a single app.config and all projects could see it.

 

I don't want to have to put a properties/app.config page in my business logic class library.

Wanna-Be C# Superstar
  • Administrators
Posted

Have you tried to create your properties as part of the ClassLibrary project? If not give it a try, The Properties.Settings etc. for a classlibrary is saved to / read from the calling application's config file.

 

It makes it just as simple to use with dlls.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...