Upgrading from Angular 2.0.0 to Angular 2.0.2

Angular 2.0.2 has been released.

It's astonishing that, exactly like for previous betas and release candidates, even in this case we have a huge amount of changes, that I'm quickly going to list here:

  • support of the TypeScript 2.0.3 compiler (even if strictNullChecks are not supported yet);
  • updated list of npm packages to use;
  • the file app.routes.ts is not needed anymore, and routes are defined directly in app.module.ts;
  • because of the previous point, routes are defined in a different way, directly during module import.

TypeScript 2 has been released

TypeScript 2 has been released (to be exact: version 2.0.3).


As by TypeScript 2.0 is now available!, the principal innovations are:

  • Definition file acquisition via npm
    This change is in line with the new Microsoft guideline to use npm (or bower) to acquire client side libraries (and still use NuGet for server side packages); it is also coherent of letting users leverage the TypeScript language even on non-Windows computers, in particular on Mac and Linux, where you can use Visual Studio Code
  • Non nullable types
    It's confirmed that this is a breaking change, so you have to set strictNullChecks to true in your tsconfig.json (by default it is false). Clearly it's strongly suggested to do so
  • Control Flow Analyzed Types
    Even more expanded from what already available in TypeScript 1.8
  • Readonly modified
    Similar to what available in C#

An even more detailed list of the language innovations is in What's new in TypeScript. And also give at look at the Breaking Changes.


Finally: you can start using it in Visual Studio 2015 downloading the TypeScript for Visual Studio 2015 plugin (it requires the Update 3).

Error in TypeScript compilation when upgrading to VS DEV15 and TypeScript 2

If you upgrade to TypeScript 2 (incidentally, done automatically by installing VS DEV15), you can get the following errors in a web project containing TypeScript files:


  • The "VsTsc" task could not be initialized with its input parameters.
  • The "OutputLogFile" parameter is not supported by the "VsTsc" task. Verify the parameter exists on the task, and it is a settable public instance property.
You need to open a Notepad as administrator and edit the file C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\TypeScript\Microsoft.TypeScript.targets, removing the OutputLogFile parameter.


Invoking the debugger from a .NET application

Recently I was in a particular debugging situation where the process that was debugged by Visual Studio was launching another process, and I needed to debug the startup of this second process too (no way to attach to the process from the IDE, then).

So something like the "debugger" instruction in JavaScript.

I have found that the solution is to call:


Process Monitor in Windows 10 error

If when running Process Monitor in Windows 10 you get the error 

   Unable to write PROCMON23.SYS.

   Make sure that you have permission to write to the %%SystemRoot%%\System32\Drivers directory.

then you can follow the suggestion from Error from Process Monitor: “Unable to write PROCMON23.SYS”: "go into C:\Windows\System32\drivers and rename procmon23.sys to something else, then try to enable boot logging from options menu again".

SharePoint 2013: how get the managed navigation from CSOM and REST

SharePoint 2013 has introduced the Managed Metadata Navigation.

