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

ShowDialog时出现尝试写入或读取受保护内存,内存损坏错误

Psap.Vft.App.Configure.ParaManage.ParaEditForm dlg = new Psap.Vft.App.Configure.ParaManage.ParaEditForm();

            if (this.lstView.SelectedItems.Count == 0)
            {
                dlg.ClassName = "";
            }
            else
            {
                Object obj = this.lstView.SelectedItems[0].Tag;
                if (obj == null) return;
                dlg.ClassName = obj.ToString();
                dlg.Description = this.lstView.SelectedItems[0].Text;
            }
            
            var dr = dlg.ShowDialog(this);
            if (dr == DialogResult.OK)
            {
                LoadDetails();
            } 


用的是Access2010作为数据库,用户控件里点击添加按钮打开模式窗体,这一句代码报错。 --------------------编程问答-------------------- dlg的显示窗体事件中是否做了什么 --------------------编程问答-------------------- private void ParaEditForm_Load(object sender, EventArgs e)
        {
            if (ClassName != "")
            {
                if (TypeName == "" && TypeValue == "") //添加操作
                {
                    this.txtClass.Text = ClassName;
                    this.txtName.Text = "";
                    this.txtValue.Text = "";
                    this.txtDescription.Text = Description;
                }
                else
                {
                    this.txtClass.Text = ClassName;
                    this.txtName.Text = TypeName;
                    this.txtValue.Text = TypeValue;
                    this.txtDescription.Text = Description;
                }
            }
            else
            {
                this.txtClass.Text = "";
                this.txtName.Text = "";
                this.txtValue.Text = "";
                this.txtDescription.Text = "";
            }
        }

只有这个窗体Load事件,是判断是添加操作还是修改操作。 --------------------编程问答-------------------- 而且很奇怪的是,出这个AccessViolationException错误,如果我用英文输入,也就是不启用中文输入法,不会报错。但是我一旦在文本框使用中文输入法,马上就报错了~ --------------------编程问答-------------------- 最好是能跟踪到具体哪句出错。。
一般是资源被释放掉后再使用会报这样的错误。。 --------------------编程问答-------------------- 跟踪不了啊~而且我用美国键盘输入法就不会出错。一换成搜狗输入法输入就出错 --------------------编程问答-------------------- 学会调试问题就解决了。 --------------------编程问答-------------------- 我选一个断点,然后出现一个窗体。我在上面用搜狗输入法打字。然后出现错误,这如何调试?况且,我用英文输入就一点问题都没有。求解释?! --------------------编程问答-------------------- 在 DevComponents.DotNetBar.ม.DrawThemeTextEx(IntPtr hTheme, IntPtr hdc, Int32 iPartId, Int32 iStateId, String pszText, Int32 iCharCount, Int32 dwTextFlags, RECT& pRect, DTTOPTS& options)
   在 DevComponents.DotNetBar.ᝩ.ᝮ(Graphics ى, String ڿ, Font บ, Rectangle ࣚ, ฮ ᝯ, Color ล, Boolean ᝰ, Boolean ᝱, Int32 ᝲ)
   在 DevComponents.DotNetBar.ᝩ.ᝮ(Graphics ى, String ڿ, Font บ, Rectangle ࣚ, ฮ ᝯ)
   在 DevComponents.DotNetBar.ᝩ.᝴(Graphics ى, String ڿ, Font บ, Rectangle ಋ, Boolean ᝵)
   在 DevComponents.DotNetBar.ᝩ.PaintCaptionText(RibbonControlRendererEventArgs e)
   在 DevComponents.DotNetBar.Rendering.Office2007Renderer.DrawRibbonFormCaptionText(RibbonControlRendererEventArgs e)
   在 DevComponents.DotNetBar.RibbonStrip.PaintControlBackground(ItemPaintArgs pa)
   在 DevComponents.DotNetBar.ItemControl.PaintControl(ItemPaintArgs pa)
   在 DevComponents.DotNetBar.ItemControl.ਡ(PaintEventArgs ل, Boolean ਢ)
   在 DevComponents.DotNetBar.ItemControl.ਝ(PaintEventArgs ل)
   在 DevComponents.DotNetBar.Office2007RibbonForm.ᬓ()
   在 DevComponents.DotNetBar.Office2007RibbonForm.WindowsMessageNCActivate(Message& m)
   在 DevComponents.DotNetBar.Office2007RibbonForm.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.UnsafeNativeMethods.SetActiveWindow(HandleRef hWnd)
   在 System.Windows.Forms.Application.ThreadWindows.Enable(Boolean state)
   在 System.Windows.Forms.Application.ThreadContext.EnableWindowsForModalLoop(Boolean onlyWinForms, ApplicationContext context)
   在 System.Windows.Forms.Application.ThreadContext.EndModalMessageLoop(ApplicationContext context)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   在 System.Windows.Forms.Application.RunDialog(Form form)
   在 System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   在 Psap.Vft.App.Configure.UserManage.UCUserConfigure.btnAdd_Click(Object sender, EventArgs e) 位置 E:\work\Psap.Vft\Psap.Vft_Solution\Psap.Vft.App\Configure\UserManage\UCUserConfigure.cs:行号 55
   在 DevComponents.DotNetBar.BaseItem.RaiseClick(eEventSource source)
   在 DevComponents.DotNetBar.BaseItem.InternalMouseUp(MouseEventArgs objArg)
   在 DevComponents.DotNetBar.PopupItem.InternalMouseUp(MouseEventArgs objArg)
   在 DevComponents.DotNetBar.ButtonItem.InternalMouseUp(MouseEventArgs objArg)
   在 DevComponents.DotNetBar.BaseItem.InternalMouseUp(MouseEventArgs objArg)
   在 DevComponents.DotNetBar.GenericItemContainer.InternalMouseUp(MouseEventArgs objArg)
   在 DevComponents.DotNetBar.Bar.OnMouseUp(MouseEventArgs e)
   在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 DevComponents.DotNetBar.Bar.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.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 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(Form mainForm)
   在 Psap.Vft.App.Program.Main() 位置 E:\work\Psap.Vft\Psap.Vft_Solution\Psap.Vft.App\Program.cs:行号 18
   在 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()

