Sinclairinat0r.com

Just tweaking my way through life.

Using .NET Native on Windows Phone 8.1 Projects

Posted by on Jul 11, 2014 in Windows Phone | 0 comments

EDIT: Found a tiny issue with my .NET Native script for WP 8.1 You HAVE to run powershell from within the Developer Command Prompt for VS 2013 (make sure you are running as admin), THEN run the powershell script. I didn’t realize that I had made this script from within that environment and noticed that the essentially environment variables that I am using weren’t there when calling PS regularly.

 

In April, Microsoft released a preview of a framework for Windows Store apps that would convert .NET assemblies into the compiled native binaries of the target architecture (x64/ARM for now) in order for application optimization. This tool was named, .NET Native.

This tool itself will help protect your code and IP (a.k.a make it even harder for people to reproduce your code, but not impossible) and also increase the application’s performance.

Getting Started: 

To download .NET Native, Go to the home page and register/download the preview. Close all instances of Visual Studio 2013 (VS 2013 Update 2 is required) then run the installation package.

The .NET Native tools are configured to purely work with Windows Store apps only, but I figured that it SHOULD work with Windows Phone 8.1 projects since they both use WinRT (mostly). I decided to come up with a solution that would enable .NET Native for Windows Phone 8.1 projects manually since there’s no way to enable it from Visual Studio.

Here’s the PowerShell script that runs this. BE SURE TO RUN AS ADMINISTRATOR 

I’ve tested this with VS 2013 Ultimate Update 2 running on Windows 8.1 Update 1 with the English language.

The syntax is as follows:

./enableProjectN.ps1 -solution “c:\pathtovsproject\wp81solution.sln”

The script will go through and determine whether you have VS 2013 installed, and whether the projects in your solution are WP 8.1 projects. It will then add the project config nodes that enable .NET Native.

For this to work, you MUST target your projects to the Release|ARM configuration in Configuration Manager.

The building of your project will take a little longer since it is running all of the tools to compile your C# into the native binaries . The file size will go up exponentially, but the app will run faster.

Read through the Compiling for .NET Native page for complete information on how the .NET Native technology works and for any gotchas.

Happy compiling.

Read More

WP8.1 – Creating/Deploying Appx Packages Using Command-Line

Posted by on Jul 7, 2014 in Windows Phone | 0 comments

Note: I already created this post on XDA-Developers first since it had something to do with a project I was working on, so if you’ve seen the post there it is a carbon-copy.

To those who are used to grabbing their packaged .XAP file from the Debug/Release directory, things have change with Windows Phone 8.1 (non-silverlight) apps. Instead, we are presented with two ways to create appx packages:

  1. Navigating to Project->Store->Create Store Package within Visual Studio 2013 (if you’re looking for a store-ready appx, then this is your option to take)
  2. Using the Command Line tools

This thread will focus on how to use the command line tools rather than use the Visual Studio.

First thing’s first, we have two core applications that we’re going to use in order to handle package management and deployment:

  • makeappx.exe – C:\Program Files (x86)\Windows Kits\8.1\bin\x86
  • AppDeployCmd.exe – C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Tools\AppDeploy

makeappx.exe:

This does as the filename suggests, make appx files.

The easiest way to build an appx file out of the contents of your Debug/Release directory is to run the following command:

makeappx pack /v /d c:\pathtodirectory /p c:\pathtoappx.appx /l 

the /v argument enables verbose output, the /d argument is your directory, the /p argument is your output package and the /l argument disables validation checks on manifest data and resource files.

If you are indeed building the appx manually from your Debug/Resource directory, please make sure to include any .dlls and .winmds that you may be referencing in separate projects that aren’t in the main output directory.

AppDeployCmd.exe:

This is the command line version of the Windows Phone 8.1 Application Deployment program.

The easiest way to deploy an appx to your phone is to run the following command:

AppDeployCmd /install c:\pathtoappx.appx /targetdevice:de /leaveoptimized 

The /install argument provides the path to the appx file you wish to deploy, the /targetdevice argument is the device that you wish to deploy to and the /leaveoptimized argument is an optional parameter to leave the optimized version of the appx package on the filesystem instead of deleting it.

Analyzing the contents of an appx package: 

The Appx file is different from a Xap file in that it is ZIP64 compressed instead of using the common ZIP compression. As of now, it isn’t possible to deploy a ZIP compressed appx or modify a ZIP64 compressed appx file.

