Search Unity

System.Data not found in Unity 2017, VS2017

Discussion in 'Scripting' started by joostbos, Jul 17, 2019.

  1. joostbos


    Feb 4, 2015
    Apologies if this is a duplicate question, but i searched the Forum, I googled and I get completely lost in tools, versions, numbers and I don't know if this is a fault in my code or in Unity or in Visual Studio. So I hope someone can help me.

    I am trying to access a MySql database from my application and get a compile error in Unity that System.Data can not be found:
    Assets/Scripts/Database Entities/MySqlDbUtils.cs(19,19): error CS0012: The type `System.Data.Common.DbConnection' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'

    I do have 'using System.Data' in my code, but it seems to get greyed out automatically. When I open the file it is black and then it turns grey and I get a Visual Studio Error that tells me 'Could not load file or assembly 'Microsoft.VisualStudio.Data, Version='. I found out that this should be solved by repairing Visual Studio. Did that, but still the same problem.

    I have added the MySql.Data.dll and System.Data.dll to my plugins folder. Originally I had the most recent MySql.Data.dll version, but since that is targeted to .NET v4 it can not be used in the Unity 2017 editor (.NET 3.5/.NET2.0). I found MySql Connector 6.3.5 which contains the MySql.Data.dll version for .NET 3.5.

    I then found that I still need to add System.Data as a Reference in Visual Studio. I did that for the v2.0.0.0, because I did not find a System.Data.dll in C:\Windows\Microsoft.NET\Framework64\v3.5

    When I open the Add Reference window in Visual Studio I get the same Visual Studio exception about Microsoft.VisualStudio.Data.

    Nevertheless I can build the project just fine in Visual Studio, 4 projects succeeded. But in the Unity console I still get the compile error. This is driving me crazy, if it compiles in VS, why not in Unity?

    I've set the player settings to .NET 3.5 Stable and API to .NET 2.0, not the subset.

  2. Silloty


    Jan 8, 2018
    Hey man !

    I have the same problem right now. Were you able to fix it ?