4

I am attempting to compile a project as a UWP application for deployment on a Raspberry Pi 2 with Windows 10 IoT installed.

The project uses an open source framework that comes with a wrapper and a DLL.

I have recompiled the DLL to ARM and have placed the C# wrapper into my project.

I have added using into MainPage.xaml.cs and have used functions from the wrapper/DLL.

I copied the compiled DLL file to C:\Users\Public on the RPi2 using FTP and using ICACLS set the DLL to accessible by all.

When I run my application via the remote debugger I get:

Additional information: Unable to load DLL 'C:\Users\Public\snap7.dll': Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

Is what I am trying to do with DLL files on Windows IoT possible?

DdW
  • 890
  • 1
  • 18
  • 30
Nick
  • 58
  • 1
  • 4
  • Remeber that the C# wrapper must be compiled as AnyCPU. – osexpert Apr 05 '16 at 13:26
  • Did you use VS2015 Visual C++ "Blank Windows IoT Core Console Application" template and change configuration type to Dynamic link library (.dll)? – osexpert Apr 05 '16 at 13:35
  • I have encountered the exact same problem. My sollution was to add the dll to the sollution explorer. set property of the dll: "copy to output directory" to "copy if newer" then when i call the dll, I dont get access denied errors. You have to find the deploy directory though. Mine was in "C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\" – Frank Schrijver Sep 21 '16 at 14:57
  • the application will also need rights to any device/file you will call with the DLL – Frank Schrijver Sep 22 '16 at 09:22

2 Answers2

1

I think you're going about it the wrong way. You shouldn't need to do the following step:

I copied the compiled DLL file to C:\Users\Public on the RPi2 using FTP and using ICACLS set the DLL to accessible by all.

Just adding the DLL to your project like you did and setting it to "Copy Local = true" should be enough. When deploying, the DLL will automatically get copied to your bin folder.

vidalsasoon
  • 4,365
  • 1
  • 32
  • 40
  • When I try to add the compiled DLL to the project I get "..could not be added. Please make sure that the file is accessible, and that is is a valid assembly or COM component." I am adding it as a reference, is this the correct way? – Nick Nov 10 '15 at 15:16
  • Also, the DLL is written in C++ so cannot be added directly as a reference into a C# or VB project. Is there any way around this. – Nick Nov 10 '15 at 15:53
  • You can either find a way to import unmanaged C++ dll in your UWP app or create a managed wrapper around your C++ library so you can add reference in VS. Either way, it needs a new question – vidalsasoon Nov 10 '15 at 16:04
  • 1
    A wrapper is already in place to load the DLL. The issue is that the application cannot see the DLL that the wrapper is pointing to when the debugger runs the code on the Raspberry Pi. – Nick Nov 10 '15 at 18:12
  • if you use the wrapper provided (snap7.net.cs), change the location on line 43 in that file to [UWP app name]\\[pathto]\\snap7.dll – DdW Sep 05 '16 at 08:38
1

Generally native DLLs can't be used with UWP Apps. Also look closely at APIs not implemented with IoT-Core. There are tools for this.

David Jones
  • 542
  • 4
  • 13