Taking a look a generated appx package, you’ll see contents similar to the following:

  • Assets – Assets directory
  • App.exe – Main exe
  • resources.pri – compiled resources
  • App.xbf – Binary XAML file for the App namespace (similar to App.xaml for Silverlight)
  • MainPage.xbf – Binary XAML file fro the Main Page (similar to MainPage.xaml for Silverlight)
  • [Content_Types].xml – XML file containing the content type of every file in the package
  • App.xr.xml – XML file containing the root XAML types of the app
  • AppxBlockMap.xml – XML file containing a crypto hash for each block of data stored in the package
  • AppxManifest.xml – XML file containing the main manifest (similar to WMAppManifest.xml in Silverlight)

When you deploy the appx to your device while using the /leaveoptimized flag, you’ll notice a new appx file in the format of nameofappx_Optimized.appx.

This specific appx package is generated every time you sideload an app to your phone and is the version that your phone receives. The deployer runs MDILXapCompile on every file in the package to precompile any managed assemblies into native code.

If you open up the optimized appx file, you’ll notice that we have two new files:

  • MDILXapCompileLog.txt – The output log of MDILXapCompile
  • MDILFileList.xml – XML file that contains the assemblies that were successfully converted to native code.

Things to be wary of with Windows Phone 8.1 appx packages and the Store:

I’ve posted this on twitter earlier this week, but for pure Windows Phone 8.1 applications, it is possible to retrieve their contents from the Store by using the Download and install manually link. The appx files on the Store ARE NOT ENCRYPTED. From my understanding, it has to do with keeping compatibility between Windows 8.1 and Windows Phone 8.1. I’m curious to know when they decide to encrypt the files.

What’s this have to do with the topic at hand? Everything. It is also possible to repackage an appx file from the Store.

Before I get into the how-to and the caveats, I’ll explain how I even discovered the appx files were unencrypted.

I happened to be researching a particular capability I’ve been seeing in some files in a ROM dump from one of the newer Lumias and happened to paste it in to Bing. I was shocked to see direct links to the appx packages and noticed some familiar file names in the description of the link (AppxManifest.xml and MDILFileList.xml were the two that caught my eye). The even bigger kicker was the fact that these appx files are indeed searchable, but only from Bing (and DuckDuckGo which happens to use Bing). I decided to make more specific search queries to see if this was legit or if I happened to be losing my mind. It turns out that I wasn’t.

“site:windowsphone.com/en-us AppxManifest.xml” happens to be the holy grail and will return any indexed Windows Phone 8.1 apps. The scary part is that you can still download apps that aren’t published anymore and side load them. Here’s an example Windows Phone 8.1 app that I happened to download (and also happens to be a Microsoft app).

http://www.windowsphone.com/en-us/st…d66c20b76b/xap.

The link is self-explanatory. It’s the Microsoft Remote Desktop Preview app. Now for the fun part.

Repackaging an app for development and testing purpose: 

Before I begin this, I’m going to put a disclaimer out there, that this is just information to be used for dev purposes and as a way of trying to understand more of the packing process. I am by no means condoning any piracy so do NOT ask any questions or make any statements that involve searching for apps that you can’t find, etc. I’m hoping Microsoft fixes this hole soon.

In the contents of the downloaded appx file, you’ll notice we have even more files:

  • AppxSignature.p7x – Signature for app.
  • AppxMetadata – folder containing the CodeIntegrity security catalog file

To repackage and deploy an app to your device, the following must be done:

  • Extract the contents of the appx into a blank folder
  • Remove MDILFileList.xml, AppxSignature.p7x, and the AppManifest folder
  • Run the makeappx command above to repackage
  • Run the AppDeployCmd command above to deploy the app to your device

Common issues with redeployment: 

  • If it’s an update to a System app (Calendar, Podcast), you won’t be able to install it because it can’t uninstall the app from your phone
  • If it is a Microsoft or OEM app, you’re most likely going to be unable to deploy it due to restricted capabilities. Some appx packages will include a WindowsPhoneReservedAppInfo.xml file that will contain the extra capabilities. You’re free to remove them, but don’t count on it actually working 
  • If the appx package contains an external DLL reference that isn’t from your project (Live SDK dll for instance), you will receive an error deploying with a message stating that the assembly can’t be optimized because it is an invalid assembly.I’ve tried two workarounds in order to actually allow the deployment:
    • Remove the strong name key
    • and replace the dll with a version downloaded from the repository.

    I tried this on an app, but the app will still crash when it tries to call functions that use the external dll

