microsoft / ConcordExtensibilitySamples

Visual Studio Debug Engine Extensibility Samples
Other
122 stars 50 forks source link

How to use IDkmCustomMessageForwardReceiver? #55

Closed igadmg closed 4 years ago

igadmg commented 4 years ago

it is stated in documentation that IDkmCustomMessageForwardReceiver can be "Implemented by components that want to receive custom messages from the IDE". Can you provide and example hot send message from Visual Studio? Or at least which function should be used for this?

gregg-miskelly commented 4 years ago

If you have a Visual Studio package (or similar IDE side extension) you can create a custom message object (DkmCustomMessage.Create) and send it to a Concord component using DkmCustomMessage.SendLower.

igadmg commented 4 years ago

Ok, so i can use Concord class from my VSIX? Good, but DkmCustomMessage.Create need at least DkmTransportConnection, how can i get it from VSIX package? DkmTransportConnection.FindConnection need a connection Guid, I can probably send it from active debugger, but maybe there is easier way to get it?

Looks like local debugger connections all have the same Guid 'DkmTransportKind.Local'. So DkmTransportConnection.FindConnection(DkmTransportKind.Local) is the way to get it?

Or maybe current connection is exposed somewhere in Vs Shell api's and I should use them?

I found, DkmTransportConnection.GetConnections(), so i can enum all connections.

Thanks, @gregg-miskelly

gregg-miskelly commented 4 years ago

There are a couple of different options depending on what you are trying to do --

  1. If you are sending to a component which has a component level >100,000 (it will not load on the remote side), and if your concord component doesn't need to know a process and/or connection, then you can pass null for both process and connection.
  2. If your UI side component is always dealing with stack frames, you can use the debugger automation (EnvDTE.Debugger.CurrentStackFrame) API along with DkmStackFrame.ExtractFromDTEObject to obtain the current DkmStackFrame.
  3. You can subscribe to AD7 events (IVsDebugger.AdviseDebugEventCallback) and convert IDebugProcess2's to DkmProcesses via their unique (GUID) ids.
  4. If you just need any connection or process, you can use the static methods on DkmTransportConnection/Process to obtain the current set.