OneDrive: sync icons not showing problem

On my fresh Windows 10 installation, I had OneDrive, OneDrive for Business and Dropbox.

I was able to see only the Dropbox icons, but not the OneDrive ones.

The solution is to go to the registry settings under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers and ensure that there are max 15 entries.

In my case I had this:

So in my case I have delete the Dropbox icons, and now I can see the OneDrive sync status.


taking inspiration from the blog post Managing overlay icons for Dropbox and TortoiseSVN and TortoiseGit, I see that the best solution is to keep the important icons for both OneDrive, OneDrive for Business and DropBox (for DropBox, I keep the icons 1, 2, 5, and 7). So in total I have now 14 entries, and I should be fine.

My registry settings now are:

Xamarin: how to use OneDrive and TFS or Visual Studio Online on a Mac

For Xamarin projects on a Mac, you can share source files with cloud based file sharing systems like OneDrive, or use source versioning systems like TFS or Visual Studio Online.

If you want to use OneDrive, you need to download it from the Mac AppStore. Here there is the direct link.
Once you setup OneDrive, as usual you can choose what folder to sync. Maybe for a Mac you don't want to sync everything, but only a folder used to share files with the PC for the Xamarin projects.
In case you want to change the synced folders, you can access the OneDrive preferences menu from the top right of your screen.
Important is not to forget in the OneDrive preferences to check "Open at login".
The advantage of this solution is that it is simple and doesn't require any additional software (apart from the OneDrive client itself), but impractical in enterprise scenarios, because you don't keep your TFS folders synced in in OneDrive.

In the second case, using TFS or Visual Studio Online, how do you do it? I recap here the updated steps to use TFS or Visual Studio Online on a Mac:
  • download Eclipse from (I have chosen the version "Eclipse IDE for Java EE Developers"), then after opening the zip file, move it to the Applications folder in Finder;
  • start the application
  • then it will ask for the workspace, accept the default path and check "Use this as the default and do not ask again"
  • go to the Team Explorer Everywhere 2015 plugin and select; if the download doesn't start automatically, the direct link is here);
  • after the download, right click on the file, Open, to uncompress it;
  • from the Help menu (on Mac, it is on top of the screen...), Install New Software, Add button, Local button, select the folder named "TFSEclicsePlugin..." created at the previous step, then Next, Next, accept the licence terms, Finish
  • in Eclipse, Window | Show View | Other, select Team Foundation Server | Team Explorer
  • now click on "Connect to Team Foundation Server" or "Sign up for Visual Studio Online", based on your case; then provide the connection information, and select the project you want to connect
  • finally create a workspace in the workspace folder created previously (when you have installed Eclipse, anyway it should be in the user documents folder), then get all the files

From Xamarin Studio on Mac, it's now possible to open the solution from the workspace folder whose files have just been retrieved.

For this blog post I've used references from:

VS2015 Android emulator: multiple issues

Visual Studio 2015 introduces the new Android emulator. What is great is that it is based on Hyper-V technology, so hardware virtualization, as described more extensively in Introducing Visual Studio’s Emulator for Android.

Using it to develop Xamarin application, I've run into some issues, and I think that it would be good to collect them here:

  • first of all, during my first attempt to run it to debug a simple application, I got in the Output windows of Visual Studio this cryptic error:
         In mgmain JNI_OnLoad
    Couldn't connect to logcat, GetProcessId returned: 0
    As described in 
    Can't run app on Visual Studio 2015 emulator (DWP Handshake failed), the solution is to go to the Android project settings and in the Android Options tab, disable Fast Deployment
  • the second problem was that because of my naming convention for demo projects, I had a too long project name.
    Doing some attempts, I've verified that the longest project name you can give is 37 characters (more create problems with the deployment);
  • when I've been finally able to run my application, I've noticed that I had multiple graphic issues (even if the application is really basic).
    As described in Visual studio android emulator will not start fully, you have to go to the folder C:\Program Files (x86)\Microsoft XDE\10.0.10240.0\SKUs\Android, edit the file xdesku.xml and delete/comment the line:

C#: automated method caller information via attributes

In C# there is a feature of the language that allows a method to receive as input parameters the member name, file path and line number of the calling method/property.

It is enough to add attributes to the method parameters receiving these values, as in the following example:

public void DoProcessing()
    TraceMessage("Something happened.");

