0
votes

I'm trying to migrate a Win/WinPhone 8.1 app to a Win10 (UWP) package.

So far the app is building fine and running, but crashes on first reference on Windows component:

Windows is undefined

(e.g. on accessing Windows.Storage.ApplicationData.current)

Some facts:

  • WinJS (base.js) is loaded before cordova.js
  • WinJS is available in global namespace - Windows is not
  • UseDotNetNativeToolchain property is set to true on *.jsproj
  • using Cordova Windows v.4.4.3 / WinJS 4.4.0

On Try-And-Error I also added some references like Windows Mobile Extensions for the UWP or Microsoft .NET Native Runtime Package for Windows , but that wasn't the reason.

Any ideas what is missing?

1
I do not use cordova, but in JS there is window, not windows. Maybe you can provide SO Snippet with issue? - Justinas
Yeah right on the browser window is the global object. But I really mean Windows from the Windows API. Example would be Windows.Storage.ApplicationData.current.localSettings.values["Key"] = "Value"; see docs.microsoft.com/en-us/uwp/api/… and choose JavaScript on the right - kerosene
I made a basic demo but didn't reproduced this problem. Could you please try it on an empty blank project? - Elvis Xia - MSFT
Strangely it is working for a fresh project. I realized var hasWinRT = !!_Global.Windows; is false on base.js - kerosene
@kerosene It looks like something is wrong in your project template, the simple way is to recreate the project and try again - Franklin Chen - MSFT

1 Answers

1
votes

Found the error on the appxmanifest definition:

    <uap:ApplicationContentUriRules>
        <uap:Rule Match="ms-appx-web:///" Type="include" WindowsRuntimeAccess="all" />
    </uap:ApplicationContentUriRules>

wasn't set which caused that the Windows Runtime was not accessible.