I’m trying to reference some DLLs which expose APIs to an installed application (Rhino 3d). These DLLs target .Net framework 4.5, and work on both Windows and macOS when developing plugins for said application. We have an example which loads one of the DLLs (by copying it to the project Assets folder) and uses the API. The example is here: rhino.inside/Unity at master · mcneel/rhino.inside · GitHub. While this works, copying the DLL to the Asset folder is not a solution we see viable going forward. The audience that will use this will have both Unity and Rhino installed, so we need that the Rhino DLLs stay in place.
While trying to extend the example, I’m having issues referencing another DLL. If I copy this DLL to the project Assets folder, Unity tries to load it, but it cannot resolve its dependencies. In the Unity console I see that the DLL cannot be loaded and it lists the dependencies with an error that it cannot find the dependency OR the dependency is not compatible.
I’ve tried other ways to load this dependency, for example with Assembly.LoadFrom()
which seems to work ok, but then I will have to reflect any part of the API that I need to use.
My application assumes the user is running Unity on Windows and has Rhino installed. For now I’ve been testing on Unity 2018.3.
Before going further, I’d like to ask:
- Can one reference DLLs for a Unity project WITHOUT copying them to the Assets folder? I’ve seen the documentation refer to csc.rsp for including other DLLs, but I am not sure if this will work with DLLs not in GAC. I’ve tried an assembly resolver, creating an event handler to catch resolving issues, but it seems by the time I add this code, Unity already complains that it cannot find the dependencies needed by the DLL.
- If there is no other way than to copy it to the Assets folder, what is a reasonable approach to resolve any potential dependencies a DLL might have?
Thanks!