Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello.
I'm programming a project that sent a file from computer to phone.
I use BluetoothCLTools-1.2.0.51 programs to discovery and send my files.
There is my code:
Process p = new Process();
                ProcessStartInfo psi = new ProcessStartInfo("cmd","/c"+@"btobex -n"MyPhone" "C:\A.txt"");

                p.StartInfo = psi;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = false;
                p.StartInfo.ErrorDialog = false;
                p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.CreateNoWindow = true;
                p.StartInfo.UseShellExecute = false;

                p.Start();

There is no problem when i use Command prom directly, but when start command prom by my code and sending file to phone if i select NO when my phone ask permission to receive file, the program has a error like this:
Problem Event Name=APPCRASH

there is no error when i use
Run->CMD
Posted
Updated 5-Oct-12 4:15am
v2

1 solution

I'm not sure about why you would get the APPCRASH and such, but my thought is that anytime you need to instantiate a process like this it would be wise for you to wrap the entire block in a try catch so that when anything unforseen happens in that 3rd party application you can at least deal with it gracefully in your code. I'm not assuming you haven't done this, but I thought it worthwhile to mention just in case.
If you use the try catch you can check for the APPCRASH state and "assume" that the user has selected no. Hopefully for you there aren't more situations that will cause this particular error to occur.
 
Share this answer
 
Comments
ghoomes 5-Oct-12 10:30am    
thank you for your answer..
error isn't in my code, I use try and catch, problem is from "btobex.exe" that i call it. there is no problem when i call it in CMD directly but when i call it in program the APPCRASH will Appear
fjdiewornncalwe 5-Oct-12 10:39am    
That is exactly why you need to handle that situation gracefully in your application. It's just one of those things that is necessary when dealing with 3rd party applications. I'm guessing that the APPCRASH is still occurring under the hood when you call the application directly, but the message doesn't get back to you using that method. You're likely only aware of it when attached to the process.
ghoomes 5-Oct-12 10:47am    
yes, you're right.. can i use some code to control APPCRASH error that doesn't show to user?!
fjdiewornncalwe 5-Oct-12 11:30am    
If the message pops up in a message box from the 3rd party app then I'm pretty sure there's nothing you're going to be able to do, but if your try-catch captures the error then you may be able to gobble the message.
ghoomes 5-Oct-12 11:51am    
oooh.. thanks.. :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900