Referencing two DLLs with same namespace in VB.NET
Posted on 2014-12-05
I'm rewriting an old program I originally wrote in VB6 with VB.Net. My old program referenced a MySQL 4.0.3 database. I am in the process of migrating everything to MySQL 5.5. The program is quite large (for me) and there are many tables to restructure. I will be working on this migration for months to come. (I cannot simply do a one-time upgrade of the MySQL tables from 4 to 5.5 for multiple reasons; that would be beautiful but not possible)
So for now I need to be able to access BOTH versions of MySQL from the same VB.NET application.
Here comes the problem. The current vb.net mysql connector cannot access any version of MySQL below 5.0. The older one is too old and incompatible with many of the automation features of VB.NET. So I am forced to use an older one alongside the current one. My goal is to simply have two references to the DLLs. But this is proving impossible as they both have the same namespace and I get ambiguity problems.
They also had the same filename so I created a copy of the old one and renamed it.
I scoured the net and found that a system exists to resolve this problem in C# using "extern alias" but that no equivalent solution exists for VB. I also saw several people suggest using a class wrapper for the old one, but I'm unsure how to do this without recreating all the classes.