none
Access USB device in a Windows UWP application using a native library (DLL)

    Pertanyaan

  • 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

    Selasa, 19 Juni 2018 17.51

Semua Balasan

  • Bump.  Does anyone have any suggestions?
    Kamis, 21 Juni 2018 11.02
  • Probably people see Rust and stop reading further...

    -- pa

    Kamis, 21 Juni 2018 11.18
  • 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++.
    Kamis, 21 Juni 2018 11.41
  • 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

    Kamis, 21 Juni 2018 16.09
  • 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.

    Kamis, 21 Juni 2018 17.21
  • Try to ask on the Windows Drivers forum. They should know there.

    -- pa

    Kamis, 21 Juni 2018 17.44
  • Thank you for the suggestion, I just asked the question in the forum you suggested.
    Kamis, 21 Juni 2018 17.51