0

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?

Andy Coarse
  • 25
  • 1
  • 6
  • Can you not attach debugger to the process that is executing your dll? – Vidmantas Blazevicius Mar 18 '18 at 20:36
  • You have to enable unmanaged debugging to see such a notification. Or set a breakpoint in the native code. Project > Properties > Debug tab. – Hans Passant Mar 19 '18 at 00:46
  • I am able to attach the debugger to the process (Revit.exe) - this is what I am actually doing. Moreover, I am able to debug the C# lib, that is executed by the process. What I am not able to do, is to debug unmanaged lib, that is executed by the previous one. – Andy Coarse Mar 19 '18 at 00:47
  • I have unmanaged debugging enabled for all of the projects. – Andy Coarse Mar 19 '18 at 00:54
  • Did you add C++ lib as dependence in C# library? And you how did you debug the another app in Visual Studio ? As I know there are two ways: In project properties of your DLL project , in the the Debug tab, choose "start external program" as the the start action. So when debugging your DLL, VS will start the 3rd party exe. Or, In VS, at the "tools" menu, choose "attache the process" to attach to 3rd exe – Fletcher Mar 19 '18 at 09:52
  • I am using the second option for debugging ("attach to process"). What kind of dependency do you mean? The only dependency, I can specify in C# project, is to add another .NET assembly to "references" section. But I think, I cannot do this with native assembly, isn't it? – Andy Coarse Mar 19 '18 at 12:06
  • it can be added as link: https://learn.microsoft.com/en-us/cpp/build/reference/assemblylinkresource-link-to-dotnet-framework-resource and this reply also mentioned it: https://stackoverflow.com/a/29053746/9125096 , also here is setting debug in mixed mode: https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-debug-in-mixed-mode – Fletcher Mar 20 '18 at 07:46

0 Answers0