Bug #60421 Cannot build/compile app with Visual Studio 2010 targeting .NET Framework 3.5
Submitted: 10 Mar 2011 19:27 Modified: 11 Mar 2011 11:49
Reporter: Manfred Gloiber Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.3.6 OS:Windows (Windows 7, 32 and 64 bit)
Assigned to: CPU Architecture:Any
Tags: dataset, DataSet Designer, DataTable, multi, multi target, target

[10 Mar 2011 19:27] Manfred Gloiber
Description:
I cannot build my application anymore when I open and upgrade it with Visual Studio 2010 (Profoessional or Ultimate, same problem).

How to repeat:
I updated my application from Visual Studio 2008 to Visual Studio 2010 and I get this errors/warnings:

Warning	130	The primary reference "C:\Projects\blah\Data\bin\Debug\Data.dll" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.	C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets	1360	9	Business

Lots of other assembly references are mentioned and the solution doesn't compile anymore. Strange thing is that it only happens when I want to run/rebuild the solution. Rebuilding the Data.dll project only works but this doesn't help when I want to debug the application -> it errors out all the time.

Running msbuild /targetversion:3.5 MySolution.sln compiles fine, too.

I tried different MySql.Data.dll versions like 6.3.6, 6.3.5, 6.3.4 and one old version I found: 6.1.2.0 -> THIS ONE WORKS!!!

I tried the one installed by the MySql 6.3.6 installer and from the different mysqlXYZ-noinstall.zip files from the v2 folder (not v4 -> I assume that's the .NET version the assembly was built with but I didn't find that somewhere in the docs ... not that I was looking for it very hard).

I'm, referencing the MySql.Data.dll directly within a MyApp\lib folder (no GAC etc.).

I tried creating the solution and all of it's projects from scratch targeting 3.5 without success.

What I discovered (IMPORTANT?):
The Data.dll has a DataSet and as soon as I add a Table from the Server Explorer to the DataSet Designer it fails to build the solution. The Data project alone can be compiled.

Suggested fix:
I DON'T KNOW BUT I NEED ONE!!!
[11 Mar 2011 9:51] Bogdan Degtyariov
Manfred,

Thanks for reporting your concerns.
However, this is not a bug in MySQL Connector/NET. As you noticed, it has been built against NET Framework 4.0 and therefore loading it into the project with target Framework 3.5 is not going to work.

You can easily build the driver from the sources targeting Framework 3.5.
There are no special requirements for MySql.Data project (others such as Installer.VS2010 or MySql.VisualStudio.2010 might fail because they require additional components).
The source code for Connector/NET 6.3.6 is available here:

http://dev.mysql.com/downloads/connector/net/

Marking the report as "Not a bug".
[11 Mar 2011 11:49] Manfred Gloiber
Thank you very much! Building the MySql.Data.dll library from source and targeting the 3.5 framework seems to work.

It should be made more clearer to developers though and I wonder, why there are two folders in all that "mysqlXYZ-noinstall.zip" files namely v2 and v4 and even Reflector and ildasm shows framework 2.0 references only.

Regards