System.AccessViolationException: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

来源:百度知道 编辑:UC知道 时间:2024/06/14 15:12:46
我的项目在本机上运行没有任何问题,一旦拿到别人电脑上就会报错,已经困扰我一阵子了,请大家赐教,十分感谢。
报错如下:
System.AccessViolationException: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
在 CodingHelp.UseDecryptDll.MDC_DecryptContent(StringBuilder pcDecContent, String pcSrcContent)
在 CodingHelp.EnCryDataTwo.DeEncrptData(String instr)
在 CodingHelp.EncryData.DeEncryData(String instr)
在 药名通_SQLSERVER_.frmPharm.tvPharm_AfterSelect(Object sender, TreeViewEventArgs e)
在 System.Windows.Forms.TreeView.OnAfterSelect(TreeViewEventArgs e)
在 System.Windows.Forms.TreeView.TvnSelected(NMTREEVIEW* nmtv)
在 System.Windows.Forms.TreeView.WmNotify(Message& m)
在 System.Windows.Forms.TreeView.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)
怎么没人答啊?是不是分太少了?

我也遇到过这个问题
主要原因是你的电脑系统没有装好,建议你重新安装系统,使用光盘安装或者U启动盘安装!不要用硬盘点击EXE安装

解决方案: 将dll里函数需要返回的局部变量声明为static。(就这么简单。原因就不重复了)