当前位置:编程学习 > C#/ASP.NET >>

这个问题怎么调试?


************** 异常文本 **************
System.AccessViolationException: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
   在 System.Windows.Forms.UnsafeNativeMethods.IOleInPlaceObject.GetWindow(IntPtr& hwnd)
   在 System.Windows.Forms.AxHost.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)


************** 已加载的程序集 **************
mscorlib
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
    基本代码: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
ContentsView
    程序集版本: 1.0.4727.37063
    Win32 版本: 1.0.4727.37063
    基本代码: file:///C:/ContentsView.DLL
----------------------------------------
ESRI.ArcGIS.ArcMapUI
    程序集版本: 9.3.0.1770
    Win32 版本: 9.3.0.1770
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/ESRI.ArcGIS.ArcMapUI/9.3.0.1770__8fc3cc631e44ad86/ESRI.ArcGIS.ArcMapUI.dll
----------------------------------------
System.Windows.Forms
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
ESRI.ArcGIS.AxControls
    程序集版本: 9.3.0.1770
    Win32 版本: 9.3.0.1770
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/ESRI.ArcGIS.AxControls/9.3.0.1770__8fc3cc631e44ad86/ESRI.ArcGIS.AxControls.dll
----------------------------------------
ESRI.ArcGIS.Controls
    程序集版本: 9.3.0.1770
    Win32 版本: 9.3.0.1770
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/ESRI.ArcGIS.Controls/9.3.0.1770__8fc3cc631e44ad86/ESRI.ArcGIS.Controls.dll
----------------------------------------
Accessibility
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
System.Windows.Forms.resources
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
    基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_zh-CHS_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------
mscorlib.resources
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
    基本代码: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------

************** JIT 调试 **************
要启用实时(JIT)调试,
该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置
jitDebugging 值。
编译应用程序时还必须启用
调试。 --------------------编程问答-------------------- 先说明白你干了什么 --------------------编程问答-------------------- 你提供这些信息,没有可参考价值。 --------------------编程问答--------------------
引用 1 楼 bdmh 的回复:
先说明白你干了什么


这个是我用arcgis的示例程序做的一个DLL 插件,然后在我开发的机器上可以用,但是注册到别人的机器上在退出程序的时候就提示上述信息,两台电脑的配置一模一样。
源程序如下:

using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.ArcMapUI;

namespace CommandInheritingBaseCommand
{
    
    [Guid("46bd0933-acac-4c33-8669-1255db03ca5c")]
    [ClassInte易做图ce(ClassInte易做图ceType.None)]
    [ProgId("CommandInheritingBaseCommand.ZoomToLayer")]
    public sealed class ZoomToLayer : BaseCommand
    {
        #region COM Registration Function(s)
        [ComRegisterFunction()]
        [ComVisible(false)]
        static void RegisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryRegistration(registerType);

            //
            // TODO: Add any COM registration code here
            //
        }

        [ComUnregisterFunction()]
        [ComVisible(false)]
        static void UnregisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryUnregistration(registerType);

            //
            // TODO: Add any COM unregistration code here
            //
        }

        #region ArcGIS Component Category Registrar generated code
        /// <summary>
        /// Required method for ArcGIS Component Category registration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryRegistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            MxCommands.Register(regKey);

        }
        /// <summary>
        /// Required method for ArcGIS Component Category unregistration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryUnregistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            MxCommands.Unregister(regKey);

        }

        #endregion
        #endregion

        private IApplication m_application;
        public ZoomToLayer()
        {
            //
            // TODO: Define values for the public properties
            //
            base.m_category = "Developer Samples"; //localizable text
            base.m_caption = "Zoom To Layer CSharp"; //localizable text
            base.m_message = "Zoom to the extent of the active layer in the TOC"; //localizable text 
            base.m_toolTip = "Zoom To Layer CSharp"; //localizable text 
            base.m_name = "DeveloperSamples_ZoomToLayerCSharp"; //unique id, non-localizable (e.g. "MyCategory_ArcMapCommand")
            try
            {
                //
                // TODO: change bitmap name if necessary
                //
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }

        #region Overriden Class Methods

        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (hook == null)
                return;

            m_application = hook as IApplication;

            //Disable if it is not ArcMap
            if (hook is IMxApplication)
                base.m_enabled = true;
            else
                base.m_enabled = false;

            // TODO:  Add other initialization code
        }

        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IMxDocument mxDocument = GetMxDocument(m_application);
            ZoomToLayerInTOC(mxDocument);
        }

        #endregion

        #region "Zoom to Active Layer in TOC"
        
        public void ZoomToLayerInTOC(ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument)
        {
            if (mxDocument == null)
            {
                return;
            }
            ESRI.ArcGIS.Carto.IActiveView activeView = mxDocument.ActiveView;

            // Get the TOC
            ESRI.ArcGIS.ArcMapUI.IContentsView IContentsView = mxDocument.CurrentContentsView;

            // Get the selected layer
            System.Object selectedItem = IContentsView.SelectedItem;
            if (!(selectedItem is ESRI.ArcGIS.Carto.ILayer))
            {
                return;
            }
            ESRI.ArcGIS.Carto.ILayer layer = selectedItem as ESRI.ArcGIS.Carto.ILayer;


            // Zoom to the extent of the layer and refresh the map
            activeView.Extent = layer.AreaOfInterest;
            activeView.Refresh();
        }
        #endregion

        #region "Get MxDocument from ArcMap"
        
        public ESRI.ArcGIS.ArcMapUI.IMxDocument GetMxDocument(ESRI.ArcGIS.Framework.IApplication application)
        {

            if (application == null)
            {
                return null;
            }
            ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument = ((ESRI.ArcGIS.ArcMapUI.IMxDocument)(application.Document)); // Explicit Cast

            return mxDocument;

        }
        #endregion                     
                
    }
}
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,