“Oh crap! I’m worried about people stealing my code, what do I do?

  • Use Silverlight if you’re doing a Windows Phone 8.1 app. Those are still encrypted from the store (Until someone installs the app with an interop-unlocked phone)
  • Use WinRT C++ instead of C#. Yeah, that’s the most difficult and crappy way to go, but it will make it a little harder (not impossible) for someone to jack your code

Again, I’m hoping that MS addresses this, but for now it is a nice way to analyze changes done in apps like the Calendar and Files app.

Happy testing folks

Read More

Windows Phone 8.1 Dev Preview Update Process Walkthrough

Posted by on Apr 14, 2014 in Windows Phone | 0 comments

This post will be updated with everything that I’ve seen throughout the Windows Phone 8.1 update process. I tried to take a few screenshots of the processes

  • First received an update to 8.0.10532.166 which seems to be a prerequisite update for 8.1
  • Received the 8.1 update afterwards
    wp_ss_20140414_0001
  • TOS
  • wp_ss_20140414_0002
  • 19 Migration steps which is much more than the typical 3-6 we see when updating. Makes sense though.
    wp_ss_20140414_0003
  • Tried to take screenshots of 8.1 after the update was installed, but I was prompted that the screenshot combination changed (I actually forgot about this). It’s now Power + Vol Up instead of Power + Start.
  • Here’s my lockscreen now. I’m using Quotastic. Notice that we have the notifications icon and the Exchange mail icon changed 
    wp_ss_20140414_0004
  • After the migration steps were complete, I was informed of the new WiFi Settings that I leaked.
    wp_ss_20140414_0005wp_ss_20140414_0006
  • It also informed me that now I have to update my Google login since it’s now using OAuth
    wp_ss_20140414_0007 wp_ss_20140414_0008
  • My Home screen now with Data Sense among many other app pins
    wp_ss_20140414_0009
  • I noticed that it decides to update and reinstall EVERY app on my phone. R.I.P Battery
    wp_ss_20140414_0010
  • CORTANA BABY!
    wp_ss_20140414_0011wp_ss_20140414_0012 wp_ss_20140414_0013 wp_ss_20140414_0014 wp_ss_20140414_0015 wp_ss_20140414_0016 wp_ss_20140414_0017 wp_ss_20140414_0018 wp_ss_20140414_0019 wp_ss_20140414_0020 wp_ss_20140414_0021
  • Thing that was shown in BUILD. Detect tracking info from emails on your phone
    wp_ss_20140414_0025
  • Storage Sense!
  • wp_ss_20140414_0026
  • Oh, all games are listed within the app list instead of having to go into the Games app in order to access them.
  • FM Radio gets its own app too in the app list
  • wp_ss_20140414_0027
  • Camera updated
    wp_ss_20140414_0028 wp_ss_20140414_0029
  • Notifications
    wp_ss_20140414_0030 wp_ss_20140414_0031
  • You have to reboot in order for Glance notifications to work
    wp_ss_20140414_0032
  • Showing facebook notifications in the People Hub?
    wp_ss_20140414_0033 wp_ss_20140414_0034 wp_ss_20140414_0035
  • Settings Sync across multiple devices
    wp_ss_20140414_0036 wp_ss_20140414_0037
  • Setting extra Tiles
    wp_ss_20140414_0039 wp_ss_20140414_0040 wp_ss_20140414_0041
  • If you’re going to enable extra tiles on a 920 or comparable device, make sure you have good eye sight because these tiles are TINY.

More to come later :)

Read More

Spoofing IE10′s User Agent in IIS for IE11 Support in SharePoint 2013

Posted by on Mar 14, 2014 in .Net, SharePoint | 2 comments

As I explained in my previous post, IE 11 doesn’t work out of the box with SharePoint 2013. It seems that my excitement was short lived with the “fix” from the previous post. I didn’t realize that although I took my domain out of Compatibility View, I still happened to have “Display Intranet sites in compatibility view” checked. I found this out from a co-worker as I had to deal with another IE 11 issue. This news bummed me out and led me to a few failed attempts at addressing this issue (writing an HTTPModule and trying to use reflection in order to change the user agent from the request, modifying the navigator object in JavaScript to change the getter method for the userAgent). Luckily, my fix doesn’t mean I necessarily have to throw my changes away from the previous post.

