locked
Debugging the PrintWwaDca app RRS feed

  • Question

  • I am playing with the PrintWwaDca sample and I want to debug the app when its invoked by the PrintTaskSettings contract ("more settings").  I know I can hit F5 and debug it normally, but doing so always opens the app with the Windows.ApplicationModel.Activation.ActivationKind.launch attribute (ref the program.js file in the sample's code).  I want it open with Windows.ApplicationModel.Activation.ActivationKind.printTaskSettings.  I think I need to attach a debugger but I'm not sure which process to use. 

    Any ideas? Is there a trick I am missing?

    Thanks


    Thursday, December 1, 2011 7:01 PM

Answers

  • Ah... think I found it.  There are javascript and C# background tasks in this sample...  To break in the javascript task set a breakpoint in the onTimer function!  If you are using full C# instead of the javascript C# code, I could not find a way to set the bp in the C# task if the main application is Javascript.

    Here is the trick to get this to work (debugging a managed object from a Jscript project without launching from the debugger):  Set the Debugger type to Managed only for the javascript project:

     


    Jeff Sanders (MSFT)

    Thursday, December 8, 2011 4:59 PM
    Moderator
  • Hey all,

    You cannot attach VS to WWAHost.exe and debug javascript. The javascript has been compiled at this point. Look for a solution to allow this scenario later however! For now you could do it old school and write out debugging statments to a file (something I had to do once).

    -Jeff


    Jeff Sanders (MSFT)
    • Marked as answer by Jie Bao Thursday, January 5, 2012 7:15 AM
    Tuesday, December 6, 2011 7:45 PM
    Moderator

All replies

  • Debug -> Attach to process, then attach to wwahost with script. You man need to select the "show all processes from all users" checkbox to see the process.
    Senior Dev for Windows Phone Services
    Thursday, December 1, 2011 9:57 PM
  • Thanks for the reply.  I tried the solution as you suggested and I get an error stating that "Script Debugging is not enabled for WWaHose.exe" and the attach fails (see attached image).  I've tried both VS 11 Ultimate and the preinstalled Express edition, both normally and as Admin.   Thoughts?

     

    Friday, December 2, 2011 9:30 PM
  • I have same issue here, a sample setup such a JS metro app include a DLL component, was trying to debug DLL code, but VS11 wasn't able to attach wwahost.exe
    Tuesday, December 6, 2011 4:55 PM
  • I was able to get a little further.  By debugging the device app I created in VS11, then going to a metro app and printing (while the device app was debugging), my device app gets properly invoked and even hits a breakpoint in VS.  Unfortunately, the debugger crashes a few moments later.  I thought this may be b/c the OS was putting the app in a suspended state but haven't been able to verify that.

    Tuesday, December 6, 2011 6:31 PM
  • Hey all,

    You cannot attach VS to WWAHost.exe and debug javascript. The javascript has been compiled at this point. Look for a solution to allow this scenario later however! For now you could do it old school and write out debugging statments to a file (something I had to do once).

    -Jeff


    Jeff Sanders (MSFT)
    • Marked as answer by Jie Bao Thursday, January 5, 2012 7:15 AM
    Tuesday, December 6, 2011 7:45 PM
    Moderator
  • Ah!  Thanks Jeff.  I'll try that. 
    Tuesday, December 6, 2011 9:11 PM
  • Update: Here is how you can debug a background JS process.

    I used the BackgroundTask sample to try this out since it was easier for me to repro.

    Steps,

    1. In the Solution Explorer, right click on the BackgroundTaskSample project

    2. Choose Properties

    3. Click the Debug nav tab on the left side

    4. Check the box "Do not launch, but debug my code when it starts" or if this is a C# app, choose the Debugging, item and set "Launch Application" to "No"

    5. Repeat steps 1-4 except for the BackgroundTask project

    6. Hit the Save All Icon

    7. Set a bp in the background task I chose the top of the Run() function

    8. Hit F5 to start debugging (note that the project does not start your app, but it says debugging.

    9. Launch your app from the Start screen by hitting the tile or typing the name of the app

    10. Register by hitting the Register button and kick off the background task by unplugging and reconnecting your network cable in this case).

    11. You will hit the BP! -Jeff


    Jeff Sanders (MSFT)

    Wednesday, December 7, 2011 2:26 PM
    Moderator
  • Thank you Jeff, the proposed solution however, doesn't work for me.

    First, BackgroundTaskSample project only has Launch Application=Yes/No option(I chose 'No'), didn't find such checkbox mentioned above.

    And after step#10. BP I set at top of Run() function was not hit either.

    -R

    Thursday, December 8, 2011 4:29 PM
  • You should set it for the BackgroundTask project.  You indicated you set it for the BackgroundTaskSample project.
    Jeff Sanders (MSFT)
    Thursday, December 8, 2011 4:31 PM
    Moderator
  • Ah... think I found it.  There are javascript and C# background tasks in this sample...  To break in the javascript task set a breakpoint in the onTimer function!  If you are using full C# instead of the javascript C# code, I could not find a way to set the bp in the C# task if the main application is Javascript.

    Here is the trick to get this to work (debugging a managed object from a Jscript project without launching from the debugger):  Set the Debugger type to Managed only for the javascript project:

     


    Jeff Sanders (MSFT)

    Thursday, December 8, 2011 4:59 PM
    Moderator