A couple of months ago I wrote about an error we encountered with WebsitePanel and MySQL 5.5. Essentially, this boiled down to WebsitePanel only recognising specific versions of the MySQL .Net Connector. The solution was actually very simple: tweak some entries in the web.config files.
Since then, we’ve upgraded WebsitePanel from 1.2.1 to version 2 (highly recommended) without any problems. A couple of weeks ago, we upgraded the MySQL .Net connector for a new project and promptly got the following error message:
System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.IO.FileNotFoundException: Could not load file or assembly 'MySql.Data, Version=184.108.40.206, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.
As before, this problem is very easy to fix. Simply change the following entries in the web.config in both WebsitePanel’s server and portal components (the default paths are c:\websitepanel\server andc:\websitepanel\portal respectively). If these entries don’t exist, create them.
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" /> <bindingRedirect oldVersion="0.0.0.0-220.127.116.11" newVersion="18.104.22.168" /> </dependentAssembly> </assemblyBinding> </runtime>
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" /> <bindingRedirect oldVersion="0.0.0.0-22.214.171.124" newVersion="126.96.36.199" /> </dependentAssembly> </assemblyBinding> </runtime>
The only line that changes begins with bindingRedirect and you need to change the value of newVersion to that of the version of the MySQL .Net Connector you have installed. In this case, 188.8.131.52.
The mistake here – and it was my mistake – was assuming that a known issue with WebsitePanel had been addressed in the latest version. Needless to say, there are now specific notes regarding upgrading the MySQL .Net Connector.
On a side note: I’ve been developing .Net websites using MySQL for well over 8 years now. I’ve very rarely run into this problem and it nearly has always occurred when I have deployed a website that utilises a much newer version of the connector than is installed on the server. One thing that I never done is to explicitly define a version of the .Net Connector. Whilst this may be considered not to be best practice in some quarters, it does go some where to accommodating differing installed versions of the connector, especially on shared hosting providers (i.e. servers outside of my direct control).