Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 10 Development : How do I debug the Windows Runtime Component (written in C#) which is consumed by Javascript code

I'm trying to develop a Windows 10 app as follows:

  1. The app is written using HTML5/WinJS
  2. The app consumes a Windows Runtime Component which I wrote in C#

I'm able to hit the break point in the javascript which invokes the method call to the WRC. But I'm not able to step into the code and see what's happening inside it. The reason for that is because the debugger is set to Script mode. If I set it to Native, then it will never hit the javascript code in the first place.

My problem, is that Visual Studio doesn't let me (to the best of my knowledge) to attach the source code of an external reference, so that I can put a breakpoint in it and run the debugger in native mode. Resharper has this feature, but I need a solution in Visual Studio.

Visual Studio DOES let me attach source code when I try to step into a reference from native code. I confirmed this by writing a dummy Windows 10 app using C#, and then tried to step into the invocation of the same Windows Runtime Component. When the source was not available, it asked me for the same and I was able to attach it and step through the code.

Does anyone have any ideas?

like image 423
Padawan Avatar asked Oct 07 '15 14:10

Padawan


People also ask

How do I debug C sharp code in Visual Studio?

To start debugging, select F5, or choose the Debug Target button in the Standard toolbar, or choose the Start Debugging button in the Debug toolbar, or choose Debug > Start Debugging from the menu bar. The app starts and the debugger runs to the line of code where you set the breakpoint.

How do I trace code in Visual Studio?

Begin code stepping by selecting F10 or F11. Doing so allows you to quickly find the entry point of your app. You can then continue to press step commands to navigate through the code. Run to a specific location or function, for example, by setting a breakpoint and starting your app.

What is WinRT used for?

C++/WinRT is an entirely standard modern C++17 language projection for Windows Runtime (WinRT) APIs, implemented as a header-file-based library, and designed to provide you with first-class access to the modern Windows API.


1 Answers

I had a similar problem. I have a C# Windows Runtime App which was referring the C++/CX Runtime component, and I couldn't get the break point to hit in the C++ code. The fix that worked was:

  • In the C# Project : Goto Properties
  • Select Debug Tab
  • Debugger type : For Application Process / Background process, select "Mixed (Managed and Native)"
like image 183
vine'th Avatar answered Oct 08 '22 18:10

vine'th