我發現需要從c#程序內啓動WPF應用程序。我寫了一個名爲eBrowse的簡單WPF瀏覽器作爲練習。然後,我被要求將它添加到已經在使用的c#程序中。想要C#程序啓動WPF應用程序
我試過System.Diagnostics.Process.Start(@"C:\eBrowse");
但它沒有奏效。
這是一個網站上找到另一種可能性:
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.
我想知道,如果它可能無法啓動從C#中的WPF應用程序。任何想法都會很棒。
謝謝大家的建議!不幸的是,WPF應用程序沒有.exe,我認爲這就是爲什麼我有這樣的麻煩。我已經檢查了多次,但沒有辦法從WPF獲取.exe。 – 2011-03-10 14:02:38
你用什麼來製作exe文件?我使用visual studio 2010,我的WPF應用程序有一個.exe。 – clamchoda 2011-03-10 14:58:10
你確定你有設置窗口來顯示已知的文件擴展名嗎? 在Windows資源管理器中,轉至工具 - >文件夾選項 - >查看選項卡 - >確保「隱藏已知文件類型的擴展名」未選中。 – clamchoda 2011-03-10 15:00:25