Visual Studio updates Xamarin

When you open Visual Studio 2015 and there is a pop windows to invite you to click on it for updating Xamarin and you click, nothing happends. There is a bug but clicking the update available popup was fixed in one of the recent releases. You can manually update in the Options menu under Tools.

As for the errors, I get those all the time. Support packages can often be a problem. Update to the latest XF package. Try deleting bin, obj, and the contents of packages folders and rebuild.


WebRole and WorkerRole Templates in VS 2015

Download the Azure SDK for Visual Studio 2015 from here:

It should force you to close Visual Studio, but if it doesn't, do so anyways. Once it's installed, you can reboot it.

When you go to add a new project, you can look under Cloud and then choose Azure Cloud Service.


This will give you the same old familiar screen, where you can choose a Web Role or Worker Role:


Customize Json result in Web API

If you work with Visual Studio 2015 and WebAPI, this short post is for you!

We have to make our Web API project easy to debug so, I’m going to remove the XML formatter. I’m doing that because I’m in a test project and I’d like to see the response in the browser. The easily way to force the response to Json for all Web API requests is to remove the XML. Obviously you shouldn't do it in production.


var formatters = GlobalConfiguration.Configuration.Formatters;

Now we can start change the setting for all Json responses accessing to GlobalConfiguration.Configuration.Formatters.JsonFormatter.

In the following examples I’ll use always the class below (create it under Models folder):

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PSC.Models
    public class MapModel
        public string Firstname { get; set; }
        public string Lastname { get; set; }
        public string Username { get; set; }
        public DateTime Birthdate { get; set; }
        public Uri Website { get; set; }
        public int Age { get; set; }
        public double Salary { get; set; }

        public string IgnoreProperty { get; set; }

Now we customize the Global.asax again to reply with the correct format. Change the Global.asax as following code:

using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace PSC
    public class MvcApplication : System.Web.HttpApplication
        protected void Application_Start()

            // start change the setting for all Json responses accessing to
            // GlobalConfiguration.Configuration.Formatters.JsonFormatter
            var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
            // How can we indent the json response?
            json.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
            // How can we change the case in the response?
            json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            // How can we manage the null in the response?
            json.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
            // How can we change the DateTime format?
            json.SerializerSettings.DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat;
            // How can we change the TimeZone format?
            //json.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc;
            // How can we change the Culture of the serializer?
            // json.SerializerSettings.Culture = new CultureInfo("en-GB");

            var formatters = GlobalConfiguration.Configuration.Formatters;

Then under Controllers create a new one and add the following code:

using Newtonsoft.Json.Serialization;
using PSC.Models;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Web.Http;

namespace PSC.Controllers
    public class MapController : ApiController
        public HttpResponseMessage Get()
            IList<mapmodel> result = new List<mapmodel>();
            result.Add(new MapModel
                Age = 34,
                Birthdate = DateTime.Now,
                Firstname = "Enrico",
                Lastname = "Rossini",
                IgnoreProperty = "This text should not appear in the reponse",
                Salary = 1000,
                Username = "enrico",
                Website = new Uri("")

            var formatter = new JsonMediaTypeFormatter();
            var json = formatter.SerializerSettings;

            json.DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat;
            json.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc;
            json.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
            json.Formatting = Newtonsoft.Json.Formatting.Indented;
            json.ContractResolver = new CamelCasePropertyNamesContractResolver();
            json.Culture = new CultureInfo("en-GB");

            return Request.CreateResponse(HttpStatusCode.OK, result, formatter);

The result is pretty cool!


Happy coding!

Design, Source and Split tabs are missing in Visual Studio 2015?

If the HTML file is in Solution Explorer, then right-click and select “Open With”. Otherwise open it with Open File dialog, but click the small dropdown arrow in the Open button, then select “Open With”. Then select “HTML (Web Forms) Editor with Encoding”. Then you should see the Design, Split and Source buttons. Click Design.


Visual Studio 2015: upgrade all NuGet packages at one time


Open the Package Manager Console and use the Update-Package cmd-let to update all packages.

If this doesn't work, you have other two solution. Always in Package Manager Console you type one of those:

First solution
  1. $list = Get-package -project {Add project name here} for($i=0; $i -lt $list.Length;$i ++ ) { Update-Package -project {Add project name here} $list[$i].Id }

Replace {Add project name here} with your project name without braket

Second solution
  1. foreach ($p in get-project -all) { update-package -ProjectName $p.ProjectName }


Happy coding!

Error : DEP3321 – Can’t deploy to Windows 10 Mobile

With Windows 10 being rolled out as I write this article, there will be updated sample Windows Platform apps available soon (today). It’s also time to update your projects.

However, you may find yourself not able to deploy to Windows 10 Mobile after updating your projects or older samples to Windows 10 (build 10240). This post will show you how to resolve this problem.

The problem

You’ll see an error something like this when deploying to a physical Windows 10 Mobile device:

Error : DEP3321 : To deploy this application, your deployment target should be running Windows Universal Runtime version 10.0.10240.0 or higher. You currently are running version 10.0.10166.0. Please update your OS, or change your deployment target to a device with the appropriate version.

The error is pretty clear but how do we fix it? The resolution is with the MinTargetVersion setting.

The fix

We need to drop the lowest version your app targets to the version that your device has running, we can do this in one of two ways; through the project properties UI editor or manually edit the XML of the csproj file. I will show you how to do it manually because in some cases, the UI’s MinTarget dropdown list won’t show the lowest SDK if you do not have it installed. Below are the steps to fix it.

NOTE: Skip to step 3 if your project is already unloaded (it will show (unavailable) next to the name)

1) Right click on your project in Visual Studio

2) Select “Unload Project“, it will now appears as ProjectName (unavailable)

3) Right click on the unloaded project and select “Edit projectName.csproj

4) Locate the <TargetPlatformVersion> and <TargetPlatformMinVersion> items in the first <PropertyGroup>.

Here’s the “Before” screenshot:


5) Change the TargetPlatformMinVersion to the version that the error stated you are running. In this case, it’s 10166. Here’s the “After” screenshot:


6) Now Save and Close the file

7) Right click on the project again and select “Reload Project

8) Rebuild the project and deploy to device. Now you should be up and running!



Planet Xamarin

Planet Xamarin


<<  July 2017  >>

View posts in large calendar

Month List