To get the managed navigation from client side code, an excellent introduction for JSOM is presented in Get Navigation Taxonomy term tree in SharePoint App, where we have the following points:

  1. get the taxonomy session from the current client context
  2. get the current navigation settings, to retrieve the term store id and the term set id of the terms storing the navigation for the current site
  3. load the term set
  4. load the navigation term set, i.e. the term set "casted" as navigation term set, so offering the additional navigational properties (note: the navigation term set doesn't inherit from from the standard term set)

I needed to do the same from C# code, containing CSOM calls, and here are more or less the same steps, even if we need first to convert the claim token to a Windows identity. Here is the CSOM file: SharePointNavigationProvider_CSOM.cs (7.4KB)

        private WindowsIdentity GetWindowsIdentity()
            WindowsIdentity windowsIdentity = null;

            SPSecurity.RunWithElevatedPrivileges(() =>
                ClaimsIdentity identity = (ClaimsIdentity)Thread.CurrentPrincipal.Identity;
                string upnFromClaim = identity.Claims.Where(c => c.ClaimType == ClaimTypes.Upn).First().Value;

// To get the current Windows identity, we need the Claims to Windows Token Service started on all frontends of the SharePoint farm
                    windowsIdentity = S4UClient.UpnLogon(upnFromClaim);
                    if (windowsIdentity == null)
                        throw new ApplicationException("windowsIdentity == null");
                catch (System.ServiceModel.EndpointNotFoundException ex)
                    throw new ApplicationException("The Claims to Windows Token Service is not running on this frontend", ex);
                catch (System.ServiceModel.Security.SecurityAccessDeniedException ex)
                    throw new ApplicationException("Unable to communicate with the domain controller", ex);

            return windowsIdentity;

        private TermSet GetTermSet(ClientContext clientContext)
            TaxonomySession taxonomySession = TaxonomySession.GetTaxonomySession(clientContext);
            StandardNavigationSettings navigationSettings = new WebNavigationSettings(clientContext, clientContext.Web).CurrentNavigation;
                navSettings => navSettings.TermStoreId,
                navSettings => navSettings.TermSetId);

            TermStore termStore = taxonomySession.TermStores.GetById(navigationSettings.TermStoreId);
            TermSet termSet = termStore.GetTermSet(navigationSettings.TermSetId);
            return termSet;

        private void GetNavigationTermSet(ClientContext clientContext, TermSet termSet,
            out NavigationTermCollection navTerms, out NavigationTermCollection allNavTerms)
            NavigationTermSet navigationTermSet = NavigationTermSet.GetAsResolvedByWeb(clientContext, termSet, clientContext.Web, "GlobalNavigationTaxonomyProvider");

            navTerms = navigationTermSet.Terms;
                terms => terms.Include(term => term.Id));

            allNavTerms = navigationTermSet.GetAllTerms();
                terms => terms.Include(
                    term => term.FriendlyUrlSegment,
                    term => term.HoverText,
                    term => term.Id,
                    term => term.LinkType,
                    term => term.SimpleLinkUrl,
                    term => term.Terms,
                    term => term.Title));


        List<NavigationNodeInfo> BuildRecursiveNodeList(string url, NavigationTermCollection allNavTerms, NavigationTermCollection currentNavTerms, int maxDepth)
            List<NavigationNodeInfo> Result = new List<NavigationNodeInfo>(currentNavTerms.Count);
            foreach (NavigationTerm navTerm in currentNavTerms)
                NavigationTerm currentTermInAllTerms = allNavTerms.First(term => term.Id == navTerm.Id);
                NavigationNodeInfo navNodeInfo = new NavigationNodeInfo
                    Title = currentTermInAllTerms.Title.Value,
                    Url = currentTermInAllTerms.LinkType == NavigationLinkType.FriendlyUrl ?
                        SPUtility.ConcatUrls(url, currentTermInAllTerms.FriendlyUrlSegment.Value) :
                    HoverText = currentTermInAllTerms.HoverText

                if (maxDepth > 1 && currentTermInAllTerms.Terms.Any())
                    navNodeInfo.Childs = BuildRecursiveNodeList(url, allNavTerms, currentTermInAllTerms.Terms, maxDepth - 1);
            return Result;

This solution, even if technically correct, has the disadvantage that these multiple CSOM calls are very slow.
An alternative to improve the performances is to use the REST calls (still after having impersonated the calling user). Here is the REST file: SharePointNavigationProvider_REST.cs (5.3KB)

private XDocument GetWebAppNavigationRest(WindowsIdentity windowsIdentity, string url)
using (new SPMonitoredScope("SZH.IntraZueri.Core.Providers.Navigation.SharePointNavigationProvider.GetWebAppNavigationRest"))
XDocument Result;

// Impersonating the user requires Kerberos in place
using (WindowsImpersonationContext ctx = windowsIdentity.Impersonate())
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(SPUtility.ConcatUrls(url,
"_api/navigation/menustate(mapprovidername='GlobalNavigationTaxonomyProvider')")); //CurrentNavigationSwitchableProvider
request.Method = "GET";
//request.ContentType = "application/json";
request.Credentials = CredentialCache.DefaultNetworkCredentials;

