错误:尝试在c#中读取或写入受保护的内存 [英] Error : Attempted to read or write protected memory in c#

查看:530
本文介绍了错误:尝试在c#中读取或写入受保护的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我收到此错误

Hi,
I am getting this error

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.



这行代码: -


on this line of codes :-

DialogResult dr = openFileDialog1.ShowDialog();//error is here
          if (dr == DialogResult.OK)
          {
              label6.Text = openFileDialog1.SafeFileName;
              pictureBox1.BackgroundImage = Image.FromFile(openFileDialog1.FileName);
          }



我在谷歌搜索并找到100多个搜索结果,我读了大部分,但我找不到合适的解决方法这个。

我也改变了VS2010中的设置,即Option-> Debugging - >未选中在模块加载时压缩JIT优化(仅管理)。

仍然我的错误无法解决..



请帮助我出去..



问候

Jayanta


I searched on google and find 100+ searched result and I read most of them, but I couldn't find proper solution on this.
I also change setting in VS2010 which is Option->Debugging -> unchecked "supress JIT optimization on module load(Managed Only)".
Still my error couldn't resolved ..

Please Help me to out..

Regards
Jayanta

推荐答案

从开始调试器:在ShowDialog行上放置一个断点并运行app。当它到达该行时,调试器将停止并等待您。仔细查看OpenFileDialog并确保一切看起来合理。然后查看前面的代码行,看看是否有任何奇怪的东西(或.NET外)。如果一切正常,单步执行该行,看看会发生什么。



对于这样的问题没有简单的做这个修复:如错误所示, 这通常表明其他记忆已经腐败 - 这意味着在你继续前进之前试图找出什么,在哪里以及如何。所以从获取信息开始,因为你将需要它!
Start with the debugger: put a breakpoint on the ShowDialog line and run you app. when it reaches the line, the debugger will stop and wait for you. Look closely at the OpenFileDialog and make sure everything looks reasonable. Then look at the preceding lines of code and see if there is anything odd (or outside .NET) in that. If everything looks ok, single step execute the line and see what happens.

There is no simple "do this" fix for problems like this: as the error says, "This is often an indication that other memory is corrupt" - and that means trying to find out what, and where, and how before you can move on. So start by getting information, because you are going to need it!


这篇关于错误:尝试在c#中读取或写入受保护的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