none
[UWP] AccessViolationException USB devices

    Question

  • Hi,

    I'm developing a UWP app (target is 1803 version, using VS2017 with latest update). I'm encountering an unsolvable (for me) issue: when I try to retrieve a frame from a video file stored on a USB device added through a USB hub to my SurfacePro 2017, I always have a "AccessViolationException" for the following line of code:

    ImageStream stream = await mediaComposition.GetThumbnailAsync(TimeSpan.FromSeconds(0), decodePixelWidth, decodePixelHeight, VideoFramePrecision.NearestFrame);

    I tried to add the "HandleProcessCorruptedStateExceptions" attribute to the method containing the line of code but no way… the try/catch block doesn't work and the app crashes.

    Is there something I can do to handle this issue? I'm starting to be a little be desperate about it….

    Francesco



    Francesco Carraro

    Friday, November 2, 2018 11:33 AM

All replies

  • Hi,

    Well, what kind of USB device it is? Just a removable storage device or other kind of USB device? 

    If it is a removable storage, have you enabled the Removeable Storage capability in the manifest?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 5, 2018 6:52 AM
    Moderator
  • Hi,

    for your reply. The issue happens only with VIDEO files. No problems trying to visualize images. Also, in some recent tests, I saw that issue happened again with video files on main disk (C:). My main question is the following: is there a way to handle the AccessViolationException within the managed code in UWP? 

    thanks,


    Francesco Carraro

    Monday, November 5, 2018 8:15 AM
  • Hi,

    I checked the document for AccessViolationException . It mentioned that "An access violation occurs in unmanaged or unsafe code when the code attempts to read or write to memory that has not been allocated, or to which it does not have access." So it might be hard to handle this exception in managed code. It would be better to find out why this exception will occur.  My suggestion is that you could change the debug mode in the Visual Studio to Mixed so it debug both managed and native code. Like this:

    And does this happens on every video file?

    Another question, what's the USB device?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 7, 2018 8:54 AM
    Moderator