WCF 4.5 features: Simplified Generated Configuration Files

 

In this post we will discuss one of the most important feature of WCF 4.5. WCF 4.5 generates simplified configuration file at the client side. WCF 4.5 generates configuration file for basicHttpBinding as following,


 

 

To understand simplified configuration file in better way take an example, Before WCF4.5 when you were adding a service reference, at the client side WCF was creating service configuration file with all the default values for the attributes of the binding. In earlier version of WCF4.5 configuration file created at client side was as following. Below is the configuration file for service with wsHttpBinding.

 

Above I have taken an old configuration file and it contains many other attributes along with default attributes. However point I am trying to make that in prior version of WCF 4.5 ,automatically created configuration file at client side contained default  attribute with values of binding by default. Whereas in WCF4.5  automatically created configuration file at client side is much simplified and contains only the binding name as shown in the image below, 

In WCF 4.5 generated configuration file at client side is very much simplified and does not contain any default value of the binding attribute.

 

In this way you can notice simplified configuration file at the client side. In later post we will discuss another feature of WCF 4.5. I hope you find this post useful. Thanks for reading.

 

Configure Node.js for Windows

In this post we will walkthrough step by step to set up environment for node.js on windows. Very first navigate to Windows Azure Download page and select node.js for Windows to download

image

Once you click on node.js download option for Windows you will get following confirmation windows. Click on Save File.

image

After saving the file when you run the exe, it would launch a Web Platform Installer. You will get option to install Windows Azure SDK for Node.js. Click on Install button to proceed with installation

image

After successful installation you will get information about successful installed products as following in a dialog box.

image

After installation open command prompt as administrator and run the command

npm install azure-g

image

After successful installation of package create a working folder. For example I have created a folder called nodedemo in C drive. Now navigate to http://nodejs.org/ and copy the Hello Word sample from here

image

Create a file called server.js inside nodedemo folder and paste this code. After this run the command

node server.js

image

You will get message that node server is running. Now when you navigate to http:127.0.0.1:1337 , you should be getting following response from the server

image

Once you get this response you can be sure that node server is configured on windows. I hope you find this post useful. Thanks for reading.

 

Step by Step creating Virtual Machine in Windows Azure

In this post we will walkthrough step by step to create Virtual Machine in Windows Azure. To start with very first you need to login to Windows Azure Management Portal here and then click on Virtual Machines option in left panel.

image

If you do not have any virtual machine created then you will get following message. You need to click on CREATE A VIRTUAL MACHINE

image

If you do not have any virtual machine created then you will get following message. You need to click on CREATE A VIRTUAL MACHINE. After clicking that you will get following option

  1. QUICK CREATE
  2. FROM GALLERY

In this tutorial let us try option of Quick Create. On selecting this option

First you need to provide DNS NAME of the virtual machine. It should be unique. You will get a right mark on valid DNS name.

 

image

Next you need to choose the Image for the Virtual Machine. Choose any image as of your requirement. You will get virtual machine mount with image you will choose from the dropdown.

image

Next you need to provide password to access Virtual Machine. Choose the size of the machine and datacenter. After providing these entire information clicks on Create Virtual Machine to create the virtual machine.

image

In bottom of the page you can see information and status on creating virtual machine.

image

Once Virtual Machine got created successfully, you can see the details as following

 

image

 

In this way you can create Virtual Machine in Windows Azure. I hope you find this post useful. Thanks for reading.

 

As a Developer why should I worry about Hybrid Application Development?

 

As a developer I see a great potential in the direction of mobile and device application development. It is evident that the platforms like IOS, Android and Windows Phone are making themselves better with each passing days such that they can excite more developers and eventually the consumers. A huge marketing perception is consumers and proper marketing make a product successful. May be, but when it comes to mobiles and devices, I don’t buy this argument. When I decide to buy a smart phone or tablet, first and foremost, I evaluate whether useful and popular applications are available in my local market place or not ? Applications are essential for the success of any platform. I believe a smart device with smarter platform is a void combination if there is dearth of applications to use on that. Applications are output of a developer work hence any platform need developers to succeed.


 

As a developer I want to write applications and get connected with user of all types of devices and platforms. At any given day I want to see my applications are running on all platforms and used by users of all types of devices.

 

Let us go bit mathematical here. For instance take an example, I want to run my application on three popular platforms and roughly I may need to learn three different technologies and need three different development environment.


 

 

Learning three different technology is exciting though I am more worried about writing three different sets of code for same business requirement. I am reluctant to put thrice of my work for the same application. After creating application I will have to manage and support three different codes as well. At any given day I do not find creating three different application for same business requirement a wise and smart idea. Having said that there may be some scenario when my application is relying heavily on a particular platform and device capability, in that case I may want to write code specific to platform. However when I see majority of the applications are data driven and just consuming data from remote services. In these types of applications I would consider to write one code running on various platforms.

Let us get more mathematical here, assume we are writing an application and want it to run on three popular platforms and application creation for each platform requires 100 lines of codes. So I have to write 300 lines of codes and later I need to manage and support three different sets of codes.


 

 

I may not want to do it if I am writing an application which is just consuming services and nowhere using device capability extensively.


 

