外部.ocx控件的Visual Basic =>访问违规

时间:2016-04-12 10:11:06

标签: vb.net

我是这个网站的新手,我将立即开始提问。

目前我正在撰写一篇论文,但此刻我陷入困境。我被要求通过Beckhoff Twincat3控制一台IP摄像机。由于这是基于visual studio,我认为从Visual Basic开始测试和调试我编码的所有内容可能是个好主意。我做的每件事都会导致AccessViolation。

  

System.AccessViolationException未处理     的HResult = -2147467261     Message =尝试读取或写入受保护的内存。这通常表明其他内存已损坏。     来源= mscorlib程序     堆栈跟踪:          at System.RuntimeType.ForwardCallToInvokeMember(String memberName,BindingFlags flags,Object target,Int32 [] aWrapperTypes,MessageData& msgData)          at RASplus_WatSearLib._DRASplus_WatSear.setCameraMap(Int16 nCamNum,Int16 postKey,String szSiteName,String szAddr,Int16 nHostCam,String szUser,String szPasswd,Int16 port,Boolean mode,Boolean bUseModem,Boolean useDvrns,String szDvrnsAddr,Int16 dvrnsPort,Int16 audioPort)          at AxRASplus_WatSearLib.AxRASplus_WatSear.setCameraMap(Int16 nCamNum,Int16 postKey,String szSiteName,String szAddr,Int16 nHostCam,String szUser,String szPasswd,Int16 port,Boolean mode,Boolean bUseModem,Boolean useDvrns,String szDvrnsAddr,Int16 dvrnsPort,Int16 audioPort)          at activex_camera.Form1.Button1_Click(Object sender,EventArgs e)在C:\ Users \ BECKHOFF stage \ documents \ visual studio 2010 \ Projects \ activex camera \ activex camera \ Form1.vb:line 41          在System.Windows.Forms.Control.OnClick(EventArgs e)          在System.Windows.Forms.Button.OnClick(EventArgs e)          在System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)          在System.Windows.Forms.Control.WmMouseUp(消息& m,MouseButtons按钮,Int32点击)          在System.Windows.Forms.Control.WndProc(消息& m)          在System.Windows.Forms.ButtonBase.WndProc(消息& m)          在System.Windows.Forms.Button.WndProc(消息& m)          在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)          在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)          在System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)          在System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)          在System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID,Int32 reason,Int32 pvLoopData)          在System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason,ApplicationContext context)          在System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,ApplicationContext context)          在System.Windows.Forms.Application.Run(ApplicationContext context)          在Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()          在Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()          在Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String [] commandLine)          at activex_camera.My.MyApplication.Main(String [] Args)in 17d14f5c-a337-4978-8281-53493378c1071.vb:第81行          在System.AppDomain._nExecuteAssembly(RuntimeAssembly程序集,String [] args)          在System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)          在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()          在System.Threading.ThreadHelper.ThreadStart_Context(对象状态)          at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean preserveSyncCtx)          at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean preserveSyncCtx)          在System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态)          在System.Threading.ThreadHelper.ThreadStart()     InnerException:

我目前正在尝试连接相机,每次都会在AccessViolation中生成。

myCam.setCameraMap(i, CShort(0), "10.199.217.144", "10.199.217.144", i, "admin", "", CShort(8016), False, False, False, "dvrnames.net", 10088, 8116)

我希望有人能让我回到正轨。如果需要.ocx或其他文件,请随时与我联系。

1 个答案:

答案 0 :(得分:-1)

我问我的老师他是否知道什么是错的,他想出了这个:

在该计划中,我正在使用'实例' activex-control的。这导致了访问。他通过使用直接控制来修复它。

毕竟它是有道理的。 ;)

此致

GiovanniVanAssche