1

I've found a need to launch a WPF application from inside a c# program. I had written a simple WPF browser called eBrowse as an exercise for me. Then, I was requested to add it to a c# program that is already in use.

I tried System.Diagnostics.Process.Start(@"C:\eBrowse"); but it didn't work.

Another possibility that was found on a website:

myProcess.StartInfo.UseShellExecute = true;
// You can start any process, HelloWorld is a do-nothing example.
//myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
myProcess.StartInfo.FileName = @"C:\eBrowse";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
// This code assumes the process you are starting will terminate itself. 
// Given that is is started without a window so you cannot terminate it 
// on the desktop, it must terminate itself or you can do it programmatically
// from this application using the Kill method.

I am wondering if it may not be possible to launch a WPF app from c#. Any ideas would be great.

4 Answers 4

5

I think you are not specifying your EXE name. Try following:

myProcess.StartInfo.FileName = @"C:\eBrowse\yourEXeName.exe"; 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, you are correct, but I didn't know it was buried in my bin/Debug directory. I am a little embarrassed for my first stackoverflow question.
1
using System.Diagnostics;

Process myProc;
myProc = Process.Start("calc.exe");

Compiled and run on my system with visual studio 2008/10.

Just swap calc.exe with the full path to your exe.

4 Comments

Thanks all for the suggestions! Unfortunately, the WPF application has no .exe and I think that's why I am having such trouble. I've checked multiple times but have found no way to get a .exe out of WPF!
What are you using to make the exe? I use visual studio 2010 and my WPF application has a .exe.
Are you sure you have windows set up to display known file extensions? In the Windows Explorer, to to Tools->Folder Options-> View Tab -> Make sure "Hide extensions for known file types" is unchecked.
Thanks again, and I wondered why I didn't get an .exe and it is odd that the program executes. (I did all this from Visual Studio 2010.) Yes, Windows Explorer is set to show all extensions, but no extension is shown for the file in question. Then I thought your strong question about where is the .exe? And it dawned on me that I didn't check the /bin/Debug directory. I went there and found the .exe and that solved my problem. I guess being new to WPF sent me into the weeds. But I am grateful for everyone's help here. Many thanks!!!
1

remember to add the .exe extension. CreateNoWindow should be false.

1 Comment

Thanks for the suggestion! I wrote on #4 how that the .exe was hidden from me and I didn't know it was there.
0

Will this work for you? Winforms/WPF interoperability

1 Comment

Thanks for the suggestion! I wrote on #4 how that the .exe was hidden from me and I didn't know it was there. I am ashamed of that but I guess WPF had me in a loop from working on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.