locked
Access USB device in a Windows UWP application using a native library (DLL) RRS feed

  • Question

  • We have the need to access a specific USB device from both the Linux and Windows platforms using C#, Java and possibly C therefore I am trying to develop a native library that can be cross compiled, on Windows and Linux, using Rust.  This seems to work well when I access the USB device within a test Rust Application.  From this application I am able to write to the USB device and get the expected results back.  When I link the DLL to a test Windows UWP application I am unable to open the USB port and receive an “Access is Denied” error.  I am linking the DLL to the test app as described here:  https://social.msdn.microsoft.com/Forums/en-US/26013e5e-3ff1-44a0-8797-0474dabd12d0/uwpincluding-dlls-in-a-uwp-application-in-visual-studio?forum=wpdevelop

    In the Package.appxmanifest file I defined the following capabilities:

      <Capabilities>
        <CapabilityName="internetClient"/>
        <DeviceCapabilityName="serialcommunication">
          <DeviceId="any">
            <FunctionType="name:serialPort"/>
          </Device>
        </DeviceCapability>
      </Capabilities>

    These capabilities allow me to communicate to the device using the standard Windows UWP communication APIs however it does not seem to allow me to access the device from within the linked DLL.

    Is it possible to allow a native library like this to communicate with a USB device when linked to a Windows UWP app?

    Thanks

    • Moved by Baron Bi Tuesday, July 3, 2018 8:02 AM More related to driver development
    Tuesday, June 19, 2018 5:51 PM

All replies

  • Bump.  Does anyone have any suggestions?
    Thursday, June 21, 2018 11:02 AM
  • Probably people see Rust and stop reading further...

    -- pa

    Thursday, June 21, 2018 11:18 AM
  • Doesn't need to be Rust, any native library would have the same issue from what I am seeing.  We picked Rust for the ability to write a library that is compatible across multiple platforms but it appears we would have the same issue if we wrote the library in C++.
    Thursday, June 21, 2018 11:41 AM
  • UWP has various obscure restrictions (for our own good, of course).

    Why you cannot make a normal "desktop" application? MS promises first class support for desktop apps (new APIs,  cool UWP & XAML controls will be usable from WinForms and even Win32).

    -- pa

    Thursday, June 21, 2018 4:09 PM
  • We could however we are not building a normal desktop application.  We are building an application that is designed to run on tablets with changing orientations and touch interface which is what the UWP apps are geared more towards.  

    It just does not make sense that we define the device capability to allow USB access and then we can not access it the way we need too.  And Microsoft wonders why developers have been moving away from their ecosystem. Wish they could at least give an official "Can't do it" if it can't be done so I do not waste a lot more time researching.

    Thursday, June 21, 2018 5:21 PM
  • Try to ask on the Windows Drivers forum. They should know there.

    -- pa

    Thursday, June 21, 2018 5:44 PM
  • Thank you for the suggestion, I just asked the question in the forum you suggested.
    Thursday, June 21, 2018 5:51 PM