VBAHole22 Posted June 21, 2006 Posted June 21, 2006 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? Quote Wanna-Be C# Superstar
Administrators PlausiblyDamp Posted June 21, 2006 Administrators Posted June 21, 2006 You should find visual studio has created a wrapper class for you Properties.Settings.Default. should be all you need. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
VBAHole22 Posted June 22, 2006 Author Posted June 22, 2006 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. Quote Wanna-Be C# Superstar
VBAHole22 Posted June 22, 2006 Author Posted June 22, 2006 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. Quote Wanna-Be C# Superstar
Administrators PlausiblyDamp Posted June 22, 2006 Administrators Posted June 22, 2006 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.