For the fix, I decided to use the URL Rewrite Module for IIS. The rule I created is a simple set up and takes only a few minutes to create.

First, open up IIS after the URL Rewrite Module is installed. Click on the particular IIS site that represents your SharePoint 2013 Web Application, then click on the Url Rewrite button in the Features View.

urlrewrite1

Next, click the View Server Variables link from the Actions pane on the right. From here we need to add HTTP_USER_AGENT into the list of Allowed Server Variables by clicking Add in the Actions Pane.

urlrewrite2

When this step is complete, click the Back to Rules button from the Actions pane then press Add Rules(s). Select Blank rule under the Inbound rules section (the first selection on the top left) and enter/choose the following values:

Name: This rule can be named anything you wish for it to be named

Match URL

Requested URL: Matches the Pattern

Using: Regular Expressions

Pattern: .*


Conditions

Logical grouping: Match All

Click Add Condition and then enter the following data:

Condition input: {HTTP_USER_AGENT}

Check if input string: Matches the Pattern

Pattern: .*Trident/([7-9]|0*[1-9]\d+).*(rv:1[1-9]).*

urlrewrite3


Server Variables

Click Add and then enter the following data:

Server variable name: HTTP_USER_AGENT

Value: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)

Replace the existing value: Checked

urlrewrite4

Action

Action type: None


After following these steps, press Apply in the Actions pane. Try editing a page in IE 11 without Compatibility View enabled now and be amazed that it actually enters Design View. This actually “fixes” the issue with external users unable to edit pages and view calendars correctly with IE 11. As explained before, Compatibility View can “solve” the IE 11 issue, but I would rather refrain from immediately putting an entire domain in Compatibility View when one site doesn’t work. Also, if your site is externally accessible, it requires users to know that they need to put the site into Compatibility View.

Leave comments if this solution has worked for you and also if it hasn’t.

Read More

Internet Explorer 11 Compatibility Fixes for SharePoint 2013

Posted by on Mar 6, 2014 in SharePoint | 3 comments

As many of you have noticed, IE11 just doesn’t work correctly with SharePoint 2013:

  • Edit Page doesn’t place the page in Edit mode (especially on custom page layouts)
  • If you do happen to use a built-in page layout, any webparts added are unable to be customized
  • The calendar view doesn’t look right
  • The calendar overlay button on the calendar view is disabled

I’ve wondered why Microsoft failed to include IE11 browser support even after SharePoint 2013 SP1, but rather than sit and wonder I decided to take action.

This happens to be mostly the same issue that I detailed in my previous post about SharePoint 2010 and I now understand what went wrong. By default, all master pages (including ones that you create in Design View) are set to be in IE10 mode via the X-UA-Compatible meta tag. This works fine for IE10 and below because it just appears to be IE10. For any browser lower than that, the page will display in IE(x) mode.

My fix involved creating a new masterpage and setting it IE10 Compatibility View from the X-UA-Compatible tag.

ORIGINAL


<meta http-equiv="X-UA-Compatible" content="IE=10" />

FIXED


<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10" />

The difference between “IE=10″ and “IE=EmulateIE10″ is that IE=10 only changes the user agent to appear as IE 10, whereas IE=EmulateIE10 fully emulates the IE 10 browser including IE 10′s DOM/Javascript API (Compatibility View).

Applying this change allows IE 11 to work perfectly without having to manually put the site in Compatibility View per user. If you are compelled to, you could always go into the 15 Hive and apply this to all masterpages that have that original meta tag in it, but I wouldn’t recommend it.

Hopefully this fix works for others. I would like to see if anyone encountered any issues.

Read More

SharePoint 2010 People Picker and Workflow Compatibility Fixes For IE10/IE11

Posted by on Feb 25, 2014 in SharePoint | 0 comments

I’ve recently encountered a bit of frustration when dealing with the people picker and publishing workflow in IE 10/11. I decided to dig around and find what was causing such issues (other than Microsoft failing to make SharePoint 2010′s IE compatibility future-proof). First thing I tried was setting the document emulation to IE9 and that worked for the workflow issue, but failed for the people picker dialog. Through trial and error, I’ve determined that IE8 emulation is what’s needed for the people picker dialog to work. How do I put this all together without putting the ENTIRE domain in compatibility view? The X-UA-Compatible header is the answer.

While looking through the 14 Hive directory (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14), I was able to locate some master pages that were statically setting the browser mode to be IE8, but for some reason the master page for the people picker dialog wasn’t. BINGO! Here’s what I added within the <head> section in the following files to make the people picker and the workflow page work correctly:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\pickerdialog.master

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL\v4.master

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>

