I am working on a commercial solution with is being hosted on Azure Websites. I love the hosting solution but not having full control of the server sometimes means you need to solve the problem properly rather than bodging something so that it works (we’ve all done it).
I am using SQL Server with HierarchyIds which are types not supported with C# out of the box. The DLL is supplied with SQL Server Developer edition but is also available via a NuGet package (Microsoft.SqlServer.Types)
I could then use all of the new SQL Server types and compilation/debugging was fine locally. The problem came after deploying to Azure. The exception received was
Could not load file or assembly ‘Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I checked everything was being correctly deployed yet whatever I tried it threw an exception. I checked the DLL versions and I was using 220.127.116.11 (which worked locally) but the exception was quoting 10.0.0.0.
The solution was to add an assembly binding to the web.config and redeploy. All working perfectly now.