If you use a library such as the Microsoft Enterprise Library Data Access Application Block, you may quickly discover that this library is dependent on configuration information stored in the Application Configuration file in order to properly load and function.
Therefore, if you want to implement dynamic functionality to switch database connection information at runtime, you will inevitably want to learn how to modify the Application Configuration file and subsequently save this information back!
Unfortunately, discovering how to accomplish this by searching on the Internet is not as easy as you might think!
I went through a large number of articles and forum posts all providing differing solutions to this common dilemma.
In the end, this solution worked for me:
The biggest difficulty with working with this solution was getting timing information to work properly within my Unit Tests to verify the file changes were being written out correctly. Ultimately, I could not get the timing perfected in my Unit Tests (even by using an Ordered Test) and I consequently gave up trying to succeed with running these changes within Unit Tests!
Therefore, if you want to implement dynamic functionality to switch database connection information at runtime, you will inevitably want to learn how to modify the Application Configuration file and subsequently save this information back!
Unfortunately, discovering how to accomplish this by searching on the Internet is not as easy as you might think!
I went through a large number of articles and forum posts all providing differing solutions to this common dilemma.
In the end, this solution worked for me:
The biggest difficulty with working with this solution was getting timing information to work properly within my Unit Tests to verify the file changes were being written out correctly. Ultimately, I could not get the timing perfected in my Unit Tests (even by using an Ordered Test) and I consequently gave up trying to succeed with running these changes within Unit Tests!
No comments:
Post a Comment