Breaking News

Wednesday, April 2, 2014

How to Hack Metro Application to run unsupported features

How to Create Metro Applications with Unsupported features

Metro – available under Windows 8 & Windows 8.1 is Microsoft’s initiative to make applications compatible to all type of platforms like Laptop, Tablet, Phablets and Phones.



Want to know more about Metro in details, Check these links – Wikipedia & PCWorld 

Let’s get on to the topic, now Microsoft has tried to make Metro applications light weight so it should be available & compatible in all kind of Handheld & Digital devices. So as to make it Light weight it has deprecated many APIs which would be necessary for Developers to build applications.

Metro applications can be built on .Net Framework 4.5 (Compact). Many APIs which are available with .NET 4.5 is not available under .NET 4.5 – Compact, thus limiting the developers to build applications with features that are not available under .NET 4.5 compact. So as to overcome this limitation and develop applications which will be a metro application but has features/API which are not available under Metro, the following steps need to be followed.


To overcome this limitation what we can do is we can create a service which will be a .NET 4.5 application & our metro application will communicate with the service to do those task which are not possible under Metro application.

How to create a Service for Metro Application

In Visual Studio, Create a New Project => Choose the preferred Language (C# in my case ) => Choose WCF sub menu => Then Choose WCF Service Application as mentioned in the Image below.

We are using .NET framework 4.5, at present this is the latest framework. You are free to choose any framework depending upon your requirement. Give a name to your Service and click OK.



Since here the development framework being used is .NET 4.5, all the API are accessible so develop the application here and once you compile and execute the service it will be available as a service.

Here is the snippet for Hello World program in Service



Delete the default code created by WCF from IService1 and Service1.svc.cs
a. So delete the data contract
b. Modify the service contract as below. Just make one operation contract to return a string.

Modify IService1.cs as below


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfService5
{
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetMessage();
      
    }  
                       }


Service1.svc.cs



using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
 
namespace WcfService5
{
    public class Service1 : IService1
    {
        public string GetMessage()
        {
            return "Hello From WCF Service "; 
        }
    }
}

 
Leave the default configuration created by WCF.
Web.Config



<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>  
</configuration>

Once your service is available you can follow the procedure mentioned here to deploy it as a Service on IIS and then use it in any metro application!


Designed By