Hello,
I’m developing a WPF application that dynamically loads C# scripts, where each script is an independent class with its own methods. For example, I have a button that, when clicked, should call method ShowDate()
:
void ShowDate()
{
MessageBox.Show(DateTime.Now.ToString())
}
I want to enable debugging for these script methods. Specifically, I’d like to open the corresponding script in a separate process. Set up breakpoint inside of the method ShowDate()
. When I click button in my main process, breakpoint should hit. I’ve read about the AttachToProcess
debugger functionality which requires running in a different process from the main application.
Currently, I’ve partially implemented the ability to attach the debugger to the main application process when a script method runs. I’m toggling between ScriptRun
instances based on the debugging state: using the ScriptRun
instance created within the main application process when debugging isn’t needed and switching to a ScriptDebugger.ScriptRun instance created within a remote debugger application process when debugging is active.
The main challenge I’m facing now is passing the instance of ScriptDebugger.ScriptRun
from the remote debugger process to the main application process. I tried to follow the example in AlterNet.Studio.AllDemos.WPF
→ DebugRemoteScript
. Here’s what I’ve done so far:
Defined the ScriptAPI
with a method for remote debugging.
Created the RemoteScriptApi
class with two methods:
void StartServer(IScriptApi scriptAPI, string? ipcPortName = null)
;IScriptApi StartClient(string? ipcPortName = null)
.
The StartServer
method is invoked within the remote debugger application process when it starts. The StartClient
method is invoked within the main application process after the remote debugger application has been executed.
Could anyone provide any hints, advice, or a helpful demo to guide me in fully implementing this debugging functionality?
Thanks!