Unable to find type or namespace of imported DLL
Asked Answered
P

1

0

I downloaded the "smilenet-1.2.1-win64-academic" library from this page and imported the smileNET.dll in my Unity project. Then I restarted my visual studio, and when I tried to use the library, it gave me an error that the type or namespace could not be found. I tried using Smile; and using smileNET; as indicated in their documentation file Hello.cs but it did not work. I tried 64 bit version as well as 32 bit one. My unity version is 2018.1.8f1 64bit

When I inspected the downloaded dll, it said that the >NET version is v4.0.30319 while my VS2017 is running version 4.7.03056, could that be a problem?

Various things that I have tried:

  1. I also tried manually adding references. The option to add references was not appearing, so I clicked on Project>Referneces>Analyzers as shown below and then in the top menu clicked on Project>Add References and then added the smileNET.dll file. Doing so fixed the error (temporarily). When I closed my VS it asked me if I want to save the changes to Chem-o-Crypt.sln Assesmbly-CSharp*, so I said yes (although I doubt if it was really saved). But when I restarted my Visual Studio, I found that the reference was gone, and error popped up again. meh :/

enter image description here

  1. Also tried enabling compiling of unsafe code (just in case) as shown in the Unity documentation, but did not work either.

enter image description here

  1. I have another folder (Chem-o-Crypt/Assets/bayesserver-8.3/DotNet/Standard20/) which contains several other dlls that are working fine, so I pasted my dll there and it did not work.
  2. I have literally tried adding this dll in Chem-o-Crypt/, Chem-o-Crypt/Plugins, Chem-o-Crypt/Assets, Chem-o-Crypt/Assets/Plugins and what not, but it seems to be adamant and not working.
  3. Copied the 64 bit version of dll in Chem-o-Crypt\Assets\Plugins\x64 and 32 bit version in Chem-o-Crypt\Assets\Plugins\x86 which did not work either.
  4. Copied the dll at the root level of the Unity editor (e.g. C:\Program Files\Unity\Editor)
  5. This person was getting the same error as mine. Skip to time 15:21 to see, but I am not able to use his solution as the things in my project explorer are appearing differently. Basically the dll is not showing up there, just like it did for him.
Pertain answered 27/2, 2019 at 5:31 Comment(10)
In VS open your project and expand References node of {YourProjectName}.CSharp project in the Solution Explorer, can you find smileNET.dll in it?Georgenegeorges
Just to be sure: How exactly did you import the dll into your project? Did you place it under the root folder Plugins?Macle
The docu you linked also says The classes defined in SMILE.NET are located in Smile and Smile.Learning namespaces so shouldn't it rather be using Smile; or using Smile.Learning?Macle
@Macle I imported it using the Assets>Import new assets option, and 'using Smile is not working.Pertain
@shingo, no I do not see it in there, but they are populated my the Unity itself and not to be done manually.Pertain
@shingo, the option to add reference is also absent in my project, couldn't find it anywhere.Pertain
Dll's should be in the Assets/Plugins folder. Move them there for unity to understand that they are plugins. By hand if you must.Decollate
I copied the dll into the Assets/Plugins folder, and still the same error :/Pertain
I'm afraid it's not imported correctly. Manually copy the dll into Assets/Plugins, then restart Unity, open VS by Assets > Open C# Project menu, check whether the dll is in reference list. If it is still absent, delete all .csproj files in the project root folder then restart Unity again.Georgenegeorges
@Georgenegeorges I did as you said. Deleted all the .csproj files, restarted Unity, opened Assets > Open C# Project and still couldn't find the dll in VS references.Pertain
G
0

I download the dll, unfortunately this is a mixed assembly, see the picture, which is not supported by Unity.

unmanaged

Then some workaround can be:

  • Build and use native plugins

  • Create another C# program using smileNET.dll and communicate with Unity program.

Georgenegeorges answered 28/2, 2019 at 5:17 Comment(3)
Does that mean I will have to use [DllImport ("PluginName")] in every C# file where I want to use the functions from this dll?Pertain
Not everywhere, but you need create a wrapper file and import necessary functions in it.Georgenegeorges
I support this answer. You need to write your own c#, managed dll that wraps the functions you need from the smile dll. Then import both dlls in your Unity project using only your own to use the smile library indirectly.Slater

© 2022 - 2024 — McMap. All rights reserved.