Showing posts with label Wcf. Show all posts
Showing posts with label Wcf. Show all posts

Thursday, 9 July 2015

WCF interviews KIT Part-1


1. What is WPF?
WPF is the latest presentation API by Microsoft Windows. It is 2D and 3D graphic engine. Its capabilities include:-
·          All the common user controls. For example, check boxes, buttons, sliders etc.
·          Supports flow and fix format documents
·          all the functionality of Flash and HTML
·          Data binding
·          Multimedia
·          Animation

2. What are the types of documents supported by WPF?
Two types of the documents supported by Windows Presentation Foundation (WPF) are the Flow format and fixed Format document. Flow format document alters the content to fit the screen size while fixed format document present content irrespective of the screen size.

3. Name the namespace required for working with 3D.
The namespace required for working in 3D is System.Windows.Media.Medi3D.

4. Is it right to say that WPF has replaced DirectX?
No, WPF can never replace DirectX. WPF cannot be used to create games with stunning graphics. WPF is meant to be a replacement for windows form, not DirectX.

5. What are dependency properties?
Properties that belong to a specific class but can be used for another are called the dependency properties.

6. How can the size of StatusBar be increased proportionally?
By overruling the ItemsPanel attribute of StatusBar with a grid. The grid’s columns can be appropriately configured to get the desired result.

7. What are Freezable objects in WPF?
An object, which has its state locked down, so that it becomes unchangeable, is known as a freezable object. Such objects perform better. It is also safer if they are required to be shared between threads. 
8. Why should WPF be preferred over Adobe Flash?
WPF is a more recent technology and thus has the latest development tools. It supports a broader range of programming languages and has a robust control reuse.

 9. How is Silverlight different from WPF browser application?
One of the major differences is that .NET framework is required for running WPF browser applications on the client machine. But Silverlight runs using only the plug-in. Another point of difference is that applications made in WPF depend on the OS as .NET Framework only runs on Windows. On the other hand, the Silverlight plug-in can be installed on those OSs also, which are not Windows.

10. Name the methods present in the DependencyObject.
It has three objects, namely:
·          SetValue
·          ClearValue
·          GetValue

11. Write about PRISM.
PRISM is a framework for creating complex applications for WPF, Silverlight or Windows Phone. PRISM utilizes MVVM, IC, Command Patterns, DI and Separation of Concerns to get loose coupling.

12. Is it possible to use Windows Forms in a WPF application?
Yes, Windows form can be used in WPF. Windows form can appear as a WPF pop. The controls of this Window form can be placed besides WPF controls in a WPF page by utilizing the functions of the WindowsFormsHost control that comes preinstalled.

13. Describe CustomControl briefly.
CustomControl widens the functions of existing controls. It consists of a default style in Themes/Generic.xaml and a code file. It is the best way to make a control library and can also be styled or templated.

 14. Name the common assemblies used in WPF?
·          PresentationFoundation
·          WindowsBase
·          PresentaionCore

15. Define Path animations in WPF
Path animation is a type of animation in which the animated object follows a path set by the Path geometry.

16. Can WPF applications be made without XAML?
Yes WPF applications can be created without XAML as using XAML in WPF is a matter of choice.

 17. What are the types of windows in WPF?
WPF has three types of windows:
·          Normal Window
·          Page Window
·          Navigate Window

18. How can elements in a ListBox be sorted?
Sorting can be done by using a property of the ItemsCollection object. ItemsCollection contains an attribute, SortDescriptions, which holds System.ComponentModel.SortDescription instances. Every SortDescription instance defines how the elements should be sorted and indicates if the sort is descending or ascending.
For instance, this code sorts elements of ContentControl on the basis of their word count property:
myItemsControl.Items.SortDescriptions.Add(new SortDescription(“WordCount”, ListSortDirection.Descending));

19. How is MVVM different from MVC?
MVC stands for Model-View Controller and.MVVM stands for Model-View ViewModel.
In MVVM, View Model is used instead of a controller. This View Model is present beneath the UI layer. It reveals the command objects and data that the view requires. It acts like a container object from which view gets its actions and data.

20. Explain Routed events in WPF.
An event, which can invoke handlers on more than one listeners present in an element tree, instead of the single object which called the event, is known as a Routed event.