详细的错误代码 --------------------编程问答-------------------- 搜狗输入法可能有什么冲突了吧。这个不知道如何调查了。 --------------------编程问答-------------------- 有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。

************** 异常文本 **************
System.AccessViolationException: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
   在 System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   在 System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
   在 System.Windows.Forms.Control.DefWndProc(Message& m)
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 System.Windows.Forms.TextBoxBase.WndProc(Message& m)
   在 System.Windows.Forms.TextBox.WndProc(Message& m)
   在 DevComponents.DotNetBar.Controls.TextBoxX.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.4963 (win7RTMGDR.050727-4900)
    基本代码: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Psap.Vft.App
    程序集版本: 1.0.0.0
    Win32 版本: 1.0.0.0
    基本代码: file:///E:/work/Psap.Vft/Psap.Vft_Solution/Psap.Vft.App/bin/Debug/Psap.Vft.App.exe
----------------------------------------
System.Windows.Forms
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.4961 (win7RTMGDR.050727-4900)
    基本代码: 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.4968 (win7RTMGDR.050727-4900)
    基本代码: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.4927 (NetFXspW7.050727-4900)
    基本代码: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
DevComponents.DotNetBar2
    程序集版本: 9.3.0.5
    Win32 版本: 9.3.0.5
    基本代码: file:///C:/Windows/assembly/GAC_MSIL/DevComponents.DotNetBar2/9.3.0.5__7eb7c3a35b91de04/DevComponents.DotNetBar2.dll
----------------------------------------
System.Configuration
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.4927 (NetFXspW7.050727-4900)
    基本代码: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.4927 (NetFXspW7.050727-4900)
    基本代码: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Accessibility
    程序集版本: 2.0.0.0
    Win32 版本: 2.0.50727.4927 (NetFXspW7.050727-4900)
    基本代码: file:///C:/Windows/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
---------------------------------------- --------------------编程问答-------------------- 本地代码出错了 不好搞 --------------------编程问答-------------------- 楼上的说的我不懂。什么叫“本地代码”啊? --------------------编程问答-------------------- 你试试将ShowDialog方式改为Show来显示那个窗口。 --------------------编程问答-------------------- 最搞笑的是,我同事的电脑可以。他还没装Access2010。不过英文输入做增删改查都是没问题的
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,