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

前端 未结 3 449
北海茫月
北海茫月 2020-12-06 15:07

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

\"Attempted to read or write protected memory. Thi

3条回答
  •  死守一世寂寞
    2020-12-06 15:53

    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

提交回复
热议问题