Sunday, 29 April 2012

Validation In Silverlight


By default silverlight doesn't give any visual feedback when the data binding system encounters error relating to incorrect input. But internally it rejects data and user is thinking that data has been saved. Silverlight data binding engine has to notify or alert us through visual appearance when there is a violation of rule.

Lets begin :)

1. Create a silverlight application and add the following Student class to your project

public class Student
{
public string Name{get; set;}
public int Age{get; set;}
}

2.//MainPage.xaml.cs

public MainPage()
{
initializeComponent();
Student std= new Student();
LayoutRoot.DataContext =std;
}

3.//MainPage.xaml
Run the application and type string in the age field . Internal validation has happened by rejecting the  invalid input but no visual feedback.

4.ValidatesOnExceptions = True, by doing that, it will makes sure silverlight will provide visual feedback for the validation error.
<TextBox Name="txtName" Text="{Binding Name,ValidatesOnExceptions=True}"
<TextBox Name="txtAge" Text="{Binding Age,ValidatesOnExceptions=True}"

5. Again type string value in Age textbox, this appearance will come :)




Friday, 27 April 2012

Silverlight Deep Zooming

The idea behind Deep Zoom is to present a “zoom-able” interface for huge images. The typical Deep Zoom image is far too large to be shown on screen at once at its native resolution.

It’s easy to create a Silverlight application that uses Deep Zoom, provided you have the  right tools. The most important is the free Deep Zoom Composer tool. The Deep Zoom Composer allows you to convert a large image into the tiled groups of images that Deep Zoom needs for its zooming interface. It also lets youtile together smaller images to create a large image that’s suitable for Deep Zoom, and it can even stitch overlapping images together automatically.

To get started, load Deep Zoom Composer, and click New Project. You’ll need to choose a project name and a project location.One folder, named Source Images, holds the original versions of all the pictures you import. The second folder, named Working Data, holds the dozens of image files that are generated when you lay these pictures out into a Deep Zoom image set.

Note : Deep Zoom project can only be opened in Deep Zoom composer. You must export the image set to generate a Silverlight project.

1.To get the pictures you want, click the Import button in the panel at right, browse to the correct file, and click OK. Importing large pictures can be slow, so be prepared to wait.

2.until you’ve imported all the pictures you need.

3.Click the Compose button. and lay out your pictures.
 
4.To add, drag picture  from the panel at the bottom.
 
5.Click the Export button. Deep Zoom Composer gives several export options The two most useful are to export your image set to DeepZoomPix or to create a Silverlight project.

6.To create a Silverlight project, click the Custom tab in the panel at the right. In the“Output type” box, choose Silverlight Deep Zoom

7. In the Name text box, enter a name for your project. If you want to export the project to a different folder, change the path in the Location text box.

8.Choose “Export as a collection” to create a Deep Zoom image set.
 
9.In the “Image settings” box , choose either PNG or JPEG.
 
10.Click Export to create the image set and Silverlight project.

Showing a Deep Zoom image in a Silverlight application is fairly easy. In fact, all you need is the MultiScaleImage element, as shown here:

<MultiScaleImage x:Name="msi" Height="600" Width="800"/>

Wednesday, 25 April 2012

Silverlight Video Support

When it comes to video, Silverlight supports the follow standards:

• Windows Media Video 7 (WMV1)
• Windows Media Video 8 (WMV2)
• Windows Media Video 9 (WMV3)
• Windows Media Video Advanced Profile, non-VC-1 (WMVA)
• Windows Media Video Advanced Profile, VC-1 (WMVC1)
• H.264 video and AAC audio (also known as MPEG-4 Part 10 or MPEG-4 AVC)

First, create a MediaElement for the file you want to play :

<MediaElement x:Name="fireMovie" Source="fire.wmv" Height="200" Width="200"></MediaElement>

Often, you can recognize Windows Media Video by the file extension .wmv. Other video formats – for example, MPEG and QuickTime–need not apply. The last two formats in this list–VC-1 and H.264–are widely supported.

WMV files you use in your Silverlight application will be a final product based on larger, higher-quality original video files. Often, the original files will be in a non-WMV format.

To get the right results when preparing video for the Web, you need the right tool. Expression Encoder is a remarkably polished and powerful tool.

Key features:

Simple video editing : You can cut out sections of video, insert a lead-in, and perform other minor edits.

Overlays : You can watermark videos with a still or animated logo that stays superimposed over the video for as long as you want it to.

