【发布时间】:2012-11-25 13:13:51
【问题描述】:
根据您可以在网络上找到的指南(例如来自 rick strahls 博客),我们为 foxpro(9 和 SP)创建了一个 .net (3.5) COM 控件
现在有时在 foxpro 中,我们在释放对象时会得到 C000005。
所以我们试图重现这个场景。当实例化和释放对象一百/千次时,我们得到了同样的错误。
我们使用一个空的 FoxPro SCX 表单和一个没有任何代码的简单 .net 按钮。
如果我们不释放 .net 对象,我们会得到类似的 .net 异常“尝试读取或写入受保护的内存”
".(完整的例外见底部)
这里是 VFP 代码:
Local lnAnzahl as Number, ;
lni as Number
set procedure to DummyProcedure.prg
lnAnzahl = val(inputbox("wie oft", "oft","0"))
for lni = 1 to lnAnzahl
thisform.newobject("cntTest","netcontrol","c0005nativetest.vcx")
thisform.RemoveObject("cntTest")
endfor
.net 错误信息
System.AccessViolationException: Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben。 Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist.北 System.Runtime.InteropServices.ComTypes.IAdviseSink.OnViewChange(Int32 方面,Int32 索引) bei System.Windows.Forms.Control.ActiveXImpl.ViewChanged() 贝 System.Windows.Forms.Control.ActiveXImpl.ViewChangedInternal() 贝 System.Windows.Forms.Control.OnInvalidated(InvalidateEventArgs e)
北 System.Windows.Forms.Control.NotifyInvalidate(矩形 无效区域) bei System.Windows.Forms.Control.Invalidate(布尔 invalidateChildren)
北 System.Windows.Forms.Control.WmUpdateUIState(Message& m) 北 System.Windows.Forms.Control.WndProc(Message&m) bei System.Windows.Forms.ScrollableControl.WndProc(Message& m) bei System.Windows.Forms.ContainerControl.WndProc(Message& m) bei System.Windows.Forms.UserControl.WndProc(Message&m) bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(消息& m) 北 System.Windows.Forms.Control.ActiveXImpl.System.Windows.Forms.IWindowTarget.OnMessage(消息& m) 贝 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&m)
北 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
这是一个已知问题吗? 任何建议我们如何解决它?
【问题讨论】:
-
看起来您在表单上使用了 ActiveX 控件。看起来它是越野车。请联系控件的供应商或作者以获得支持。
-
我同意,可能是 activeX 控件的问题。如果您创建了此控件,请尝试将一些日志记录到该控件中,以查看是否可以捕获错误或问题。
-
它的基本 .net 按钮只使comvisible 并设置适当的属性。
-
你提到了 Rick 的博客。您可以编辑您的问题并粘贴一个链接供我查看。过去,我为 Web 目的构建了许多 VFP COM 控件,但不知道您尝试执行的上下文基础。
标签: .net com foxpro visual-foxpro