I may consider to write one application and expect it to run on all platforms. This type of application is known as Hybrid Application


 


I want to write code once and expect it to run on all types of devices. And path for me would be creating a Hybrid Application. Now question is what technology, language need to be used to create a Hybrid Application? Hybrid application can be created using web technologies like HTML and JavaScript.

There are many awesome products out there which help to create Hybrid Application. One of the best could be jQuery Mobile and Kendo UI Mobile

So I may summarize Hybrid Application Development in following steps


 

  1. Create application using HTML
  2. Build application using PhoneGap
  3. Deploy it to various platform via respective marketplace

In block diagram, I can summarize hybrid application development as following


 

 

So if I am opting for hybrid application development, I may need to write only 100 lines of codes and my application is running on all the platforms. For the same requirement, if I am going to create native application, I will have to write 300 line of codes and I will have to manage 3 different set of codes.

I will end this post by saying if I am not going to write application that is going to use hardware and device capability heavily then Hybrid Application is my choice. At any given day I would like to write one set of code running on various platforms and being used by consumers from all across.

Any comment would be appreciated.

 

Video : ListBox Data Binding in Windows Phone


using System.Collections.Generic;
using Microsoft.Phone.Controls;

namespace PhoneApp1
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
this.DataContext = GetProducts();
}

private List<Product> GetProducts()
{
List<Product> lstProduct = new List<Product>
{
new Product { ProductName ="Pen" , ProductCat ="Education" , ProductPrice = 100 },
new Product { ProductName ="Pencil" , ProductCat ="Education" , ProductPrice = 200 },
new Product { ProductName ="Bat" , ProductCat ="Sports" , ProductPrice = 400 },
new Product { ProductName ="Ball" , ProductCat ="Sprots" , ProductPrice = 90 },
new Product { ProductName ="Eraser" , ProductCat ="Education" , ProductPrice = 10 },
new Product { ProductName ="Shoes" , ProductCat ="Sports" , ProductPrice = 790 },
new Product { ProductName ="NoteBook" , ProductCat ="Education" , ProductPrice = 345 },
new Product { ProductName ="Cycle" , ProductCat ="Sports" , ProductPrice = 5000 },
new Product { ProductName ="Gel Pen" , ProductCat ="Education" , ProductPrice = 130 },
new Product { ProductName ="Football" , ProductCat ="Sports" , ProductPrice = 440 },
new Product { ProductName ="Hockey Stick" , ProductCat ="Sports" , ProductPrice = 320 },
new Product { ProductName ="Drwaing  Book" , ProductCat ="Education" , ProductPrice = 480 },
new Product { ProductName ="Novel" , ProductCat ="Education" , ProductPrice = 180 },
new Product { ProductName ="Tenis Bat" , ProductCat ="Sports" , ProductPrice = 340 },
new Product { ProductName ="Tenis Ball" , ProductCat ="Sports" , ProductPrice = 46 }

};
return lstProduct;

}
}

public class Product
{
public string ProductName { get; set; }
public string ProductCat { get; set; }
public int ProductPrice { get; set; }
}
}


<ListBox x:Name="lstProduct" ItemsSource="{Binding}" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding ProductName}" Style="{StaticResource PhoneTextTitle2Style}" />
<StackPanel Orientation="Horizontal" >
<TextBlock Text="{Binding ProductCat}" Style="{StaticResource PhoneTextNormalStyle}" />
<TextBlock Text="{Binding ProductPrice}" Style="{StaticResource PhoneTextAccentStyle }" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

Video : Find which Panorma Item is selected in Windows Phone

 

Source Code


public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();

myPanorma.SelectionChanged += new EventHandler<SelectionChangedEventArgs>(myPanorma_SelectionChanged);
}

void myPanorma_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (myPanorma.SelectedIndex == 0)
{
MessageBox.Show("first item is selected");
}
if (myPanorma.SelectedIndex == 1)
{
MessageBox.Show("second item is selected");
}

}

What is strict mode in JavaScript?

Have you ever noticed use of strict keyboard as shown in following image anywhere?

 

When I start creating application for Windows Store (Metro App), I noticed this on the top of the default.js file. Well it is nothing but a way to tell JavaScript for better coding and error checking in JavaScript code. If you put strict mode then you are not allowed to do many things in JavaScript code like assigning value to a read only variable.

You can put strict mode restriction

  1. On the function level
  2. On the page level   

 You can put strict restriction on function level as following

Now let us try to put some code in above function. In below code we are assigning value to a variable which is not declared. We have also put function is the strict mode.

When try to call this JavaScript function, you will get error as following. You see in the error message that “Variable undefined in strict mode”. If you go ahead and remove strict mode from the function then you should able to call the function.

If you have put strict mode then you will get error if you try to perform following operations.

  1. Assigning value to non-declared variable
  2. Assigning value to read only variable
  3. Defining duplicate property
  4. Defining duplicate parameters in a function
  5. Using future reserved keywords like interface, let, package etc.
  6. Cannot defined a function inside if-else or for statement

There are many other operations will give you error in strict mode. I hope now purpose of strict mode is clear to you. Thanks for reading!