Silverlight-ready : allows you to create a fully skinned Silverlight video player.

To encode a video file in Expression Encoder, follow these steps :

1.To specify the source file, choose File Import. Browse to the appropriate media file, select it, and click Open.

2.To specify the destination file, look at the group of tabs on the right side of the window, and select the Output tab. In the Job Output section, you can specify the directory where the new file will be placed, and its name.

3.To choose the bit rate, look in the Presets tab (in the top-right corner of the window) and expand the Encoding for Silverlight section. If you’re using progressive downloads, you need to select a format from the Variable bitrate group.

4.After you choose an encoding, the relevant information appears in the Video section of the Encode tab.

5.To encode your video, click the Encode button at the bottom of the window, in the Media Content panel.

Tuesday, 24 April 2012

Silverlight Audio Support

Adding audio to a Silverlight application is fairly easy, because you can throw in just about any MP3 file. Using a video file is more work. Not only must you make sure you’re using one of the supported WMV formats, but you also need to carefully consider the quality you need and the bandwidth your visitors can support.

For audio, Silverlight supports the following :

• Windows Media Audio (WMA) [versions 7, 8, and 9]
• MP3

All the audio and video functionality is built into a single class: MediaElement. A simple MediaElement tag is all you need to play a sound. For example, add this markup to your user interface :

<MediaElement Source="test.mp3"></MediaElement>

The startup behavior of the MediaElement is determined by its AutoPlay property. If this property is set to false, the audio file is loaded, but your code takes responsibility for starting the playback at the right time :

<MediaElement x:Name="media" Source="test.mp3" AutoPlay="False"></MediaElement>

When using this approach, you must make sure to give the MediaElement a name so that you can interact with it in code. Generally, interaction consists of calling the Play(), Pause(), and Stop() methods.
We can change the Position property to move through the audio.
Here’s a simple event handler that seeks to the beginning of the current audio file and then starts playback : 

private void cmdPlay_Click(object sender, RoutedEventArgs e)
{
media.Position = TimeSpan.Zero;
media.Play();
}

The two check boxes on the page are the last ingredient in this media player and one of the simplest details. The Mute check box sets the corresponding IsMuted property of the MediaElement :
private void chkMute_Click(object sender, RoutedEventArgs e)
{
media.IsMuted = (bool)chkMute.IsChecked;
}

Handling errors :
MediaElement doesn’t throw an exception if it can’t find or load a file. Instead, it’s up to you to handle the MediaFailed event. Fortunately, this task is easy. First, tweak your MediaElement tag as shown here :
<MediaElement ... MediaFailed="media_MediaFailed"></MediaElement>
Then, in the event handler, you can use the
ExceptionRoutedEventArgs.ErrorException property to get an exception object that describes
the problem. Here’s an example that displays the appropriate error message:
private void media_MediaFailed(object sender, ExceptionRoutedEventArgs e)
{
lblErrorText.Text = e.ErrorException.Message;
}

The MediaElement exposes a number of properties that allow you to control your playback.
Volume : Sets the volume as a number from 0 (completely muted) to 1 (full volume). The default value is 0.5.set IsMuted to true for temporarily muting.

Balance : Sets the balance between the left and right speaker as a number from -1 (left speaker only), 1(right speaker only) and 0 by default.

Position : Provides a TimeSpan object that indicates the current location in the media file.

<Slider Grid.Column="1" x:Name="sliderVolume" Minimum="0" Maximum="1" Value="0.5"
ValueChanged="sliderVolume_ValueChanged" ></Slider>

<Slider Grid.Row="1" Grid.Column="1" x:Name="sliderBalance" Minimum="-1" Maximum="1"
ValueChanged="sliderBalance_ValueChanged"></Slider>

When the user drags the thumb in the slider, the change is applied to the MediaElement :
private void sliderVolume_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
media.Volume = sliderVolume.Value;
}

private void sliderBalance_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
media.Balance = sliderBalance.Value;
}

The Mute check box sets the corresponding IsMuted property of the MediaElement :
private void chkMute_Click(object sender, RoutedEventArgs e)
{
media.IsMuted = (bool)chkMute.IsChecked;
}

Linq To Sql

LINQ to Sql  interact and provides query capability to relational database.

Architecture of LINQ to sql consists of :

Object Model - It consists of Data Context and Data Entities. Data entities are the partial classes generated by Linq to sql. Data context define connection to the database.It maps data entities with databae tables and
fills the objects into generic collection type called Table<>. It also maps Stored Procedures and user defined functions.
 
