Update configuration in a Winforms class assembly

Jan 14, 2012 at 11:24 AM

I have a Winforms class assembly and would like to update the secure access setting. The documentation refers to adding the configuration in the web.config file. I have added these sections to the app.config file but this does not seem to help. 

Has anybody done anything like this? Why is not not possible to simply change the values in the code? I realise I can change the source code but would rather not if there is a better way.

Thanks

David

Jan 14, 2012 at 5:54 PM

Well I figured out the problem. By inserting the following line of code:

AppDomain.CurrentDomain.SetupInformation.ConfigurationFile

I could determine which config file was being looked at. Needless to say it was not the one that I had inserted my configuration into. When I tested the class assembly I had a Windows console application that was calling the class library. In that case it was the test application's app.config file that needed the configuration. The problem is that in the production environment it is going to be a third party application that calls my class library assembly. I have no way of accessing the third party config file (I tested this putting the configuration into the third party application and it worked but I will not be able to do this on the end user's machine).

I am not sure of any other way of getting around this other than adapting the source code so that the  secure access setting is read-write. I have now done this and it works fine.

Does anybody know of another way of solving this problem?

Thanks

David