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作为数据库,用户控件里点击添加按钮打开模式窗体,这一句代码报错。

解决方案 »

  1.   

    dlg的显示窗体事件中是否做了什么
      

  2.   

    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事件,是判断是添加操作还是修改操作。
      

  3.   

    而且很奇怪的是,出这个AccessViolationException错误,如果我用英文输入,也就是不启用中文输入法,不会报错。但是我一旦在文本框使用中文输入法,马上就报错了~
      

  4.   

    在 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()详细的错误代码
      

  5.   

    有关调用实时(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
    ----------------------------------------
      

  6.   

    你试试将ShowDialog方式改为Show来显示那个窗口。
      

  7.   

    最搞笑的是,我同事的电脑可以。他还没装Access2010。不过英文输入做增删改查都是没问题的