You should now be able to publish a page and use the people picker correctly after following those steps above. I’m curious to know more issues that IE10/IE11 cause for SharePoint 2010.

Edit: I’ve noticed that I am unable to save changes to Pages from within Edit Properties (EditForm.aspx). The fix is a modification of Markus Drake’s solution that needs to applied to end of the <body> tag within the v4.master file:


<script language="javascript">
if (typeof UserAgentInfo != 'undefined' && !window.addEventListener) {
 UserAgentInfo.strBrowser=1;
}
</script>

Read More

More Features To Look Forward To In Windows Phone 8.1

Posted by on Feb 15, 2014 in Windows Phone | 2 comments

Within the past few days, Microsoft has been rolling out the Windows Phone 8.1 SDK to certain individuals. The SDK happened to be leaked also within this time period which led to the discovery of more features. The features that have been shown are really nice, but that’s not the end of it. With the help of my friend @jessenic, we present even more new features to look out for:

Please note: The features listed below were pulled from MUI strings directly from the emulator’s file system. These are subject to change as the current SDK is a preview. We won’t know until the RTM is released.

  • Sharing secure WI-Fi Networks with contacts if they have Wi-Fi Sense. They don’t get to see the shared password though
  • Social notifications will now show up in action center by swiping from the top of the screen
  • Operators can now control data sense limits remotely
  • Operators can also install certain applications once a SIM card is detected
  • Along with normal updates, there are now “important” updates.
  • Options to always download emails and pictures within them
  • Encrypted and signed e-mail support
  • Change default SMS app. You can also change which SMS app will show notifications.
  • Enterprise enrolled phones can have their passwords changed and remotely locked
  • “Type as I swipe through letters”. This means we will be seeing Swype-like functionality.
  • Geofence monitoring support. Geofence is a boundary around a place of interest to you. Location services can monitor geofences to tell your apps when you’re entering and leaving them. This would be really good for IFTTT
  • Office Lens support. Will scan in documents and screens

    “Download the Office Lens which scans whiteboards and documents directly in the camera as a Windows Phone Lens.The Office Lens lets you scan whiteboards, documents, and more with your phone’s camera, then optimizes the images so they’re clear and easy to read in your notes.”

  • The phone will have to update to the latest version before you can restore it to factory settings
  • Option to update store apps automatically
  • Option to update store apps when only on Wi-Fi
  • App Suggestions by location
  • Manual App Update checks
  • Video Calling Support? I don’t know if we will be given choices of which VOIP provider to use. Maybe Skype video calling will be built-in?
  • Password protected Office document support
  • Trusted app list for NFC that will remove the need for asking whether you want to open a particular app.
  • In-call speech commands. You’ll be able to say “Call XXXXXX”.
  • Double-Tap to unlock your phone (Feature from Lumia devices on Amber Update and newer)
  • Lock Notification (Feature from Lumia devices on Amber Update and newer I was thinking of Glance for some reason. This could also mean notifications of apps on the lock screen. We don’t know where these strings are being used in the UI, so this one is a speculation)
  • Quiet Hours  (FINALLY)
  • Double Tap to Power Off
  • Notification if charger isn’t of adequate power
  • Screenshot button combination is now Power + Volume Up (Since the newer phones will have the start button on screen)
  • Chkdsk for SD Cards essentially
  • Apps on SD Cards are only allowed from ONE originating phone. If it detects that apps from another phone are installed on the SD Card, then it will ask to delete those first
  • Voice Narrator for Accessibility
  • The Search button will be the new way to open Speech instead of the Start button
  • New Email sync options with accordance to usage patterns (i.e. If you get a lot of mail on particular days and if you don’t check mail every day).
  • Change the size and amount of tiles on your start screen.
  • Wallet supports tickets and membership cards
  • App Syncing
  • Backups now include application data (ABOUT TIME)
  • Screen Reader functionality (Maybe Text-To-Speech for apps?)
  • Screen Recording functionality
  • Inner Circle of contacts. Up to 40 contacts can be in the inner circle.
  • You can favorite photos by tapping a heart icon
  • Virtual SmartCard support

I’ll update this post with more information as I get it.

A big thanks to @jessenic for providing this!

Feel free to comment and ask for any clarification and we will answer if we know. I’m open to know any changes that need to be made in this post also.

Read More