I have an application that has reference to Microsoft.Data.SqlXml.dll assembly (part of SQLXML). But on different machines, depending on whether it’s live environment or test, or developers local PC, different versions of SQLXML are installed. This arises an issue: depending on destination machine I have to compile application against correct Microsoft.Data.SqlXml.dll assembly.
In Subversion I keep csproj and dll file that is used on live environment. When I have to test modules that take advantage of Microsoft.Data.SqlXml.dll locally, I change reference in project, and revert them back. But several times I forgot to rollback changes and I checked in csproj and Microsoft.Data.SqlXml.dll with version that didn’t comply with SQLXML installed on live server. As a result, I received runtime errors.
My question is: is there any way to dynamically load assemblies in runtime? I can have switch statement somewhere in application that would load correct assembly depending on entry in app.config (eg. env=”live|test|local”) ? Or perhaps there is another way to address this issue?
Thanks,Pawel
From Microsoft page:
Naturally you have to change the part
//Build the path of the assemblyusing what you need.