之前由于不会用,所以在C#中一直不能捕获到异常,后面发现用这种方法可以。如下
private void Form1_Load(object sender, EventArgs e){HObject ho_Image = null;HTuple hv_Exception = null;HOperatorSet.GenEmptyObj(out ho_Image);try {try {ho_Image.Dispose();HOperatorSet.ReadImage(out ho_Image, "E:/testImage/00177.bmp");}catch (HalconException HDevExpDefaultException1) {HDevExpDefaultException1.ToHTuple(out hv_Exception);int errId = hv_Exception[0].I;string errMsg = hv_Exception[1].S;}}catch (HalconException HDevExpDefaultException) {ho_Image.Dispose();throw HDevExpDefaultException;}ho_Image.Dispose();}