public void TraceMessage(string message,
        [System.Runtime.CompilerServices.CallerMemberName] string memberName = "",
        [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "",
        [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0)
    System.Diagnostics.Trace.WriteLine("message: " + message);
    System.Diagnostics.Trace.WriteLine("member name: " + memberName);
    System.Diagnostics.Trace.WriteLine("source file path: " + sourceFilePath);
    System.Diagnostics.Trace.WriteLine("source line number: " + sourceLineNumber);

You can see that this feature can be particular useful during tracing.

The example above has been taken from Caller Information (C# and Visual Basic).

Debugging Entity Framework With ToTraceString

When you develop with Entity Framework, you may need the SQL instruction passed to the SQL engine when your LINQ query is evaluated.

As you can see from the post ToTraceString Method in Entity Framework, both the System.Data.Objects.ObjectQuery and the System.Data.EntityClient.EntityCommand classed implement the ToTraceString() method, whose evaluation returs just the info you need.

An update in EF 6.1 allows to output the generated SQL doing:

   context.Database.Log = Console.Write; 

after having created the context, as explained in Logging and Intercepting Database Operations.

PowerShell: edit and debug ps1 files in Visual Studio

In Visual Studio it's possible to edit and debug PowerShell scripts, using the PowerShell Tools for Visual Studio 2015 extension.

But even after installing the extension, debugging doesn't immediately work, as trying to do this, the output window simply shows an unauthorized access error message.

I've found the blog post PowerShell Tools for Visual Studio 2013 – unable to run and/or debug PowerShell script – execution policies problem that has helped me in finding the solution:

  • from a PowerShell window with elevated privileges,
  • run the command "Set-ExecutionPolicy" RemoteSigned

JavaScript CORS used to call asmx web-services

The following example shows how to implement a server implementing an asmx web-service and a JavaScript client invoking it from a different domain. The particularity is that this cross-site invocation requires CORS (Cross-origin resource sharing), supported in IE8+ and other popular browsers.

The server (part 1)

To create the server, I create in Visual Studio an empty web application. Then I add a Search.asmx web-service, adding the following method:


public string DateTimeNow(string Where)


return DateTime.Now.ToLongTimeString() + " in " + Where;


Then to test it I easily deploy it to the Azure Website

The client

To create the client, I create in Visual Studio another empty web application. I add a reference to the jQuery NuGet package, then I add a simple html page and an App.js file.

Here the html page:

<!DOCTYPE html>

<html xmlns="">


<title>My CORS Client Page</title>

<script src="Scripts/jquery-2.1.4.js"></script>

<script src="Scripts/App.js"></script>



<input id="city" type="text" value="Basel" />

<input type="button" value="Press here" onclick="test_cors_client(false, document.getElementById('city').value);" />



The App.js file is copied here too:
function test_cors_client(simple, where)
function escapeHTML(str) {
return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');

var soapEnv, soapAction;
if (simple) {
soapEnv =
"<soap:Envelope xmlns:xsi=\"\" xmlns:xsd=\"\" xmlns:soap=\"\"> \
<soap:Body> \
<HelloWorldResponse xmlns=\"\"> \
<HelloWorldResult>string</HelloWorldResult> \
</HelloWorldResponse> \
</soap:Body> \
soapAction = "";
else {
soapEnv =
"<soap:Envelope xmlns:xsi=\"\" xmlns:xsd=\"\" xmlns:soap=\"\"> \
<soap:Body> \
<DateTimeNow xmlns=\"\"> \
<Where>" + escapeHTML(where) + "</Where> \
</DateTimeNow> \
</soap:Body> \
soapAction = "";

//url: "http://localhost:8118/Search.asmx",
url: "",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset=\"utf-8\"",
headers: {
"SOAPAction": soapAction
function processResult(xData, status) {
if (status != "success") {
alert("error\n\n" + xData.responseText);
alert("success\n\n" + xData.responseText);
/* var createCORSRequest = function (method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
// Most browsers., url, true);
} else if (typeof XDomainRequest != "undefined") {
// IE8 & IE9
xhr = new XDomainRequest();, url);
} else {
// CORS not supported.
xhr = null;
return xhr;

//var url = "http://localhost:8118/Search.asmx";
var url = '';
var method = 'POST';
var xhr = createCORSRequest(method, url);
xhr.setRequestHeader("Content-Type", "text/xml; charset=\"utf-8\"");

xhr.onload = function (e) {
// Success code goes here.
alert('success\n\n' +;

xhr.onerror = function (e) {
// Error code goes here.
alert('error\n\n' +;

xhr.setRequestHeader("SOAPAction", soapAction);

This file contains both the jQuery implementation using $.ajax, and the XmlHttpRequest + XDomainRequest produced using
Trying the example, you will see that it works when the example is run locally (with Service.asmx copied in the same client website), but not with CORS.

The server (part 2)

To enable CORS on the server, we need to add additional headers on the server, and one quick method is to modify the web.config as here below:

<?xml version="1.0" encoding="utf-8"?>


For more information on how to configure your ASP.NET application, please visit




<compilation debug="true" targetFramework="4.5" />

<httpRuntime targetFramework="4.5" />





<add name="Access-Control-Allow-Origin" value="*" />

<add name="Access-Control-Allow-Headers" value="Content-Type, SOAPAction" />





Now it will be possible to invoke the Search.asmx web-service even from another domain through CORS and here is the zip file containing the complete solution: (704.8KB).

A few links used for reference:

C#: background task in a WinForm application containing a long running task

Recently I had to develop a WinForm application doing some checks. During development, with test data, everything was fast and the UI was acceptable. But once running the application with real data, as it was much more, I understood I was facing a long running task, as the UI was not responsive for 2+ hours.

From my studies, I knew the solution was to use the BackgroundWorker component, and one example was in How to: Run an Operation in the Background.

This was fine in the "old" versions of .NET, and even if still supported, I did some researches to see if a more modern approach was available, for example using the Task class introduced in .NET 4.
In fact the solution is pretty easy: you can run your background task with:

Task t = Task.Factory.StartNew(() =>
// do your long-time processing here
t.ContinueWith((Success) =>
// callback when task is complete
}, TaskContinuationOptions.NotOnFaulted);
t.ContinueWith((Fail) =>
// callback when task throws an exception
}, TaskContinuationOptions.OnlyOnFaulted);

And in how run now operations in the Task synced with the main thread, necessary to update the UI?
Using the Invoke method, better if after checking with the InvokeRequired property, as shown in C# - ThreadPool and Windows Forms.

Azure: impossible to delete an Azure Storage Container due to a lease

When cleaning the resources in my Azure subscription, I tried to empty a Storage Container and I got the following message:

There is currently a lease on the container and no lease ID was specified in the request…

The problem was caused by some Virtual Machines images I had created as a test. It has been enough to delete these images (from the Virtual Machine section, then Images) to then be able to delete the Storage Container.