Debugging native C++ code, called from managed C# library, executed by another app

238 Views Asked by At

I have the following setup: Third-party app (Autodesk Revit) executes my C# library thru C# Revit API (the library is Revit addon, named csapi). Then, my C# library calls another C++ native library (libbrowserhost-client-capid.dll) thru PInvoke.

My goal is to debug the native library in Visual Studio. I have either the C++ source and the symbols.

I am already able to debug it, if I rebuild my C# plugin lib as an executable and call the unmanaged library directly from the executable. In Visual Studio Output window I see the following:

'csapi.exe' (Win32): Loaded 'D:\Documents\Visual Studio 2017\Projects\browserhost-csharp-api\BrowserhostCSharpApi\bin\x64\Debug\libbrowserhost-client-capid.dll'. Symbols loaded.

The problem comes, when Revit becomes the first in the executing chain. The debugger omits native PInvoke calls (like Step Over). Output:

...
'Revit.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\Ondra\AppData\Local\Temp\RevitAddins\csapi-Executing-20180318_200947_6493\csapi.dll', Symbols loaded.
'Revit.exe' (Managed (v4.0.30319)): Loaded 'C:\Program Files\Autodesk\Revit 2018\MessageLogger.dll'
'Revit.exe' (Managed (v4.0.30319)): Loaded 'C:\Program Files\Autodesk\Revit 2018\log4net.dll'
...

But I can see no libbrowserhost-client-capid.dll loaded there.

First, this is an output of what? The debugger or the dynamic linker or whatever? Second, how do I achieve to load libbrowserhost-client-capid.dll to the Revit process to be able to debug it? Is it possible to load the DLL to VS debugger somehow manually?

0

There are 0 best solutions below