How to restart a Desktop Bridge app programmatically - wpf

I have a Desktop Bridge app which needs to have a "Restart" button.
I've got it calling RequestRestartAsync method on the CoreApplication (described in this blog post) - but at runtime it fails with reason "NotInForeground".
I wonder if this is because of the way the Desktop Bridge technology wraps the WPF application. Any ideas on how I can cause the app to restart?

This is a new feature which is introduced from Windows 10 Fall Creators Update (v10.0.16299.0). Please note that not all UWP APIs are available for desktop bridge apps. You could check this document UWP APIs available to a packaged desktop app (Desktop Bridge). The CoreApplication relevant APIs have not been listed on the document. So, you cannot use this APIs in desktop bridge app now.

You can restart a Desktop Bridge app in the same way you can restart any regular Win32/WPF app. Nothing specific about it being on the "desktop bridge". For example you could spin up a new process, exit the app, and then have the new process launch a new instance of your app (and then kill itself).
I agree we should make the RequestRestartAsync() API work for Desktop Bridge apps as well to make this easier. We have logged a workitem on our backlog based on your UserVoice post.

Related

What's the best way to send event notifications from a Winforms server application to a Blazor client application?

A few years ago I was instructed to build an Windows Desktop application to control several devices, add and check data from a local database among other stuff. At the time the answer was very simple and I decided to create a WinForms application that provided a solution to the request, the app would control the devices, it would store data in a local database and it would show the data in it's UI.
Even though it worked perfectly for a while, the project has now expanded a lot, to the point were it consists in several projects including two REST API services working on different servers as windows services, a Xamarin Android and iOS apps that access those servers and some other stuffs. Obviously, my dicision of not separating the original Winforms server application's UI from the server stuffs has kick me in the rear. Another problem is that the solution has been working for a long time and the client does not want to give me much time for updating (which by the way it would probably require to rethink everything) so he want me to give him a fast and simple solution to the problematic server - client scheme.
So again I decided to try a fast solution (probably not the right one, but its a matter of time) and created a Blazor app that connects to the local database and it would work in the same server where the winforms app is, guaranteeing that none one will touch that app.
The problem now is that I need a way to show real time notifications in the blazor web UI and update its datagrids, etc., when the winforms app receive an event from one of the devices. At first I thought of SignalR, being the blazor app the server for SignalR and the winforms just a client, but I have no experience with it. Although if SignalR is the answer I'll deal with it.
So, the question is: which is the best way to send real-time event notifications from a winforms application to a blazor app?
Thanks in advance

Show desktop notification from one windows app (WPF) to another using webservice call

I have created WPF app and installed in two different PC. now I want that when I click one button from app in 1st PC, then I should get desktop notification in 2nd PC.
So I don't know how it will be done. Whether I have to use WCF or not or anything else? If I've installed this app in multiple PC then how should I send notification to particular?
I've tried to use signalR but I didn't understand how to invoke windows form method.
The application will not be closed. it'll just minimized in the tray. so my idea is that we can invoke App method from using WCF and show notification.
I want this kind of notification for my app but from webservice:
You can use self hosted WCF like here:
https://msdn.microsoft.com/en-us/library/ms731758(v=vs.110).aspx
Use net tcp binding, it will not require administrative rights.
Also there is a need to maintain a list of addresses/hosts of the PCs where your app runs. Then according to some logic you have there, choose the one that should show your notification.
You can also use a central app that coordinates, it may be a web app. Then signalR can be helpful. It becomes like a standard chat app... google can find you plenty of implementations for that.

How to have a SharePoint action invoke a feature in a WinForms application launched by Click-Once?

We have a SharePoint site that our users have open all the time (type of dashboard for the business). We have a WinForms application that listens on a specific port for when the user clicks a web part on the SharePoint site, we take the JSON in the WinForms, parse the request and launch a feature in the WinForms. Essentially allowing a web site to launch a feature in a running WinForms app on the same client machine.
This worked great when we were running in XP. When we moved to Windows 7 (with elevated UAC), this feature stopped working. Since we launch the WinForms app via ClickOnce, and ClickOnce apps can't be Run As Administrator, our current code won't work.
We can't make the ClickOnce app Run As Administrator for all the reasons you see here on StackOverflow.
So my question is: how can we invoke a feature in a ClickOnce deployed WinForms app when a user clicks on something in SharePoint site? It is super easy to get the WinForms app to call a Sharepoint web service but I need to go the otherway.
You can invoke a ClickOnce application by calling the deployment manifest URL. If you want to be able to call the app and have it do something specific, call the deployment manifest URL and pass query parameters to it, then have the application handle the query parameters.
This article shows you how to handle query parameters with ClickOnce applications.

Start WPF application from link in browser?

We have a requirement to start a WPF application with specific parameters from a link in a browser.
We are wondering if this is possible?
As an alternative could we embed the web application in a WPF browser control, and read the values out of the html web page?
Several possibilities :
if you control the browser (i.e. if you are in an intranet scenario, and have the opportunity to deploy applications), you can :
create an activex or plugin that runs the application
register a new uri scheme to interpret the url of kind "yourapplication://yourarguments"
(complex): deploy a listening app ran under the user session, and from the webapplication, ask this listening app to run the target application
reduce the security of the browser (not recommended)
if you don't control the browser:
create a clickonce application... this involves a setup, but which does not require admin privilege
Moving to Silverlight also might be an option, depending on your needs. SilverLigth V5 (still in beta) notably adds the ability for an admin to control the rights of the application via a GPO
Note: My feelings is the later option (Silverlight) is far more preferable because it's a lot more cleaner and less security hole factor. However, it can only be done if your requirements fits into the SL features
It is not possible to call client app from a browser, previously it was possible from activex controls but for that you need to have a signed library, in wpf you can make browser based application but you cant embed your web app in it.
So partially you are correct if you used wpf app you will be able to launch application on client side but with browser it seems difficult until unless you make activex control
but still i am not 100% sure that with activex control you will be able to launch the app or not

Silverlight 4 launch a trusted application into the browser?

I just lost 5 hours looking for a answer which i haven't been able to find :p
First, I'd like to force a trusted application (i need to access the file system) to display into the browser. Based on what i found on google a trusted application must be installed and launched as a desktop application (also called out-of-browser application).
So, i want to have an installed application on the client side but meanwhile, the user must also be able to start this same application into a browser window when he goes on my web site. Is this possible ?
Second, I'd like to give to the user the possibility to start the application from the browser. To be clear, the application is installed on the client computer but i want a button on my web site which starts the desktop application. How can i do that ?
Thanks
The answers are sort of and no.
Yes you can run an application that has been installed on the client also in the browser. However, not all of the installed application features will be available. Anything that requires elevated trust will not work inside the browser.
No you can't launch the installed application programmatically from within code running in the browser. The best you can do is display a polite message to the user to the effect that they have this app already installed and in order to access all of its feature they will need to launch it.
Yes, it is possbile since Silverlight 5, see my answer on silverlight-4-elevated-permission-inside-the-browser

Resources