I'm recently looking into the file-sharing features of Windows Phone 8.1. One possibility is, to do this via file extensions. My question is, how exactly my app gets access to a launched file that it registered to handle.
I know that in WP8 this was done with a URI and a file token (https://msdn.microsoft.com/en-us/library/windows/apps/jj206987%28v=vs.105%29.aspx), but since the SharedStorageAccessManager class is not available anymore, I guess that it must be done different in 8.1.
So: What happens on "OS-level" in Win8.1/WP8.1 when an app is launched via a file extension, and how does the target-app actually get the launched file?
Thanks in Advance!
The app can register as a file handler in its Package.appxmanifest. Openthe manifest designer in Visual Studio, go to the Declarations tab, and add a File Type Associations declaration. You'll be prompted to fill out the details.
The app's Application.OnFileActivated method will be called with the launched StorageFiles in the FileActivatedEventArgs.Files property.
See How to handle file activation and the Association Launching sample for documentation and walkthroughs.
At a system level this all gets stored in the registry and when the launcher is called on a file the shell looks up the association then uses COM (or historically command line parameters or DDE) to launch or connect to the app registered for the file type. The details are hidden from Windows Runtime apps but are more directly exposed to desktop apps on Windows. See File type and URI associations model Implementing a Custom File Format
Related
We have a web application which is used to manage a list of main records in a database via a Spring Boot Web server talking to a back-end Java Server.
We also have a JavaFX standalone application which is used to graphically manipulate sub-records of these main web records, using a similar connection to the back-end Java Server.
We want to be able to launch this JavaFX application by clicking on a link next to each of the main records in the web interface. We would like to do this as seemlessly as possible.
At the moment the only way I can think that we can do this, is to use the Browser's 'Applications' set up to associate a particular MIME file type with the standalone JavaFX application, and somehow pass the UID of the record we click on as the 'file' being 'downloaded'.
Trouble is I'm not really sure what I should be googling for, to find out about this download process. For instance, does the browser pass the 'file' in a MIME message that is passed to the application, or does it save the 'file' in a temporary directory and then call the application with the temporary file path?
Has anyone done this sort of thing before, that could give us some pointers?
I don't have a turnkey solution but I think what you are looking for is a custom URI scheme (like the Magnet URI scheme magnet:, mailto:, or tel:).
Here is an article about launching applications using custom browser protocols and here is how to register an application to a URI Scheme on Windows.
You will have to modify the Windows Registry to link your custom protocol to an application, it looks like:
HKEY_CLASSES_ROOT
alert
(Default) = "URL:Alert Protocol"
URL Protocol = ""
DefaultIcon
(Default) = "alert.exe,1"
shell
open
command
(Default) = "C:\Program Files\Alert\alert.exe" "%1"
I am observing a strange situation where my app passes WACK on my computer, but submission to the store fails at Certification stage, due to unsupported APIs. I am using MSVC 15 Update 2.
Solution Consists of:
Universal APP
Class Library (Universal Windows)
Class Library (Portable)
EF Core RC2
Syncfusion SfChart.UWP.dll
Store Certification output:
Error Found: The supported APIs test detected the following errors:
API sysctl in libc.dll is not supported for this application type. Microsoft.Extensions.PlatformAbstractions.dll calls this API.
API uname in libc.dll is not supported for this application type. Microsoft.Extensions.PlatformAbstractions.dll calls this API.
API RtlGetVersion in ntdll.dll is not supported for this application type. Microsoft.Extensions.PlatformAbstractions.dll
calls this API.
As mentioned, no errors are spotted by WACK on my machine. I tried both WACK that comes with visual studio and WACK that's installed separately.
Could "Class Library (Portable)" cause this just by it's existence?
Update: It's not the portable class library, i removed it and still get the same certification failure.
This was caused by entityFrameworkCore.Tools. They are still pre-release and do not support .net native properly.
There is a workaround, but you can also simply remove it from the project before compiling it with .net native and submitting it to the store.
Are you expecting Microsoft.Extensions.PlatformAbstractions.dll to be included in your package? It's possible that this is getting included in the packages built into the .appxupload file, but not in the packages you build locally to test. I have seen some recent cases where the project is including references to dlls that are unnecessary in the package and are not compliant. You may want to investigate this angle and verify if this file is being included incorrectly.
One way to validate locally why you might be passing is to check the programinventory_*.xml file in %localappdata%\Microsoft\appcertkit, and see if you can find any references to Microsoft.Extensions.PlatformAbstractions.dll. If the file is not found when locally testing, then your best bet is to investigate your project and why it's getting including when you build the .appxupload file to submit to the store.
We have a SPA web application that we're trying to convert into a WinJS project as a native Windows Store app. For most part, the Javascript is working except for DOM manipulations deemed unsafe.
One thing that does not appear apparent is, how can the start page of the app (e.g. index.html) be supplied with query string and hash parameters? Our site main page is designed to behave differently based on parameters.
e.g. index.html?contextId=xxxxx#enviroment=xxxxx
I tried adjusting the value in package.appxmanifest to no avail. It will throw errors on query strings, and hash parameters will silently not persist.
UPDATE: Project background
A brief about what our app does, and then why the above naive desire won't work and the answer below how we went about this issue.
Our web app is a highly-dynamic data-driven application that completely relies on data to figure out what to render. Therefore the ?contextId=xxxxx parameter is so crucial as it tells our system to load the data which further informs what kinds of visual components to load and it goes on recursively to form wildly different UIs.
We were looking to therefore find some means to supply these parameters like traditional command-line parameters to the same executable to produce different UIs. And thus different "apps" by mere changes in those parameters. Like a "config transform" mechanism for web.config in ASP.NET web projects, that would be most welcome.
However further testing showed it is not possible; a single Windows store app project has a GUID that is supplied into the packaged app bundle. Building the same project multiple times with different "build config" would just mean overwriting a previous installation since they are the same app with increasing version numbers. The answer details how we went about this.
Windows Store apps don't work with URI parameters when launched from their primary tile. In that case, you should make sure that the app defaults to suitable values, e.g., if you were thinking to supply defaults in the manifest, then default to those in the app's activation handler for the ActivationKind.launch case when eventObject.detail.arguments is empty.
There are two other ways to launch an app that can supply other arguments.
First is to launch via a secondary tile. When you create the tile from the app (which is subject to user consent), you supply the launch arguments. In your activation handler, for ActivationKind.launch, those args will be in the eventObject.detail.arguments property.
Second is to launch the app through a URI association. You use a custom schema for this, which is declared in the manifest. The app will then see ActivationKind.protocol and eventObject.detail.uri will contain the full URI including any parameters. A URI launch can be done from another app, by entering the URI into a browser address bar, or through a shortcut that a user could configure on the Start screen.
The first step is to convert our Windows (8.1) Store project into a Universal app structure, which would then spin off a separate Windows Phone WinJS project (this is nice when we wish to target Windows Phone later) and a shared project.
Practically everything from the Windows Store project is moved to the shared project (including default.html or index.html). What remains in the Windows Store project is a customised config.js carrying the parameters
window.customWin8 = {
contextId: xxxxxxxxxx,
customParam: 'xxxxxxxxxx'
};
The downstream modules that sense for query string/hash parameters would then fall back to this alternative object if it exists to pick up the data it needs.
Now, for every differing app we wish to deploy, that would for now seem to require a separate Windows Store project so it gets its own GUID and won't conflict with other apps. All these projects would reference the very same shared project thanks to the Universal structure Visual Studio affords. The only down side is it seems Visual Studio 2013 does not have a direct UI method to make this referencing to the share project and has to be hand code into the jsproj file.
<Import Project="..\Common.Shared\Common.Shared.projitems" Label="Shared" />
With this adjustment they can all build and package with their isolated "build config".
Please read the following in the Visual Studio 2012 context:
I have two projects--one is a website (File --> New Website) and another is a console application (File --> New Project --> Windows --> Console Application). I am the author of the former.
The standalone app fakes the input by hardcoding it, runs through some code, and creates an output. It uses dlls from a local installation of software that I have installed on my machine to generate this output.
I read on MSDN that I cannot add a console app to a website solution in a useful manner. So, if I compile the console app to output a dll instead of an exe, can I reference that dll in my website? How can I do this exactly? I would need to pass the input value from the website to the dll, and return meaningful results from the dll. Is this possible?
Yes, you describe a feasible way to solve this. You need to create a class library project, add source code from console application to it, except the the class that has static Main method and modify (add to) that source code such that there is a class that you will be able instantiate from the code in your web application after you add the class library assembly to the web application as a reference. This class will have a method with appropriate parameters, that you will call. All this assuming that the task that console application code performs is fast and will not create noticeable delay in the web application response. If the task takes a long time, you will either have to run it in a background thread or move it outside the web application - the latter is significantly more involved.
In my app I upload a file to the server using HTML5 File API, however I am encountering a situation where a file is not accessible because it is being used by another process. This actually creates two different error conditions in firefox and in chrome. Is there a way to detect if a file is inaccessible using html5?
Have you looked the sample in this link which shows how you can read a file and in case of error you can write proper error handler:
http://www.azoft.com/spotlight/2011/02/02/filesystem-apifile-api.html
About your second questions "if there's an API call to just check if it is readable without actually having to read it locally", I verified that there is no such API to just get the file handle state and verify it. I think it could be because (but i may be wrong):
the web application runs on any box with limited privilege and getting file handle could require SYSTEM level access
The file handle access could be different for different OS (Linux or Windows)