The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
[UWP]Windows Runtime Component doesn't trigger RRS feed

  • Question

  • I followed this introduction: Run a background task when your UWP app is updated to add a task when app updated, but when I debug the task, the breakpoint doesn't catch, and the background task doesn't work.

    What I have done are: create a Windows Runtime Component project in the solution with IBackgroundTask and run method, reference it in my app, register it as Extension in Package.appxmanifest, modify the app version, set the app as auto build and deploy, set the debug action as "Do not launch, but debug my code when it starts", press F5.


    Friday, December 21, 2018 5:56 AM

All replies

  • Hi,

    According to the document, the background will be triggered only when there is some updates for your app. Have you tried to increase the package's version number and try to run the app again after you deployed a old version of the app?

    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, December 24, 2018 6:03 AM
    Moderator
  • Of cause I have modified the app version that greater than the previous one:

    What I have done are: create a Windows Runtime Component project in the solution with IBackgroundTask and run method, reference it in my app, register it as Extension in Package.appxmanifest, modify the app version, set the app as auto build and deploy, set the debug action as "Do not launch, but debug my code when it starts", press F5

    Monday, December 24, 2018 7:08 AM
  • Hi,

    Well, from your words, it seems that you haven't deployed or run your app on the device after you added the background task but before you modified your version? 

    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.

    Tuesday, December 25, 2018 7:02 AM
    Moderator
  • I know I have to run the app before I modify the version, should I edit my work like this:

    What I have done are: create a Windows Runtime Component project in the solution with IBackgroundTask and run method, reference it in my app, register it as Extension in Package.appxmanifest, set the app as auto build and deploy, set the debug action as "Do not launch, but debug my code when it starts", build and deploy and run the app, close it, modify the app version, press F5

    Tuesday, December 25, 2018 7:13 AM
  • Hi,

    I made a sample for this. I found that the break point does not trigger, but the task is finished. I tried the create a file in the local folder in the update task. Every time I changed the version number and run the app, the file could be created correctly while the break point is not triggered.

    So the task is actually finished but we could not debug it using the break point.

    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.

    Thursday, December 27, 2018 9:32 AM
    Moderator
  • Hi Roy,

    My code doesn't trigger, and the code didn't run in the background even if I increase the minor version, these code modify user's data that could make sure user's data could match app's new feature, so I must make sure these codes works correctly.

    I think we should report this issue to MS uwp department or someone.

    Thursday, December 27, 2018 9:46 AM
  • Hi,

    What's the OS version of your device? Have you checked if the entry point is the same as the name of the background  task?

    Could you please share me a demo that could reproduce the issue. This could help to locate the problem.

    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.


    Friday, December 28, 2018 3:21 AM
    Moderator
  • Hi

    The OS version is windows 10 1809 17763.195, and I checked the visual studio 2017 enterprise all the component are latest, and the sample package can download here.

    Friday, December 28, 2018 5:49 AM
  • Hi,

    The way you create a file in background task is not possible to work. UWP apps has different behavior with WPF apps in file permissions. For security reason, UWP apps could only access some locations that UWP apps have permissions. You could not directly access C disk if you do not have permissions.

    I test your code and it could works correctly after changed the code in background task like this:

     Windows.Storage.StorageFolder storageFolder =  Windows.Storage.ApplicationData.Current.LocalFolder;
                Windows.Storage.StorageFile sampleFile =  await storageFolder.CreateFileAsync("sample.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting);

    For more information about file permissions, please refer:File access permissions. For information about how to create files in UWP apps, please refer:Create, write, and read a file

    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, December 31, 2018 8:06 AM
    Moderator
  • OK, as you said this code could run in background, but our scenario is much more complex than this one, it is not only write a file, we need to request data from server, compare with the user data and find the difference, modify the difference and save it. And our users are globally located, we must test all the scenarios that make sure these function works good, so we need to debug it when we find anything unusual.
    Wednesday, January 2, 2019 2:03 AM
  • Hi,

    To confirm this, I'm asking the team to see if they could help with this. There might be some time delay.

    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.

    Thursday, January 3, 2019 8:03 AM
    Moderator
  • Thanks for support, mate.
    Thursday, January 3, 2019 11:08 AM
  • Hi,

    Currently, there is an alternative, instead of just breakpoints, try a Debug.WriteLine or something similar and watch the Output window's debug pane if you needs to debug the code immediately.  

    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.

    Tuesday, January 8, 2019 7:52 AM
    Moderator
  • When will you fix the debug issue.
    Tuesday, January 8, 2019 9:07 AM
  • Hi,

    The issue has been reported. But currently we don't know when this will be fixed.

    Thank you for your patience.

    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, January 9, 2019 9:36 AM
    Moderator