dan blanchard

Hi,

I am using ConfigurationManager.OpenMappedExeConfiguration() to specify a roaming user config file that I can easily persist settings too. However, I find it is extremely finicky, when adding, removing, or renaming settings or sections. ie, when adding, if there is a new setting that is not also in the xml file, it throws an exception. When removing or renaming, if there is a setting in the xml file that is not in the mapped class, it throws an exception.

It is almost as if I will need to write some sort of helper function that compares the Xml file to the mapped setting classes, and add/remove items from the xml file if it does not match...

Or, am I missing something

Thanks,

Dan



Re: .NET Base Class Library ConfigurationManager.OpenMappedExeConfiguration is very finicky

Feng Chen - MSFT

Hi dan,

Since you¡¯ve came across exceptions, we will appreciate if you can post the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Thanks!






Re: .NET Base Class Library ConfigurationManager.OpenMappedExeConfiguration is very finicky

dan blanchard

Feng,

I would be more than happy to post a sample project, how do I post, or who do I email to (the email in your profile )

thanks,

dan





Re: .NET Base Class Library ConfigurationManager.OpenMappedExeConfiguration is very finicky

Feng Chen - MSFT

Hi dan,

You can paste the code here; we just need them to reproduce the problem. And could you please cover the exception in more details You can post its stack trace, and inner exception here.

Thanks!






Re: .NET Base Class Library ConfigurationManager.OpenMappedExeConfiguration is very finicky

dan blanchard

Feng,

It is really not convenient to post all the code here, there are several classes and config files and project has dependancies, etc. It would be really helpful to be able to upload or email a project. Is this possible

Thanks,

Dan




Re: .NET Base Class Library ConfigurationManager.OpenMappedExeConfiguration is very finicky

dan blanchard

hmmm, after making a sample, I think I found my problem, when I added a new section I used ConfigurationPropertyOptions.IsRequired, so this is most likely why it was throwing an exception if it didn't exist! I changed it to ConfigurationPropertyOptions.None and it seems to work.

Thanks,

Dan