Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Unable to use APIs available to real packages #21

Open
RReverser opened this issue Mar 5, 2016 · 4 comments
Open

Unable to use APIs available to real packages #21

RReverser opened this issue Mar 5, 2016 · 4 comments

Comments

@RReverser
Copy link

Getting the following error when trying to get local/temp folders:

> Windows.Storage.ApplicationData.current
WinRTError: The process has no package identity.

I read around and looks like it's been a common issue for various UWP test runners, and in this specific case it happens because we don't really have any AppData associated with the script, but wondering if it would be possible to shim such APIs so that they would use e.g. script's folder as a base.

@jianchun
Copy link

jianchun commented Mar 8, 2016

This module is a thin wrapper of JSRT API JsProjectWinRTNamespace and doesn't have further logic to patch differences when used inside/outside of a UWP. From a first glance, patching the differences seems out of scope of this module.

@munyirik @aruneshchandra @Yongqu Do you have opinions?

@RReverser
Copy link
Author

@jianchun Patching the differences is rather a backup plan, I was wondering if it's possible to simulate the mentioned "package identity" so that all the APIs that rely on it, would still work.

@munyirik
Copy link
Contributor

munyirik commented Mar 8, 2016

It's not possible to do that i.e. make a desktop application impersonate a UWP application (aka WinRT/Store app). Some classes like ApplicationData are tied to UWP apps since app packages have their own storage folders. For example the LocalFolder property will point to the application's own local folder (e.g. C:\Users\MyName\AppData\Local\Packages\MyApp\LocalState) and not c:\Users\XYZ\AppData\Local. For a desktop app (i.e. Node.js (Chakra)) I think the way to do this would be to use environment variable. E.g. the local folder variable is LOCALAPPDATA.

@RReverser
Copy link
Author

For a desktop app (i.e. Node.js (Chakra)) I think the way to do this would be to use environment variable. E.g. the local folder variable is LOCALAPPDATA.

Yeah, except then need to rewrite code to retrieve folders in asynchronous manner (as you can't get StorageFolder by path synchronously in opposite to ApplicationData.current.* items which pre-exist) which, in turn, affects all the code that depends on it and so on and so on. So I hoped it would be possible to simulate C:\Users\MyName\AppData\Local\Packages\MyApp\ via .\.uwp-package\ or anything that would give pre-defined paths via the same API for testing purposes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants