Bug #69577 64bit ODBC Driver requires 32bit ODBC Driver (System.Data.Odbc)
Submitted: 26 Jun 2013 0:33 Modified: 26 Jun 2013 7:12
Reporter: Linc Merizon Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.2.5 OS:Windows (7)
Assigned to: Bogdan Degtyariov CPU Architecture:Any
Tags: 32, 64, bit, ODBC, system.data

[26 Jun 2013 0:33] Linc Merizon
Description:
When deploying my NET application using a standard Microsoft ODBC connection interfacing MySQL ODBC 5.2.5 64 ANSI I am required to install 32 bit version of the driver as well.

How to repeat:
Public WithEvents Connection1 As System.Data.Odbc.OdbcConnection = New System.Data.Odbc.OdbcConnection

Connection1 .ConnectionString = "DRIVER={MySQL ODBC 5.2 Unicode Driver};SERVER=127.0.0.1;UID=root;PWD=pass;DATABASE=db1;PORT=3306;"
Connection1 .Open()

RESULT:
-2146232009
ERROR [IM02] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
[26 Jun 2013 6:13] Bogdan Degtyariov
Hi Linc,

Thank you for your interest in MySQL software and for reporting the problem in it.
I do not think the behavior you observed is a bug because of the following reason:

NET applications are using the platform-independent managed code, which 
means they generally don't have native CPU instructions. Therefore, the 
native 32 or 64 bit code (in our case ODBC driver as a DLL) cannot be 
directly loaded by such applications.

From ODBC point of view the Microsoft NET Framework works as a wrapper from
System.Data.Odbc calls made inside NET applications with managed code to 
the ODBC driver with native code. This native code is loaded by the low-level
NET libraries that are platform-dependent as well. Therefore, it is 
important to take into account the platform options for your NET application.

The NET project properties -> build page has the platform setting
"Platform Target". By default it is set to x86 meaning that the native calls
are processed by 32-bit versions of NET system modules. It can be changed to 
x64 for 64-bit versions. The last option called "Any CPU" is more complicated
as it does not set the particular preference for 32 or 64-bit code. The 
decision which platform to use is made dynamically. This means
if the NET module is used by a 64-bit process the NET framework switches to
the 64-bit mode. For a 32-bit process it switches to the 32-bit mode. 
This mechanism puts limitations of not mixing 32 and 64 bit modules at the 
same time.

Check the screenshot showing the platform settings 
(bug_69577_platform_settings.jpg).

Please let me know if you have any other questions.
[26 Jun 2013 6:14] Bogdan Degtyariov
VS 2010 screenshot with NET project platform settings

Attachment: bug_69577_platform_settings.png (image/png, text), 38.17 KiB.

[26 Jun 2013 6:35] Linc Merizon
Thanks AnyCPU fixed the issue.
[26 Jun 2013 7:12] Bogdan Degtyariov
Thanks for your feedback.
Closing the report with "Not a bug" status.