I have a simple C++ project which uses the CoCreateInstance to access and use some C# code (com-exposed class). The simple code looks like:
// ...
hr = CoCreateInstance(
CLSID_rclsid,
NULL, CLSCTX_ALL,
CLSID_riid,
reinterpret_cast<void**>(&pMyComServer));
if (SUCCEEDED(hr)) {
g_hr = hr;
g_pMyComServer = pMyComServer;
pMyComServer->GetData();
}
// ...
CoUninitialize();
// ...
The C# code is exposed in very standard way, something like that:
[Guid("D9084CEE-5C65-4AB6-9E10-2718595FAD83")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
[ComVisible(true)]
public interface IPipeClient
{
void GetData();
}
[Guid("6BEE99C5-CEB5-4B2B-B605-0E6648162AEA")]
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
public class PipeClient : IPipeClient
{
public void GetData(){...}
// ...
}
How can I debug the C# called by CoCreateInstance? That is when I open the C# project in debug mode and set breakpoints none is hit. Moreover also using debugging functions like Debug.WriteLine doesn’t print anything in C# project output window. The only way to “debug” this C# I found is using message boxes, which is not handy at all. Is there a way to enable better ways to debug such a “remote” code?