如题
代码非常简单,load的时候,HDevProgram都是新的了,执行的时候 HDevProcedure 也是新建的对象,调试模式可以看到对象都是新的,但是远程调试连上去,显示的代码时旧的
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using HalconDotNet;
- namespace HalconWinFormDebug
- {
- static class ExtendHalcon
- {
- public static void PrintAddress(this HDevProgram program)
- {
- }
- }
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- HDevEngine engine;
- HDevProgram program;
- HDevProcedure procedure;
- HDevProcedureCall procedureCall;
- void load()
- {
- program = new HDevProgram();
- string path = textBox1.Text;
- string b = System.Environment.CurrentDirectory;
- try
- {
- System.Diagnostics.Debug.WriteLine(path);
- program.LoadProgram(path);
- }
- finally
- {
- System.Environment.CurrentDirectory = b;
- System.Diagnostics.Debug.WriteLine("program loaded: {0}", program.IsLoaded());
- }
- System.Diagnostics.Debug.WriteLine(engine.GetLoadedProcedureNames());
- System.Diagnostics.Debug.WriteLine(engine.GetProcedureNames());
- }
- /// <summary>
- /// Start the f*cking debug server
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- if (engine == null)
- engine = new HDevEngine();
- engine.StopDebugServer();
- engine.StartDebugServer();
- System.Diagnostics.Debug.WriteLine("server started.");
- load();
- }
-
- private void debug_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Debug.WriteLine("start debug: {0}", program.IsLoaded());
- procedure = new HDevProcedure(program, "test");
- procedureCall = procedure.CreateCall();
- procedureCall.SetWaitForDebugConnection(true);
- procedureCall.Execute();
- System.Diagnostics.Debug.WriteLine("debug ended");
- }
- private void button2_Click(object sender, EventArgs e)
- {
- // a new program every click
- load();
- }
- }
- }
复制代码
|