|
-
September 30th, 2008, 11:58 AM
#1
Memory error after invoking explorer
I have this in my code, under a context menu selection:
Process.Start("explorer.exe", "C:\\");
The program runs fine and I select this item from the context menu. The explorer window opens no problem and then the program stops in program.cs on this line:
Application.Run(new Form1());
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
The really strange thing is, if I step through this in debug, I can open the window over and over no problem. The second I remove the breapoint and run it, it crashes like above.
Any ideas? It seems to have a mind of its own.
Thanks!
-
September 30th, 2008, 12:10 PM
#2
Re: Memory error after invoking explorer
Are you trying to do an Application.Run from inside an Application.Run ? This won't work. You should already have an Application.Run in the main() function of your application for you to have a context menu in the first place.
Application.Run executes the windows message loop for your application (i.e. it processes all the windows messages for your application), with the form which it's given as the main top level form (i.e. the form which will close the application if it's closed). So you should only have and only need one windows message loop for each application.
What are you trying to do exactly ?
Darwen.
Last edited by darwen; September 30th, 2008 at 12:14 PM.
-
September 30th, 2008, 08:49 PM
#3
Re: Memory error after invoking explorer
"What are you trying to do exactly ?"
An on screen grid contains a path and filename. A context menu has the function, "Open contaning folder". I'm simply tring to have the application open an explorer window with the folder in the grid as the argument.
I wasn't sure if it was something to do with the grid value I was passing it so I hard coded one, as above. Even a valid hard coded path produces the error, *after* the explorer window is successfully opened.
Is there a different/better method for running a process such as explorer.exe from within a C# program?
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|