1 在C#环境中引用了一个 OCX 控件 (成功的)
2 调用该控件一个方法:public virtual bool ReadLhtDefault(ref object mapDir, ref object codeDir, int mapScale, double centerB, double centerL, bool ifAllArea, double minB, double minL, double maxB, double maxL)前2个参数 :
mapDir 文件在的路径
codeDir 文件在的路径3 object o1 = "D:\\jb\\data";
object o2 = "D:\\jb\\data"; axGMapInfoSvr1.ReadLhtDefault(ref o1, ref o2, 1000000, 25, 121, true, 0, 0, 0, 0);
4 运行:
未处理 System.AccessViolationException
Message="尝试读取或写入受保护的内存。这通常指示其他内存已损坏。"
Source="mscorlib"
StackTrace:
在 System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
在 GMAPINFOSVRLib._DGMapInfoSvr.ReadLhtDefault(Object& MapDir, Object& CodeDir, Int32 MapScale, Double CenterB, Double CenterL, Boolean IfAllArea, Double minB, Double minL, Double maxB, Double maxL)
在 AxGMAPINFOSVRLib.AxGMapInfoSvr.ReadLhtDefault(Object& mapDir, Object& codeDir, Int32 mapScale, Double centerB, Double centerL, Boolean ifAllArea, Double minB, Double minL, Double maxB, Double maxL)
在 jb.frmMain.frmMain_Load(Object sender, EventArgs e) 位置 D:\jbpro\jb\jb\frmMain.cs:行号 25
在 System.Windows.Forms.Form.OnLoad(EventArgs e)
在 System.Windows.Forms.Form.OnCreateControl()
在 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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Form.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Control.set_Visible(Boolean value)
在 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(Form mainForm)
在 jb.Program.Main() 位置 D:\jbpro\jb\jb\Program.cs:行号 17
在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
2 调用该控件一个方法:public virtual bool ReadLhtDefault(ref object mapDir, ref object codeDir, int mapScale, double centerB, double centerL, bool ifAllArea, double minB, double minL, double maxB, double maxL)前2个参数 :
mapDir 文件在的路径
codeDir 文件在的路径3 object o1 = "D:\\jb\\data";
object o2 = "D:\\jb\\data"; axGMapInfoSvr1.ReadLhtDefault(ref o1, ref o2, 1000000, 25, 121, true, 0, 0, 0, 0);
4 运行:
未处理 System.AccessViolationException
Message="尝试读取或写入受保护的内存。这通常指示其他内存已损坏。"
Source="mscorlib"
StackTrace:
在 System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
在 GMAPINFOSVRLib._DGMapInfoSvr.ReadLhtDefault(Object& MapDir, Object& CodeDir, Int32 MapScale, Double CenterB, Double CenterL, Boolean IfAllArea, Double minB, Double minL, Double maxB, Double maxL)
在 AxGMAPINFOSVRLib.AxGMapInfoSvr.ReadLhtDefault(Object& mapDir, Object& codeDir, Int32 mapScale, Double centerB, Double centerL, Boolean ifAllArea, Double minB, Double minL, Double maxB, Double maxL)
在 jb.frmMain.frmMain_Load(Object sender, EventArgs e) 位置 D:\jbpro\jb\jb\frmMain.cs:行号 25
在 System.Windows.Forms.Form.OnLoad(EventArgs e)
在 System.Windows.Forms.Form.OnCreateControl()
在 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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Form.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Control.set_Visible(Boolean value)
在 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(Form mainForm)
在 jb.Program.Main() 位置 D:\jbpro\jb\jb\Program.cs:行号 17
在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
你的前2个参数是不是一定要指定有效哦。
其它语言下好使吗?比如用VB
object o1 = "D:\\jb\\data ";
object o2 = "D:\\jb\\data "; 改成string o1 = "D:\\jb\\data ";
string o2 = "D:\\jb\\data ";
试试看
这是什么控件啊,怎么会传Object呢
怎么是Object呢,它是什么类型啊,你把控件给我看看可以吗
发到我邮箱吧,有多大?[email protected]
3 object o1 = "D:\\jb\\data ";
object o2 = "D:\\jb\\data ";
axGMapInfoSvr1.ReadLhtDefault(ref o1, ref o2, 。
这样用是可以的