Object Relational Designer  

Runtime
 
Key Features of Linq to sql :-

1)Generating Object Model From db -  Linq to Sql connects to sql server db and creates ObjectModel by dragging  and dropping tables from the server explorer.

2)Stored Procedures and user defined functions support - linq to sql supports stored procedures and user-defined functions by generating corresponding methods in DataContext.

3)Framework compatibilities - linq to sql is part of .Net framework 3.5 and higher.

Strengths :-

1)Linq to sql queries are well-integrated with programming lang. this helps in avoiding Sql Injection attacks.

2)Uniform syntax for working with various data sources like xml, relational datastores like sql server.

3)Improve app. dev by proving Intellisense, compile time syntax checking and debugging support.

4)Support compiled queries and stored procedure to enhance the overall performance of db operations.

Weakness:-

1)Linq to Sql only works with Sql Server Db.

2)From main object, navigation to foreign key, reference object is not possible.

3)It supports only bottom-up design i.e database to object oriented and not the other way.

Summary :-

It overcome several drawbacks of Ado.Net by providing single uniform type query language to query relational and non relational datastores in obj oriented manner. User friendly object oriented syntax, highly
optimized for MS sql server.




Tuesday, 10 January 2012

Navigation In Silverlight

Navigation in Silverlight can be achieved by managing Root Visual in App.xaml. We can use layout container as Silverlight application's root visual, this container may be border or Grid. In root visual, we can change user control that represents first page with different user control that represents other page. This technique is simple and requires less codes. It also has ability of state management and animation.

//App.xaml.cs
   
       // This Grid will host pages.
        private Grid rootGrid = new Grid();

        private void Application_Startup(object sender, StartupEventArgs e)
        {
           // Load the first page.
            this.RootVisual = rootGrid;
            rootGrid.Children.Add(new Register());
        }

        public static void Navigate(UserControl newPage)
        {
            App currentApp = (App)Application.Current;
            // Change the currently displayed page.
            currentApp.rootGrid.Children.Clear();
            currentApp.rootGrid.Children.Add(newPage);
        }

Note : Navigate method is static for making process straightforward.

Now, In Silverlight application navigation can be performed by using this code :)

App.Navigate(new confirm());

Saturday, 19 November 2011

WCF With Silverlight

Here is an example of WCF services with Silverlight performing some mathematical operations like addition, substraction, etc.

Lets begin :)

1) Open Visual Studio -> Click New Project -> Select Silverlight from Project Type and then Specify Name and Location from New Project Window.

2) In New Silverlight Application, Select Asp.Net Web Application Project As New Web Project Type -> Ok.

3) Open Expression Blend for designing UI of application, it is easy to create user interface in blend.

//MainPage.xaml



<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"  x:Class="SLMathsDummy.MainPage"
    d:DesignWidth="600" d:DesignHeight="500">
    
<Grid x:Name="LayoutRoot" Background="#FFF8D1D1">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.373*"/>
            <ColumnDefinition Width="0.28*"/>
            <ColumnDefinition Width="0.347*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.144*"/>
            <RowDefinition Height="0.08*"/>
            <RowDefinition Height="0.08*"/>
            <RowDefinition Height="0.128*"/>
            <RowDefinition Height="0.08*"/>
            <RowDefinition Height="0.16*"/>
            <RowDefinition Height="0.328*"/>
        </Grid.RowDefinitions>

        <Button x:Name="btnAddition" HorizontalAlignment="Right" Margin="0,0,96,58" Width="75" Grid.Row="5" Content="Addition" FontWeight="Bold" VerticalAlignment="Bottom" Grid.Column="1">
            <Button.Foreground>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="Black" Offset="0"/>
                    <GradientStop Color="#FFF00B0B" Offset="1"/>
                </LinearGradientBrush>
            </Button.Foreground>
        </Button>
       

<Button x:Name="btnSubstract" Margin="96,0,0,0" Grid.Column="1" Grid.Row="5" Content="Substract" FontWeight="Bold" VerticalAlignment="Top" Width="75" HorizontalAlignment="Left" d:LayoutOverrides="Width">
            <Button.Foreground>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="Black" Offset="0"/>
                    <GradientStop Color="#FFF00B0B" Offset="1"/>
                </LinearGradientBrush>
            </Button.Foreground>
        </Button>
        
