Share via

Talking to a running WPF application from commandline arguments

More questions than answers 21 Reputation points
2022-07-12T20:42:22.767+00:00

I have a WPF application which starts without a window and has a main method as such in the App.xaml.cs,

static void Main(String[] args)

once the application is loaded and running I want to continue to send commandline arguments to it IF POSSIBLE e.g.

myApp.exe "string 1", "string 2"

And get it to react appropriately. Is this possible and if so how or what method should I use the do achieve this?

Developer technologies | Windows Presentation Foundation
0 comments No comments

Answer accepted by question author

Hui Liu-MSFT 48,711 Reputation points Microsoft External Staff
2022-07-13T14:36:30.003+00:00

Hi,@More questions than answers . Welcome Microsoft Q&A.
There are three ways to troubleshoot talking to a running WPF application from command line arguments. You could try to refer to it

  1. You can use Named Pipe classes in c# .
  2. You can pass files and the systemfileWatcher class.
    Put the files in a folder, then other processes will audit this folder, and finally you can transfer the information.
  3. You can use memoryMappedFile.
    Open a view to see the same mempry region and transfer data in each process.

For more details, you could try to refer to the solution here.


If the response is helpful, please click "Accept Answer" and upvote it.
 Note: Please follow the steps in our [documentation][5] to enable e-mail notifications if you want to receive the related email notification for this thread. 

[5]: https://learn.microsoft.com/en-us/answers/articles/67444/email-notifications.html

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.