WPF app not interacting with my Windows service - c#

I have a windows service which needs to open a WPF application based on an event.
I am done with coding and when I run a WPF application instance through a process from my custom window service then it opens the app but hidden to me.
I confirmed it's existence from task manager where my app instance has been created but APP GUI not visible to me.
I also tried using "ProcessExtensions" class available on Github but that didn't help.
Please suggest what should I do for this!
Some saying for IPC mechanism but that I don't wanna use. Please let me know how can I achieve it!

Related

Running my UI app (WPF App) inside Worker Service with C# .Net Core

I'm new in programming with .Net and C# and, as said in the title, I have a WPF app which is accessible in a system tray icon and I want to run it a windows service.
Typically, I want an output like it was described in an answer provided in a discussion here.
If you want it in the system tray I think what you'll have to do is make it a Windows service. I've only written 1 Windows Service and that was years ago, but I believe that's what you'll have to do. If I'm correct about writing a Windows service, then what I would suggest you do is create a new Visual Studio solution and add two projects to it. One would be a DLL which would run as a Windows service. The second project would be a WPF project that will be your UI the user interacts with. Then you'll have to use some messaging system to communicate between the two. For the action messages that would mimic what Outlook does, I've used some WPF toast messages to accomplish that. If you Bing/Google "WPF toast popup" you'll get lots of results.
I have many searched in Internet and find some helpful answers like:
URL1
You can't, not directly, because the windows service will necessarily start when the machine does, not when a user logs in. The service will also be running in a different context, likely as a different user. What you can do is to write a separate system tray based "controller" that interacts with the service.
URL2
It needs some effort to achieve. Well, just two hints: 1) use static property System.Environment.UserInteractive to detect in which mode your application is running, see http://msdn.microsoft.com/en-us/library/system.environment.userinteractive.aspx; 2) get rid of app.xaml, because it will force starting WPF Application in all cases; instead, create and run and instance of System.Windows.Application (or better, a specially derived class) explicitly and only for interactive mode, see http://msdn.microsoft.com/en-us/library/system.windows.application.aspx.
And, I could not apply their instructions.
Thanks advance!

How do I run a process in a UWP before displaying app

I've completed a winform project that handles a uri scheme (TEL:)
I'm now trying to do the same in UWP. I've successfully got the app launching on TEL activation.
How do I stop the app showing when its run with arguments? Run silent.
The app runs a task and closes. There is no need for the UI unless the user hasn't done the first time set up or there is an error.
I've been looking into prelaunch but before painting myself into a corner I wanted to ask a more experienced user what the best practice is as I would like to publish this application and follow best practice.
I've checked similar questions but they were after a background service.
Thank you.
Answer thanks to Nico Zhu.
Can not launch an app without displaying UI but it is possible to use 'FullTrustProcessLauncher' to run an exe instead.
More information on this can be found here

UWP to launch my application from WPF application

I have a Windows store app I want to run (if not running) or expand (if not expanded) of another of my app written in WPF.
Through The Process.Start() I could not do. Tell me, can this be done? Thanks for the help!
To launch an UWP app from another app, you could make use of deep linking.
Here is a great article describing exactly how to do that
In summary, you need to add a protocol declaration (essentially a URL with a custom scheme), handle the activation event and then you can launch that app by navigating to that URL from your other application.

Create a process not an application in C#

I've created a simple application that I wish to be a process and not show up as an application inside taskmanager, simply because it is not an application. It was intended to be a process.
You might want to read about Windows Services.
Walkthrough: Creating a Windows Service Application in the Component Designer
Creating a C# Service Step-by-Step: Lesson I
You don't give much information about what you application does, but either Console or Forms will be displayed on the TaskManager, and even as a process it will be shown over the Processes tab so I'm not sure what are your intentions with this.

C# app that will stay in the background and receive commands via cmd arguments?

I'm trying to make an app in Visual Studio with C# that will stay in the background and then other programs could start the app with just one argument and it will popup a notification (another form) with that argument.
I need the app to be consisted of just one process, i don't need multiple processes/instances of my app. I just want it to stay in the background and when someone starts the app with an argument, for example MyApp.exe "this is a notification", it will just pop up another form that will have that cmd argument in it, and it won't start the app as another process.
I hope you get my point, if you don't I can explain it more.
What you are wanting is more of a job for a Windows Service. A Windows Service is a program, with no GUI interface, that sits in the background and does something. The service is usually started when the computer boots up and stays running till the computer shuts down.
Communication between other programs and you service can be done using Windows Communication Foundation (or WCF). WCF allows communication between two applications using one or more transports.
Without using WCF, another way (although arguably less efficient) to "communicate" is through a database. Your service can monitor a table for rows added and your main program can add these rows whenever something needs to happen. The choice comes down to really what your end goal is.
Good luck!
Consider using named pipes (System.IO.Pipes)
or WCF's System.ServiceModel.NetNamedPipeBinding.
Other options are: old .NET Remoting or TCP/IP Sockets.
The 'background app' can be an Windows Service, but it won't allow showing any GUI form to the user, as background services don't have any forms.
For an easy way to create Windows "Background" Services see OpenSource TopShelf project.

Categories