<Button x:Name="btnMultiply" Margin="0,0,93,2" Grid.Column="1" Grid.Row="5" Content="Multiply" FontWeight="Bold" VerticalAlignment="Bottom" Width="75" HorizontalAlignment="Right" d:LayoutOverrides="Width">
            <Button.Foreground>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="Black" Offset="0"/>
                    <GradientStop Color="#FFF00B0B" Offset="1"/>
                </LinearGradientBrush>
            </Button.Foreground>
        </Button>
        
<Button x:Name="btnDivide" HorizontalAlignment="Left" Width="75" Grid.Column="1" Grid.Row="5" Content="Divide" FontWeight="Bold" VerticalAlignment="Bottom" Margin="93,0,0,0">
            <Button.Foreground>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="Black" Offset="0"/>
                    <GradientStop Color="#FFF00B0B" Offset="1"/>
                </LinearGradientBrush>
            </Button.Foreground>
        </Button>
        
<TextBlock x:Name="txbFNumber" HorizontalAlignment="Right" Margin="0,8,4,16" Grid.Row="1" Text="First No :" TextWrapping="Wrap" d:LayoutOverrides="Height" Foreground="#FFF80D0D"/>
       
<TextBlock x:Name="txbSNumber" HorizontalAlignment="Right" Margin="0,8,4,16" Grid.Row="2" Text="Second No :" TextWrapping="Wrap" d:LayoutOverrides="Height" Foreground="#FFF21111"/>
      
<TextBlock x:Name="txbResult" HorizontalAlignment="Right" Margin="0,8,8,16" Grid.Row="4" Text="Result :" TextWrapping="Wrap" d:LayoutOverrides="Height" Foreground="#FFFA0D0D" FontWeight="Bold"/>
       
<TextBlock x:Name="txbResultSet" HorizontalAlignment="Left" Margin="0,8,4,16" Grid.Column="1" Grid.Row="4" TextWrapping="Wrap" d:LayoutOverrides="Height" Foreground="#FF102EEE" FontWeight="Bold"/>
        
<TextBox x:Name="txtFNo" Margin="8,8,0,8" Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" d:LayoutOverrides="Height" Foreground="#FF102EEE" Width="300"/>
       
<TextBox x:Name="txtSNo" Margin="8,8,0,8" Grid.Column="1" Grid.Row="2" TextWrapping="Wrap" d:LayoutOverrides="Height" Foreground="#FF102EEE" Width="300"/>
   
</Grid>
</UserControl>

Note : Don't worry for namespace that are in <UserControl>, they will appear automatically when you drag controls in design interface.

4) Click on Add -> New Item -> Select Silverlight-enabled WCF service. Default its name is Service1.svc.





5) //Service1.svc.cs

Replace existing Operation Contract DoWork() by following codes.

 [OperationContract]
        public int Addition(int num1, int num2)
        {
            return num1+num2;
        }

        [OperationContract]
        public int Substract(int num1, int num2)
        {
            return num1-num2;
        }

        [OperationContract]
        public int Multiply(int num1, int num2)
        {
            return num1*num2;
        }

        [OperationContract]
        public int Divide(int num1, int num2)
        {
            return num1/num2;
        }

 6) Add Service Reference



7) //MainPage.xaml.cs

private void btnAddition_Click(object sender, RoutedEventArgs e)
{
            int num1, num2;
            ServiceReference1.SLWCFAddServiceClient addService = new  ServiceReference1.SLWCFAddServiceClient();
            addService.AdditionCompleted += new EventHandler<SLWCFAdd.ServiceReference1.AdditionCompletedEventArgs>(addService_AdditionCompleted);
            num1 = Convert.ToInt32(txtFNo.Text.ToString());
            num2 = Convert.ToInt32(txtSNo.Text.ToString());
            addService.AdditionAsync(num1, num2); 
}


public void addService_AdditionCompleted(object s, ServiceReference1.AdditionCompletedEventArgs e)
        {
            txbResultSet.Text = e.Result.ToString();
        }

       
private void btnSubstract_Click(object sender, RoutedEventArgs e)
        {
            int num1, num2;
            ServiceReference1.SLWCFAddServiceClient subService = new SLWCFAdd.ServiceReference1.SLWCFAddServiceClient();
            subService.SubstractCompleted +=new EventHandler<SLWCFAdd.ServiceReference1.SubstractCompletedEventArgs>(subService_SubstractCompleted);
            num1 = Convert.ToInt32(txtFNo.Text.ToString());
            num2 = Convert.ToInt32(txtSNo.Text.ToString());
            subService.SubstractAsync(num1, num2);
        }

       
