Search code examples
c#visual-studiounity-game-enginehololens

.dll, .winmd can be read in Unity but not in XAML project


I have a c++ .dll and .winmd from this solution. When I put them in a Plugin folder in Unity, build the Universal Windows project and deploy to the Hololens 2, the classes in the .dll and .winmd are recognized.

If I create a Visual Studio Universal Windows XAML project, copy the .dll and .winmd to the project path and include the .winmd via Reference-Add, all the classes are there during editing (no errors thrown during editing and building). When I build the solution, the .dll is also copied to the build path. If I, however, deploy and run the code, the project throws the following exception:

 'ResearchMode.exe' (Win32): Unloaded U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\78ac9912-63f6-43a8-b469-6e4684f8ea08VS.Release_ARM.cwule\HoloLensForCV.dll
onecore\com\combase\objact\dllcache.cxx(2132)\combase.dll!7728B3FD: (caller: 771AC799) ReturnHr(1) tid(178) 8007007E The specified module could not be found.
onecore\com\combase\objact\dllcache.cxx(4634)\combase.dll!771AC7B3: (caller: 771AB0A9) ReturnHr(2) tid(178) 8007007E The specified module could not be found.
onecore\com\combase\objact\dllcache.cxx(4766)\combase.dll!771AC7CB: (caller: 771AB0A9) ReturnHr(3) tid(178) 8007007E The specified module could not be found.
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Interop.dll
The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Am I including the .winmd and .dll incorrectly? What could be the reason why they are loaded correctly for the Unity project but not for the XAML project? Anything else I need to specify for these assemblies that Unity perhaps already does for me that I am not aware of?


Solution

  • Got it. The project above delivered a HoloLensForCV.winmd and a HoloLensForCV.dll and a opencv_world3411.dll. In addition to adding HoloLensForCV.winmd via Reference-Add (which copied HoloLensForCV.dll to the output directory), I needed to manually add opencv_world3411.dll to the solution via Add-Existing item (chose "Copy always").