当前位置: 代码迷 >> C# >> win7下 winform程序调用COM组件 运行提示 “访问内存位置失灵”
  详细解决方案

win7下 winform程序调用COM组件 运行提示 “访问内存位置失灵”

热度:489   发布时间:2016-05-05 05:19:06.0
win7下 winform程序调用COM组件 运行提示 “访问内存位置失效”
一个winForm程序,加载了一ActiveX控件,用来显示图形,程序编译完成后,在xp下运行正常,
但是在Win7 总是提示 内存位置访问无效,追踪代码报错的位置为:
((System.ComponentModel.ISupportInitialize)(this.axvg)).EndInit();
就是控件 结束初始化的地方。

采用管理员权限运行也不行,什么原因。

有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。

************** 异常文本 **************
System.BadImageFormatException: 内存位置访问无效。 (异常来自 HRESULT:0x800703E6)
   在 System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
   在 System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)
   在 System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)
   在 System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
   在 System.Windows.Forms.AxHost.CreateInstance()
   在 System.Windows.Forms.AxHost.GetOcxCreate()
   在 System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
   在 System.Windows.Forms.AxHost.CreateHandle()
   在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   在 System.Windows.Forms.Control.CreateControl()
   在 System.Windows.Forms.Control.WmShowWindow(Message& m)
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
   在 System.Windows.Forms.Form.WmShowWindow(Message& m)
   在 System.Windows.Forms.Form.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



------解决思路----------------------
你的操作系统是不是64bit的,强制你的程序集在32bit下运行。
  相关解决方案