Referencing external dll

Hello,

I’m trying to use a dll (based on .Net Standard 2.0 framework) in a Unity project, but I find no way to reference it from my Unity’s script. This dll contains some simple C# utilities that are not related to Unity.

I’ve read the documentation and other posts on the subject and did the following:

  • Compile de dll (was done before)
  • Drag and drop the compiled dll into Unity’s ‘Asssets/Plugins’ folder
  • The inspector told me that it targets the ‘.Net 4.x’ (but I don’t know why as it should be .Net Standard 2.0). Also .Net 4.x is not compatible with the Editor, so I’ve checked ‘Exclude platforms/Editor’.
  • After that I’ve created a Unity script and tried to reference the dll in it… but there is no accessible reference available

I am surely missing something, but what ?

Edit (following the accepted answer by @meat5000):

My utilities dll references itself both Newtonsoft.Json and Stackexchange.Redis.

Stackexchange.Redis is available for .Net 4.5/6 and .Net Standard 1.5.

My utilities dll needs to be .Net Standard as it is also used in Xamarin projects.

So using the experimental 4.6 setting in Unity solved the issue (at least that allows to reference the dll, as I’ve not tried to run the project for now).

Maybe try setting Runtime version to Experimental 4.6.
You can do this in Build Settings → Player settings. Might not help, though, as the API compatibility is still 2.0. I’d suggest recomiling the dll for your target platform if possible. How to: Modify the Target Framework and Platform Toolset | Microsoft Learn