public void subService_SubstractCompleted(object s, ServiceReference1.SubstractCompletedEventArgs e)
        {
            txbResultSet.Text = e.Result.ToString();
        }

       
private void btnMultiply_Click(object sender, RoutedEventArgs e)
        {
            int num1, num2;
            ServiceReference1.SLWCFAddServiceClient multiService = new SLWCFAdd.ServiceReference1.SLWCFAddServiceClient();
            multiService.MultiplyCompleted += new EventHandler<SLWCFAdd.ServiceReference1.MultiplyCompletedEventArgs>(multiService_MultiplyCompleted);
            num1 = Convert.ToInt32(txtFNo.Text.ToString());
            num2 = Convert.ToInt32(txtSNo.Text.ToString());
            multiService.MultiplyAsync(num1, num2);
        }

 public void multiService_MultiplyCompleted(object s, ServiceReference1.MultiplyCompletedEventArgs e)
        {
            txbResultSet.Text = e.Result.ToString();
        }

private void btnDivide_Click(object sender, RoutedEventArgs e)
        {
            int num1, num2;
            ServiceReference1.SLWCFAddServiceClient divService = new SLWCFAdd.ServiceReference1.SLWCFAddServiceClient();
            divService.DivideCompleted += new EventHandler<SLWCFAdd.ServiceReference1.DivideCompletedEventArgs>(divService_DivideCompleted);
            num1 = Convert.ToInt32(txtFNo.Text.ToString());
            num2 = Convert.ToInt32(txtSNo.Text.ToString());
            divService.DivideAsync(num1, num2);
        }

public void divService_DivideCompleted(object s, ServiceReference1.DivideCompletedEventArgs e)
        {
            txbResultSet.Text = e.Result.ToString();
        }


8) Run the application.





Monday, 14 November 2011

LINQ Interview Questions And Answers

Here, some common LINQ interview questions which asked by the interviewer.  
 

What is use of ‘Distinct’ in a LINQ ?

It removes duplicate values from result set.

What is different between LINQ and Stored Procedure?

  •  We can debug LINQ as it is part of .Net, whereas Stored procedure can’t be.
  •  Deployment is easy with LINQ as everything compiled into DLL whereas with Stored procedure script is required for deployment.
  •  At compile time we can find error, if any in LINQ but it not possible with Stored procedure.
What is role of DataContext classes in LINQ?
  
DataContext  acts as a bridge between a  SQL Server database and the LINQ to SQL. It contains the connection string  and functions for accessing the database and for also  changing  the data in the database.   

In LINQ, ‘Select’ comes after ‘ From’, why?

In any programming language, variable defines first then conditions specifies. In LINQ also, all variables declared first by using ‘Select’ clause then ‘From’ clause is used for define conditions.

What is the extension of LINQ to SQL file ?

It is .dbml.

Disadvantage of LINQ over Stored procedure?

Stored procedure compiles one time and executed every time whereas LINQ compiled everytime , so Stored Procedure is faster as compare to LINQ.


Friday, 11 November 2011

WPF Interview Questions And Answers

Here, some common WPF interview questions which asked by the interviewer. 

Explain WPF?

Windows Presentation Foundation (WPF) is UI framework, used to create rich user experience application. It introduced in .NET 3.0. WPF supports 2D graphics, 3D graphics, animations, documents and multimedia. 

What do you mean by dependency properties in WPF?
Dependency properties are properties of one class and used by another class.
Let’s understand by an example:
<Ellipse Height=”70” Width=”70” Canvas.Right=”20” Canvas.Top=”30” />
Here ‘Canvas.Right’ and ‘Canvas.Top’ are dependency properties as it used by Ellipse to specify position within Canvas though it’s not properties of Ellipse.
Which namespace is using for animations and 3D graphics in WPF?

System.Windows.Media  namespace is using.

Which operating systems support WPF?
  •  Windows XP Service Pack 2 or later
  •  Windows7
  •  Windows Vista
How many layouts supported in WPF?
  •  Grid
  •  Stack Panel
  •  Dock Panel
  •  Wrap Panel
  •  Canvas Panel
Which type of documents supported by WPF?
WPF supports two types of documents, ‘Fixed Format Documents’ and ‘Flow Format Documents’.  Fixed format document is like PDF. It displays contents regardless of screen resolution and size.  Flow format document adjust content with respect to screen resolution and size.
What are advantages of WPF over Windows applications?
WPF has following capabilities:
  1. Supports 2D and 3D vector graphics.
  2. Animation
  3. Multimedia
  4. Fixed and Flow format documents
  5. Having all capabilities of Html and Flash.
  6. UI separates from code.




