Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
656 views
in Technique[技术] by (71.8m points)

c# - Attempted to read or write protected memory. When I call showDialog method of openfileDialog

recently in my project when I call ShowDialog method of OpenFileDialog I get this error:

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

I have been searching all over the web before now but my problem did not solve. Also I installed microsoft patch, but because my project is in .Net 3.5, it was not useful.

Code Sample:

OpenFileDialog OFD = new OpenFileDialog(); 
OFD.ShowDialog();

Thanks for any help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

OpenFileDialog loads a large amount of unmanaged code into your process. All of the shell extensions that you have installed on your machine. One of them isn't very happy about your process environment, or messes with your process enough to make it crash and burn.

You'll need to find the shell extension that causes this. Start with Project + Properties, Debug tab, tick the "Enable unmanaged code debugging" option. You'll now see the list of DLLs that get loaded in the Output window. Odds are reasonable that the last one you see before you get the exception is the trouble-maker. Although you'll still have to reverse-engineer the DLL name to the shell extension name.

The other approach is slash and burn. Use SysInternals' AutoRuns utility. Click the Explorer tab and disable anything that wasn't made by Microsoft. Ask more questions about this at superuser.com


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...