Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 5-Oct-12 4:13am
ghoomes473
Edited 5-Oct-12 4:15am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
ghoomes at 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
Marcus Kramer at 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 at 5-Oct-12 10:47am
   
yes, you're right.. can i use some code to control APPCRASH error that doesn't show to user?!
Marcus Kramer at 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 at 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)

  Print Answers RSS
0 Richard MacCutchan 335
1 OriginalGriff 310
2 Sergey Alexandrovich Kryukov 207
3 Sharmanuj 146
4 Magic Wonder 129
0 Sergey Alexandrovich Kryukov 5,999
1 OriginalGriff 5,115
2 CPallini 2,473
3 Richard MacCutchan 1,597
4 Abhinav S 1,505


Advertise | Privacy | Mobile
Web02 | 2.8.140814.1 | Last Updated 5 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100