Reputation: 559
I have created a small C# library prototype which has an Invoke
function.
public class TestClass
{
public async Task<object> Invoke(dynamic input)
{
Dictionary<Type, IReport> reports = new Dictionary<Type, IReport>
{
{typeof (LevelOne), new LevelOneReport()},
{typeof (LevelTwo), new LevelTwoReport()}
};
ILevel toTestLevel1 = new LevelOne(1);
ILevel toTestLevel2 = new LevelTwo(2);
IReport report = reports[toTestLevel2.GetType()];
return report.Generate(toTestLevel2);
}
}
The result of the function is a new object which has an int
in it. I've confirmed in my node/electron/edge.js app that the data is being successfully passed from the C# dll to my app. (i.e. the C# code and JavaScript are working together as I expect them to.)
Since this is a prototype for a more complex system, I would like to be able to attach the Visual Studio debugger to the node (or electron?) process, have it load the debugging symbols file for the C# dll and allow me to step through my C# dll according to the Edge.js documentation (See the github page here). I've copied the C# dll and .pdb file to the electron app directory.
So, I set a breakpoint in my C# class in Visual Studio and then went to attach the debugger to the "Managed" node.exe process. The first thing I noticed is that there were two node.exe processes running, neither of which had the "Managed" description mentioned in the documentation.
I tried attaching first to one, then the other but could not get my breakpoint to be hit after my edge.js invocation of the C# dll function. I checked the Debug->Windows->Modules and saw that no modules are actually being loaded. Frustrated, I attached the debugger to the electron process (which has the "Managed" description) and my C# dll suddenly appeared with symbols loaded in the Debug->Windows->Modules page! Alas, my breakpoint was still not being hit.
Does anyone know if there is a way to get the debugger in Visual Studio to actually attach to the node/electron app and allow detailed debugging in the associated C# dll?
Upvotes: 2
Views: 1308
Reputation: 559
Ok, I figured it out. There are three electron.exe processes also running. I kept the Debug->Windows->Modules viewer open in Visual Studio then ran my electron/edge/node app. Using the debugging tools there, I put in a breakpoint before the function call to my C# dll and ran it. It stopped on the breakpoint. I then attached the debugger to the first electron.exe process and set my breakpoint in the C# class. I then stepped over my call to the C# library. I repeated the process for each electron.exe process. The electron.exe process that DOES have the "Managed" description worked and I was able to hit my breakpoint in the C# dll and step through the code! Each time you step through the call from the electron app to the C# code, I could see it loading my debugging symbols in Visual Studio in the Modules viewer.
EDIT Through further use and testing, the "Managed" electron process does not appear until the electron-edge require function is called in javascript. So if you don't see the "Managed" electron process, make sure your breakpoint is set somewhere after this call.
Upvotes: 3