Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my wpf c# application i am calling one c++ exe file, It is calling but it is closing automatically.

ProcessStartInfo s = new ProcessStartInfo();
s.WindowStyle = ProcessWindowStyle.Hidden;
s.FileName = example.exe;
System.Diagnostics.Process.Start(s);

Error name:example.exe has stopped working

What I have tried:

I called one c++ exe file from my c# application but it is closing automatically
Posted
Updated 13-Jun-16 23:43pm
v2
Comments
Jochen Arndt 14-Jun-16 4:47am    
We don't know what your exe is doing or should do. Test it standalone by executing it from a command shell or better by using a debugger.
Garth J Lancaster 14-Jun-16 4:49am    
In addition to Jochen's comment, you show no code - how are you starting the exe as a Process ? are you capturing stdout & stderr for example ?? if not, that might be a useful approach (if the exe outputs anything useful to the console)
Member 11559270 14-Jun-16 5:08am    
i am calling with process
phil.o 14-Jun-16 5:12am    
Unfortunately that is not informative enough. Please use the green "Improve question" button and qualify your question with relevant code you have so far.
Member 11559270 14-Jun-16 5:11am    
Is there any issues in calling Unmanaged exe in managed exe

1 solution

"Is there any issues in calling Unmanaged exe in managed exe"
No - when you start an application with Process.Start it's a completely independant app which shares nothing with the app that started it. It can be anything, including a file that causes Windows to open the associated program such as a web browser. Managaed / unmanaged is irrelevant.

But...The code you show won't compile as the FileName you set isn't a string.
Assuming you mean:
C#
s.FileName = "example.exe";
instead, then the most likely reason is that Windows can't find the file you specified. If it isn't in the current directory, or in a Windows application folder, or on the Windows Path then it won;t be found and that might cause your problem.
I'd suggest trying by giving an absolute reference to the EXE file:
C#
s.FileName = @"C:\Program Files\My Examples\example.exe";
And see if that fixes it.
Alternatively, if the file is being found by still shuts down immediately, it's probably that it needs some parameters you aren't supplying - so start by executing the app via a command prompt: Hold the Windows Key and press "R", then type CMD and press ENTER. Type the app name and see what happens. Probably, you'll get a "File not found" error, so use CD to get to the right folder, and try again.
 
Share this answer
 
v2
Comments
Member 11559270 14-Jun-16 5:48am    
yeah but i put that "example.exe" in my project Debug folder... so i didnt mentioned full file path
OriginalGriff 14-Jun-16 5:55am    
So use a command prompt to go to the debug folder and execute it manually.
What happens?

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