none
call winform app from wpf button click RRS feed

Answers

  • "Launching an app" means to start another app. Where that app resides isn't relevant. It can be in your solution or a third-party tool, doesn't matter. Process.Start, as I mentioned earlier, is the way to go. You don't need any interop libraries for this.

    private void LaunchAnotherAppButton_Clicked ( object sender,  RoutedEventArgs e )
    {
       //Start notepad or any other app that is in the search path
       Process.Start("notepad.exe");
    }

    But, as I already mentioned, if the apps need to communicate then you also need to implement some sort of IPC (sockets, WCF, etc). If they don't communicate then you don't need to do anything.

    If you have a winforms app that you want to render its UI within your WPF app then you'd get into interop but you'll need to move the winform controls into a class library that you can call. You cannot run 2 different apps in the same UI without going into ActiveX. This is the only place you'd need to worry about interop and it isn't pretty.

    • Marked as answer by Sunny Burman Wednesday, February 8, 2017 5:58 AM
    Tuesday, February 7, 2017 2:12 PM
    Moderator

All replies

  • Apps run in isolation so whether you are trying to start a winforms app or some other app isn't relevant here. All you need to do is call Process.Start. You can start any app but note they aren't connected in any way. There is an overload if you need to take more control over how the process gets started but the simply overload just requires the EXE name.

    Note that if you want to host controls from a Winforms app in a WPF app then that is an entirely different problem and needs to be posted in the WPF forums.

    Michael Taylor
    http://www.michaeltaylorp3.net

    Monday, February 6, 2017 4:10 PM
    Moderator
  • hope I am clear from my question.

    That I want to launch winform app when I click the button on wpf app. Both app are in same solution.

    What I have research there is some "Interop" library for the same but how to use this or is there any other ways.

    Regards

    Sunny

    Tuesday, February 7, 2017 11:54 AM
  • "Launching an app" means to start another app. Where that app resides isn't relevant. It can be in your solution or a third-party tool, doesn't matter. Process.Start, as I mentioned earlier, is the way to go. You don't need any interop libraries for this.

    private void LaunchAnotherAppButton_Clicked ( object sender,  RoutedEventArgs e )
    {
       //Start notepad or any other app that is in the search path
       Process.Start("notepad.exe");
    }

    But, as I already mentioned, if the apps need to communicate then you also need to implement some sort of IPC (sockets, WCF, etc). If they don't communicate then you don't need to do anything.

    If you have a winforms app that you want to render its UI within your WPF app then you'd get into interop but you'll need to move the winform controls into a class library that you can call. You cannot run 2 different apps in the same UI without going into ActiveX. This is the only place you'd need to worry about interop and it isn't pretty.

    • Marked as answer by Sunny Burman Wednesday, February 8, 2017 5:58 AM
    Tuesday, February 7, 2017 2:12 PM
    Moderator
  • Thanks buddy

    This explanation is really appreciated which is more than my one week research.

    I really convinced to that explanation . OK i will try this.

    Regards

    Sunny

    Wednesday, February 8, 2017 4:36 AM
  • Thanks a lot CoolDadTx it work for me.

    Steps followed

    • Compile the application in Release mode.
    • Open the solution folder
    • Open the project folder
    • Open the Bin folder
    • Open the Release folder
    • Copy the .exe file
    • Share it.

    And put the exe file name inside Process.Start function in wpf app.

    Code:

    private void LaunchAnotherAppButton_Clicked ( object sender,  RoutedEventArgs e )
    {
       //Start notepad or any other app that is in the search path
       Process.Start("feedback.exe");
    }

    Best Regards

    Sunny

    Wednesday, February 8, 2017 5:58 AM