Wednesday, 9 November 2011

WCF Interview Questions And Answers

Here, some common WCF interview questions which asked by the interviewer. 

Explain briefly about WCF?
WCF is a programming platform and runtime system for building, configuring and deploying network-distributed services. It is latest service oriented technology. Interoperability is fundamental characteristic of WCF. WCF is combined feature of Web Service, Remoting, MSMQ, and COM+. WCF provides a common platform for all .NET communication.

What are different technologies involved in WCF?

There are mainly five technologies involved in WCF, these are :
  1. WSE [WS*] - Protocol Support.
  2. Messaging  - Message oriented programming.
  3. .Net Remoting - Extensibility location transparency.
  4. Enterprise Service - Attribute based programming.
  5. ASMX - Interop with other platforms.
What are advantages of WCF?

Advantages of WCF are :
  1. WCF is interoperable with other services but .Net Remoting requires client and service in .Net.
  2. WCF service provides better reliability and security as compare to Web Services.
  3. In WCF, there is no need to make much change in code for implementing the security model and changing the binding. Small change in the configuration will make your requirement.
Brief about WCF Hosting?
There are three ways of hosting WCF service :
Self Hosting
IIS Hosting
WAS(Windows Activation Service)
Explain address and all types of address in WCF?
Address describes where WCF service is hosted. Address is URL that client uses to connect to desired service.
Here is an example :

What is Binding in WCF?
 

Binding describes how client will communicate with services. There are different protocols available to communicate to client. Binding has several  characteristics :

Transport - Define base protocol to be used like HTTP, Named Pipes, TCP and MSMQ. 

Encoding(Optional) - Three types of encoding available - Text, Binary or Message Transmission Optimization Mechanism(MTOM). MTOM is interoperable message format that allows the effective transmission of attachments or large message. 

Protocol(Option) - Defines information to be used in Binding such as security transaction or reliable messaging capability.

What are types of Binding available in WCF? 
BasicHttpBinding – It uses SOAP over HTTP.
WsHttpBinding – It uses SOAP over HTTP, it also supports reliable message transfer.
NetTcpbinding – It uses SOAP over TCP, but server and client should be in .Net.
NetNamedPipesBinding – It uses SOAP over Named Pipes.

Explain contract and all types of contract in WCF?
 
Contract is platform-neutral and standard way of describing what services does. In WCF, all services are exposed as contract. There are four types of contracts :
Service Contract – It describes operation provided by service. A service should contain at least one service contract. Service Contract is defined by using [ServiceContract] attribute , it is similar to [WebMethod] of Web Services.

Data Contract – It describes data exchange between service and client. Data Contract is defined using [DataContract] and [DataMember] attribute.
Message Contract – It transfers information from service to client. WCF uses SOAP message format for communication.
Fault Contract – It handles and convey error message to the client when service get error.
What is concept of endpoint in WCF?
WCF service expose endpoints by which service is available to client.Endpoint is nothing but consists of ABC that is Address, Binding and Contract.

What is WCF Runtime?

WCF  runtime is set of objects for sending and receiving message.

What is Message in WCF?

WCF message is the unit of data exchange between client and service. It consists of several parts, including a body and header.

Difference between WCF and Web Service?
 

1) Web Services support hosting in IIS whereas WCF support hosting in IIS, WAS and Self-hosting.
2) Web Services can be invoked by Http whereas WCF service can be invoked by Http, Tcp, Named Pipes, MSMQ.
3) WCF Services are more reliable and secure as compare to Web Services.
4) WCF Services are more flexible as we make a new version of service we just have to expose a new endpoint.
5) In Web Service, [WebMethod] attribute specifies the method exposed to client. In WCF [OperationContract] attribute represents the method.

What is Service Host?

Service Host object is in process of  hosting the WCF service and registering endpoints. It loads the service configuration  endpoints, apply the settings. System.ServiceModel.ServiceHost namespace holds this object. This object is created while self hosting the WCF service.

There is scenerio, when one client has to access service SOAP using Http and other client have to access Binary using TCP, how can you acheive?

This can be acheived by adding extra endpoint in configuration file.

<endpoint address="http://locahost:8090/Service" contact="IMathService" binding="wsHttpBinding"/>
<endpoint address="net.tcp://locahost:8080/Service" contact="IMathService" binding="netTcpBinding"/>