using (new SPMonitoredScope("SZH.IntraZueri.Core.Providers.Navigation.SharePointNavigationProvider.GetWebAppNavigationRest.ServiceInvoke"))
//using (WebResponse webResponse = request.GetResponse())
using (Task<WebResponse> asyncResponse = webReq.GetResponseAsync())
using (WebResponse response = asyncResponse.Result)
using (Stream webStream = webResponse.GetResponseStream())
Result = XDocument.Load(webStream);

return Result;

private List<NavigationNodeInfo> BuildRecursiveNodeList(XElement parentNode, XNamespace ns, string url, int maxDepth)
List<NavigationNodeInfo> Result = new List<NavigationNodeInfo>();

foreach (XElement currElement in parentNode.Elements())
// Check isHidden flag. If it's hidden, don't include in result set
string isHiddenStr = currElement.Element(ns + "IsHidden").Value;
bool isHidden;
bool.TryParse(isHiddenStr, out isHidden);
if (isHidden)

string title = currElement.Element(ns + "Title").Value;
string friendlyUrlSegment = currElement.Element(ns + "FriendlyUrlSegment").Value;
string simpleUrl = currElement.Element(ns + "SimpleUrl").Value;
string linkUrl;
if (!string.IsNullOrEmpty(friendlyUrlSegment))
linkUrl = SPUtility.ConcatUrls(url, friendlyUrlSegment);
linkUrl = SPUtility.ConcatUrls(url, simpleUrl);
List<NavigationNodeInfo> childs;
if (maxDepth > 1)
childs = BuildRecursiveNodeList(currElement.Element(ns + "Nodes"), ns, url, maxDepth - 1);
childs = new List<NavigationNodeInfo>();

NavigationNodeInfo navNodeInfo = new NavigationNodeInfo
Title = title,
Url = linkUrl,
Childs = childs
return Result;

1Password: how use OneDrive to share content between PC, Mac and iPhone/iPad

To avoid the stupid problem of the DropBox icons overwriting the OneDrive and OneDrive for Business icons explained in OneDrive: sync icons not showing problem, I've chosen to uninstall DropBox.

In the end, I was using it only to share my 1Password vaults between PC, Mac and iPhone/iPad. OneDrive has the advantage of being integrated in Windows and also with Office 365 you have 1Tb of space for free.

On the Mac:

  • go to 1Password preferences, sync tab, and change it to folder (choose a folder inside OneDrive)
  • it will ask if you are sure to delete the files in DropBox, take risk and say yes
  • to uninstall DropBox: close it (from the top right menu), and from the Activity Monitor kill all the DropBox processes still running. Then you can drag the application icon to the trask
  • in Finder, search for DropBox, you will still find a folder in your profile; delete it
On the PC:
  • run both the DropBox and OneDrive sync
  • open 1Password, it will automatically ask to open the vault from another source; choose the OneDrive folder
  • uninstall DropBox
  • search for all the DropBox folders and delete them (this can require the reboot of the computer)
On the iPhone/iPad:
  • so far you can't use directly the OneDrive folder, so you need to use wifi sync
  • from the Mac, Preferences | Wifi Server, check "Run a Wi-Fi server trom this Mac"
  • from the iPhone/iPad, start 1Password and dismiss the message about DropBox
  • from Settings | Sync | Start Syncing | Sync using Wi-Fi, select your Mac and enter the secret phrase from the Mac, then finally you can "Sync Now"

Xamarin: adding Android components with problems

Working on a Xamarin project, I have added a component but I had some problem: the component was downloaded, but the dll was not referenced in the project.

I have found the explanations of the guide Walkthrough: Including a Component in your project, but it must be something simple because I add the component inside Visual Studio 2015.

Then I've found the help Quick work around for unresolved Xamarin components in Visual Studio, and I thought that this could be the case, but the files were already on the disc so the issue was not about the path length.

In the end the component was badly downloaded on the first instance, and I had to:

  • remove the components from my project
  • remove the NuGet packages related to the components from my project (founding this took me really a lot of time...)
  • clear the Components folder at the solution level
  • clear the Packages folder at the solution level