ScriptDom versioning issues

I installed the 2016 SSMS client recently and in one way or another any of my apps that I have written that use the DacFx ScriptDom have all broken in slightly different ways. One app throws a type conversion error and another just failed to find any statements in a batch.

When I started debugging the problem I noticed that I got this when I started one of the apps from Visual Studion:

No way to resolve conflict between “Microsoft.SqlServer.TransactSql.ScriptDom, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91” and “Microsoft.SqlServer.TransactSql.ScriptDom, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91”. Choosing “Microsoft.SqlServer.TransactSql.ScriptDom, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91” arbitrarily.

I looked into it some more and because the ScriptDom is in the GAC, .Net ends up choosing the highest version available which in this case is a) a beta and b) not the version my app was created using.

To fix it I changed the properties of the reference in my project to be version specific:

Set the reference to ScriptDom.dll to be version specific

If you can’t rebuild your app for some reason then you can use the app.config to force it to stay at the correct version:

https://msdn.microsoft.com/en-us/library/7wd6ex19(v=VS.100).aspx (or if the url changes search for “Redirecting Assembly Versions”.