21. How is System.Windows.Media.Visual dll utilized in WPF?
It is used whenever a requirement for creating custom user interface arises. It is a drawing object, which gives instructions for making an object. These instructions include opacity etc. of the drawing. The Visual class also bridges the functionalities of WPF managed classes and the MilCore.dll.

22. What are the various layout panels in WPF?
They are:
·          Stack Panel
·          Grid Panel
·          Canvas Panel
·          Dock Panel
·          Wrap Panel


23. Name the important subsystems in WPF
The major subsystems are:
·          Windows.Controls.Control
·          Windows.DependancyObject
·          Windows.FrameworkElement
·          Windows.Media.Visuals
·          Object
·          Threading.DispatcherObject
·          Windows.UIElements

24. What does BAML mean in WPF?
BAML is the abbreviation for Binary Application Markup Language. It is nothing but XAML that has been tokenized, parsed and changed into binary form. BAML is a compressed declarative language, which gets loaded and parsed quicker than XAML.

 25. What is Difference between Page and Window Controls in WPF?
The basic difference is that Window Control presides over Windows Application while Page Control presides over the hosted Browser Applications. Also, Window control may contain Page Control, but the reverse cannot happen.

Previous                                                                                                                             Next Part-2

Monday, 22 October 2012

WCF Introduction


Introduction

This article demonstrates how to create a WCF service application. This article also covers basic information of all the contracts and a code demonstration.

What is WCF?

WCF is a combined feature of Web Service, Remoting, MSMQ and COM+. WCF provides a common platform for all .NET communication. It is a part of .Net 3.0.

What-is-WCF.jpg

Difference between WCF and Web service
  • In a web service we need to add the [WebService] attribute to the class.
    In WCF we need to add the [ServiceContract] attribute to the class.
     
  • Add the [WebMethod] attribute to the method in a web service.
    Add the [OperationContract] attribute to the method in WCF.
     
  • For serialization in a web service use the System.Xml.serialization namespace.
    WCF uses the System.Runtime.Serialization namespace for serialization.
     
  • We can host a web service in IIS.
    We can host WCF in IIS, WAS (Windows Activation Service), self-hosting and a Windows Service .
Let's see how to create a WCF service application step-by-step.

Step 1

Start Menu >> All Programs >> Microsoft Visual Studio 2010 >> Microsoft Visual Studio 2010

In that "File" >> "New" >> "Project..."

Microsoft-Visual-Studio-2010.jpg

Step 2
  • Select WCF from Installed Templates
  • Select .NET Framework 4 from dropdownlist
  • Select WCF Service Application
  • Give desired name and select the location
  • Click on OK button

    Select-WCF-Installed-Templates.jpg
Step 3

Now your Windows Communication Foundation service application is ready as a default service. You will see in Solution Explorer Service1.svc and IService1.cs

Open the IService1.cs file, as in:

Open-Service1.cs-file.jpg

In this file you willl find a ServiceContract, OperationContract and DataContract.

Service Contract

Service contract is an attribute applied to an interface i.e. IService1. It describes which operations the client can perform on the services.

Service-Contract.jpg

Operation Contract

Operation Contract is an attribute applied to methods in interfaces i.e. IService1. It is used to define a method in an interface.

Operation-Contract.jpg

Data Contract

DataContract defines which data types are passed to and from the service. It is used to define a class and the DataMember attribute is used to define the properties.

Data-Contract.jpg

WCF Contracts map directly to a corresponding web services standard:
  • ServiceContracts map to WSDL
  • DataContracts map to XSD
  • MessageContracts map to SOAP
Step 4

There is one method "GetData" which accepts parameters of type int.

WCF-Contracts-map.jpg

An implementation of this method is in the Service1.svc.cs file. This method returns a string with the value you passed as a parameter.

Service1-svc-cs.jpg

Step 5

Now let us run this service.

run-this-service.jpg

You can test your service in WCF Test Client. WCF Test Client is a GUI tool which enables us to enter parameters, invoke services with these parameters and view the responses returned by services.

Now double-click on the "GetData" method and enter a parameter value of type System.int32. Here I enter "25" as a parameter value and press the "Invoke" button. You will get "You entered: 25" as a response.

GetData-method.jpg