Search Unity

Installed Npgsql in VS using nuget no issues, Unity throws error

Discussion in 'Editor & General Support' started by michaelc2024, Aug 10, 2021.

  1. michaelc2024

    michaelc2024

    Joined:
    Jun 21, 2021
    Posts:
    5
    Hi all,
    I installed Npgsql library on VS for a unity server project of mine, using nuget... and updated depdencies. This allowed me to declare 'using Npgsql' and write a test function using its methods without VS producing any errors... then I tab out to Unity.

    Unity is throwing me a missing namespace compilation error can't start the server.

    Any ideas? Are there additional steps when using 3rd party C# libraries in Unity from Nuget?

    Thanks in advance
     
  2. michaelc2024

    michaelc2024

    Joined:
    Jun 21, 2021
    Posts:
    5
    If there is any additional information that you need from me for helping solve this issue please let me know!

    * Unity version 2020.3.12f1 Personal
    * Visual Studio Community 2019 (v 16.10.3)
    * NuGet version 5.10.0
    * Npgsql version 5.0.7

    In VS solution explorer, when I expand:
    Assembly-CSharp -> References - I am able to see "Npgsql" here. And as stated, no errors in VS.
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,674
    VS is irrelevant, it's just an editor / debugger for Unity.

    Unity is what compiles your project.

    Is this package you speak of compatible with Unity?
     
  4. michaelc2024

    michaelc2024

    Joined:
    Jun 21, 2021
    Posts:
    5
    Hi Kurt-
    Yes it is compatible with Unity. I actually managed to solve this issue by crawling through the depths of the internet and piecing together a bunch of information... For anyone this may help in the future:

    1) Use NuGet to install the packages as you typically would
    2) For compatibility purposes you are going to want to use netstandard 2.0 version of DLL's
    3) Create a directory under your ASSETS called "Plugin"
    4) Copy over your Npgsql.dll file from the Packages folder to the newly created Plugin folder
    5) You will probably get more errors about dependencies that Npgsql needs... follow the breadcrumbs and keep copying over these DLL's until the errors are gone. Tada. For me, I needed to also add the DLL's for system.buffers, system.memory, system.numberics.vectors, system.runtime.compilerservices.unsafe, system.text.encodings.web, system.text.json, system.threading.channels, and system.threading.tasks.extensions.
     
    alyaghini, jiexdrop and Kurt-Dekker like this.
  5. alyaghini

    alyaghini

    Joined:
    Sep 6, 2021
    Posts:
    1
    You helped me big time, Thank you