halcon c# 自带examples报错 Matching

发布于:2025-06-09 ⋅ 阅读:(20) ⋅ 点赞:(0)

最近开始学习halcon与C#的联合编程,打开Matching例程时遇到了下面的问题

“System.TypeInitializationException”类型的未经处理的异常在 halcondotnet.dll 中发生 
“HalconDotNet.HHandleBase”的类型初始值设定项引发异常。

System.TypeInitializationException
  HResult=0x80131534
  Message=“HalconDotNet.HHandleBase”的类型初始值设定项引发异常。
  Source=halcondotnet
  StackTrace:
   at HalconDotNet.HWindow..ctor(Int32 row, Int32 column, Int32 width, Int32 height, HTuple fatherWindow, String mode, String machine)
   at HalconDotNet.HSmartWindowControl.CreateHWindow()
   at HalconDotNet.HSmartWindowControl.HSmartWindowControl_Load(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Forms.UserControl.OnLoad(EventArgs e)
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

内部异常 1:
DllNotFoundException: 无法加载 DLL“halcon”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。
 

“HalconDotNet.HOperatorException”类型的未经处理的异常在 halcondotnet.dll 中发生 
HALCON error #1305: Wrong value of control parameter 5 in operator open_window

“HalconDotNet.HOperatorException”类型的未经处理的异常在 halcondotnet.dll 中发生 
HALCON error #8603: Interface library not available. Check www.mvtec.com/download for additional interfaces in operator open_framegrabber

问题分析:

缺少halcon运行相关的库

问题解决:

添加下面的库文件