dot net questions 35

Upload: immaculatepriya

Post on 09-Apr-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Dot Net Questions 35

    1/23

    http://www.syncfusion.com/FAQ/WPF/default.aspx#61http://www.wpf.megasolutions.net/WPF-Concepts-Routed-Events.aspxhttp://www.wpftutorial.net/DependencyProperties.htmlhttp://www.techshankar.com/technologies/wpf-interview-questions-with-answers/http://social.msdn.microsoft.com/Forums/en/wpf/thread/a2988ae8-e7b8-4a62-a34f-

    b851aaf13886http://www.codeproject.com/KB/WPF/WPFSilverLight.aspx

    What AJAX framework do you recommend for PHP applications?SAjax, NAjax, FAjax.

    All of them are ok, but it it best to make your own to suit your needsWhat are the different frameworks available In AJAX?A good framework that I have seen is "Zephyr".

    It is used with php and seems to be very easy to use.You can get it from here http://zephyr-php.sourceforge.net[Prototype.JS Framework is available with detailed documentation, its very easy tohandle AJAXand JavaScript, Introduce $ concept its very simple, For Ajax specially u don't need tocheck cross broswer, OPen, Close and error handling through traditional AJAX. ]Who is the inventor of AJAX?nobody invented AJAX....

    Microsoft first implemented the XMLHTTPRequest object in Internet Explorer 5 for

    Windowsas an ActiveX object.it is the term coined after this support.Asynchronous javascript and XML.[They're probably after the name Jesse James Garrett of Adaptive Path, who coined theterm]

    What is the difference between DOM Parser and AUX Parser?In DOM parser is used at server side in php using domxml.While AUX parser is used at client side in javascriptWhat is the back ground work going on when you type www.yahoo.com in your web

    browser?actually there is nothing like yahoo.co.in it is actually an ip address which is resolved byDNS(domain name server ) so when you type yahoo.co.in this is the work of DNS toidentify the

    pertucular page and redirect you to that page.[ 1. Browser gives a DNS request to theDNS server to resolve the name www.yahoo.co.in. The DNS request may be a TCP or UDP requestto the

    http://www.syncfusion.com/FAQ/WPF/default.aspx#61http://www.wpf.megasolutions.net/WPF-Concepts-Routed-Events.aspxhttp://www.wpftutorial.net/DependencyProperties.htmlhttp://www.techshankar.com/technologies/wpf-interview-questions-with-answers/http://social.msdn.microsoft.com/Forums/en/wpf/thread/a2988ae8-e7b8-4a62-a34f-b851aaf13886http://social.msdn.microsoft.com/Forums/en/wpf/thread/a2988ae8-e7b8-4a62-a34f-b851aaf13886http://www.codeproject.com/KB/WPF/WPFSilverLight.aspxhttp://www.syncfusion.com/FAQ/WPF/default.aspx#61http://www.wpf.megasolutions.net/WPF-Concepts-Routed-Events.aspxhttp://www.wpftutorial.net/DependencyProperties.htmlhttp://www.techshankar.com/technologies/wpf-interview-questions-with-answers/http://social.msdn.microsoft.com/Forums/en/wpf/thread/a2988ae8-e7b8-4a62-a34f-b851aaf13886http://social.msdn.microsoft.com/Forums/en/wpf/thread/a2988ae8-e7b8-4a62-a34f-b851aaf13886http://www.codeproject.com/KB/WPF/WPFSilverLight.aspx
  • 8/8/2019 Dot Net Questions 35

    2/23

    DNS server. 2. After the IP address is recieved, the browser makes a socket connectionwith thatIP Adress and port 80 ( if explicit port not given).3. Now a Http GET request is fired bythe

    browser on that socket connection and when the response starts coming it parses it and

    shows iton the screen.4. Note depending on the content of the first response , multiple socketsmight beopen to retrieve embedded images and objects in the same page.]

    what is AJAX ? How it is implemented? Given skeleton example?AJAX is made for suppoting XML format that can be used with JAVA API.[ Ajax is aconcept or collection of technologies which include html or dhtml, javascript, DOM,XMLHttpRequestobject, XML and a server side scripting language. XML is for data transfer and is not a

    mandatory choice, a user can transfer data in plain text or jason format. Also a server sidescripting language is not a requirement but is used in database applications as javascriptcannotspeak to database, in such situation other server side scripting language like php isused.eg: keepwatching, must add comments to code, will add soon.].[AJAX - Asynchronus JavascriptAndXML, Using JavaScript technology, an HTML page can asynchronously make calls tothe server from which it was loaded and fetch content that may be formatted as XML documents,HTMLcontent, plain text, or JavaScript Object Notation (JSON). The JavaScript technologymay thenuse the content to update or modify the Document Object Model (DOM) of the HTML

    page. ]What are the AJAX tools available for ASP.NET?There are lot of tools are available for the AJAX which works with .NET like Infrajistics,OBOUT...

    What is Mashups in AJAX?An Ajax mashup is a hybrid Web application. It uses Ajax techniques to present a rich UIthatupdates itself in place using content that it retrieves asynchronously from multiplesources. Theserver sends an initial page to the browser, which then makes calls to retrieve updatedcontent.These calls can be made directly to the third-party sources from the browser or back totheoriginating server, which acts as a proxy for the third-party content.How dataset is accessed using AJAX?

  • 8/8/2019 Dot Net Questions 35

    3/23

    What are the components of JAVA that could be used with AJAX?The components of Java that could be used with AJAX are XML, JavaScript andXMLhttpWhat are the technologies combined in AJAX?The AJAX combined the client side technolgies to implement.

    these technolgy includesJava ScriptDHTMLHtmlHow is data binding handled in AJAX?What is the architecture used in AJAX?What is the AJAX request used for retrieving data when the data will not change for agivenrequest URL?What are the steps for integration of AJAX into the web site?What does AJAX stands for?

    AJAX:- Asynchronous JavaScript and XMLWhat is Comet in AJAX?What is the concept used in AJAX to communicate changes data between the server andclient?What is JSON in AJAX?JSON is the JavaScript Object Notation, and it is a lightweight data interchange format. It

    provides Java Scripts eval() method to easily parse an XML.What new features are available in AJAX that makes it powerful?What is the use of Script Tag in VBScript?What are the vital security measures to be handled while using AJAX?How is a record set retrieved by using an AJAX object? What are the browsers and

    platformssupported by AJAX?

    How is user interfaces powerful in AJAX?How asynchronous processing is handled using Ajax?With AJAX, your JavaScript can communicate directly with the server, using theJavaScriptXMLHttpRequest object. With this object, your JavaScript can trade data with a webserver,without reloading the page.AJAX uses asynchronous data transfer (HTTP requests) between the browser and theweb server,allowing web pages to request small bits of information from the server instead of whole

    pages.The AJAX technique makes Internet applications smaller, faster and more user-friendly.What are the use of drag and drop feature of AJAX?What are the components in the architecture of AJAX?Why is HTTP GET request used by AJAX requests?What is the use of Ajax non-turn tools?

  • 8/8/2019 Dot Net Questions 35

    4/23

    What are the security issues with AJAX?What are the differences between AJAX and JavaScript?What are the environments in which AJAX can be used?2

    What is synchronous request in AJAX?What are the browsers that support AJAX?Why is AJAX a comfortable fit with JAVA?What must be done to use an AJAX code be used across different browsers?What are the steps or considerations one should take while using AJAX?What are the methods of handling images in AJAX?How is encoding handled in AJAX?What are the limitations of AJAX?What is the reason of using HTTP POST request by AJAX requests?What are the benefits of AJAX over Java applet?What are the steps for handling concurrent requests in AJAX?

    I believe it can be done by creating the XMLHTTPRequest object from within an inner function,instead of creating a seperate function for making a new XmlHttprequest object withingthe same

    page...What is AJAX polling?How is interaction with an AJAX client handled?how many types of ready states in ajax?If a page only has one gridview, no other controls. Should Ajax be used? Justifyxml file parsing system?Is DOJO a part of AJAX What is AJAX and WHAT is DOJO?Is the server or the client in control in AJAX?It depends. With AJAX the answer is more in between. Control can be more centralizedin aserver-side component or as a mix of client-side and server-side controllers.Centralized server-side controller - When having a more centralized controller the key isto makesure the data in client-side page is in sync with that of the server. Some applications maykeep allthe state on the server and push all updates to client DOM via a simple JavaScriptcontroller.Client and server-side controllers - This architecture would use JavaScript to do all

    presentationrelated control, event processing, page manipulation, and rendering of model data on theclient.The server-side would be responsible for things such as business logic and pushingupdatedmodel data to the client. In this case the server would not have intimate knowledge of the

    presentation short of the initial page that would be sent to the client page request.

  • 8/8/2019 Dot Net Questions 35

    5/23

    There are some use cases where an entire AJAX application can be written in a single page. Keepin mind if you choose this type of architecture that navigation and bookmarking should

    beconsidered.

    What is the role of Ajax in enhancing user experience?AJAX is not a new technology but a combination of several existing technologies in anew way.These include HTML, CSS, DOM, XML, XSLT, XMLHttpRequest and Javascript. TheacronymAJAX stands for Asynchronous Javascript and XML. AJAX is based on open standardssupported by many browsers and platforms. AJAX is a new paradigm for building webapplication.What is naming context?A set of associations between unique, atomic, people-friendly identifiers and objects.What is one-way messaging? A method of transmitting messages without having to block

    until aresponse is received.How can I call a Java method from Javascript?3

    Direct Web Remoting is an open source Java library which allows for easy integration of AJAXinto your web site. It allows you to call Java methods directly from Javascript.Which browsers support AJAX?Internet Explorer 5.0 and up, Opera 7.6 and up, Netscape 7.1 and up, Firefox 1.0 and up,Safari1.2 and up, among others.Is there any way that an AJAX object can get back a record set?You could build an XML document out of your recordset and send that back to theserver, sayyou had a redord set for a user with the following details (name, surname, age, email),youcould build an xml document like this:

    * How can I animate a BorderThickness value ? ThicknessAnimation* How do I create a Borderless Window in WPF ? To get a border-less window, you needto set the following attributes on your Window.

    WindowStyle="None" ShowInTaskbar="False" AllowsTransparency="True" Background="Transparent"

  • 8/8/2019 Dot Net Questions 35

    6/23

    * How can I get an enumerator to the ContentControl s logical child elements ?

    The LogicalChildren of a ContentControl is of "protected-type" access. You can derive acustom class from it and then expose a public version of the "LogicalChildren" property.

    $$[C#] public class SPanel : StackPanel { public System.Collections.IEnumerator LogicalChildren { get { return base.LogicalChildren; } } } $$

    * Can I create a ContentTemplate and apply the templ* How can I create Four Button controls with the con* How can I apply the TypeConverter Attribute?* What way can a custom class can be defined in XAML* Which namespace is used to associate namespace ide* How can I map CLR Namespaces to XML Namespaces in

    * What are the limitations of Inline Styles and Temp* How can I create a custom WPF button whose look an* How can I set a ControlTemplate ?* How can I create an extended style ?* How can I restrict the use of style ?* How placing controls in a WrapPanel differs from a* When I try to add multiple controls to a button it* How can I add a CommandBinding to a window using m* How do I create a CommandBinding using a RoutedCom* What is Commanding in WPF?* How can I obtain a writable copy of a Read-Only Fr

    * How can I determine whether a Freezable Is Frozen?* What is a Freezable?* What is Path animation?* ow do I trigger an animation when the data in the * ow do I trigger an animation when the data in the * How can I use an application resource ?* How can I handle the input event through XAML?* What is a Routed event?* How can I use an application resource ?* How can I handle the input event through XAML?* What is a Routed event?* How can I set an attached property in code?* What is Attached Properties and how to register it* How can I register the default value of the State * How can I use Dependency Property MetaData?* How can I create Custom Read-Only Dependency Prope* What is Attached Properties and how to register it* How can I register the default value of the State * How can I use Dependency Property MetaData?

  • 8/8/2019 Dot Net Questions 35

    7/23

    * How can I create Custom Read-Only Dependency Prope* How can I enumerate all the descendants of a visua* How can I override the Logical Tree ?* What is WPF?* How can I use a BulletDecorator control that uses

    * How can I animate the thickness of a border by usi* How can I Save, Load, and Print RichTextBox Conten* How do I support drag-and-drop for a RichTextBox?* How do I create and save a RichTextFormat (RTF) fi* How do I add a hyperlink to a RichTextBox control * How can I customize the Ticks on a Slider ?* How can I use the Content-Scrolling Methods of Scr* How can I use the member values of the enumeration* How can I style a Separator used as a Menu Item ?* How do I enable the mnemonics (underlines) being d* How can the DrawVisual be used for rendering image

    * How do I access / edit the metadata associated wit* How to rotate an image ?* Why does adding images to an ImageList in the Desi* How can I crop an Image ?* How can I convert an Image to grayscale ?* How can I create and use a GridLengthConverter Obj* How can I make sure that a GridSplitter Is visible* How can I save the contents of a FlowDocumentReade* How can I load an XAML file into a FlowDocumentRea* How to load an XPS document into the DocumentViewe* How can I DataBind DocumentViewers Zoom Property * How can I extend the style of a DocumentViewer ?* How can I replace the style of a DocumentViewer ?* How do I make the Expander button to be justified * How can I bind the Expanders header elements Wid* How can I create an Expander with a ScrollViewer ?* How do I make the Context Menu to close after a se* How can I create a shared Context Menu ?* How can I enable a Context Menu on a disabled Cont* How do I make the Context Menu appear only when cl* When I tab into a toolbar in WPF I cant tab out a* How can I apply a Style to a Menu control on a Too* How do I determine which button in a ToolBar is cl* How do I create custom layout for StatusBar items?* How do I display items in a ListBox horizontally?* How do I bind a string array with a ListBox?* How do I fill a ComboBox with the available fonts * How do I support browsing for a text file and read* How do I make a TextBox use all upper-case (or low* How do I format numbers, dates and currencies in a

  • 8/8/2019 Dot Net Questions 35

    8/23

    * How can I animate a Popup ?* How do I display the PrintPreview as a maximized w* How can I create and display a PrintDialog ?* How can I create a ProgressBar and use an animatio* How can I add a style to a TabItem that is used in

    * How do I make the tabs in a TabControl appear on t* How do I dynamically hide and unhide tabs in a Tab* How do I prevent the user from changing the select* How can I use the ToolTipService properties to spe* Can I delay the display of a ToolTip ?* Does XAMLPAD support custom controls ?* What is XAMLPAD ?* What are the file formats supported by ZAM3D ?* What is ZAM3D ?* How do I add custom controls to an application usi* Will you provide a tool to convert Windows Forms a

    * How can I host a Windows Forms Composite Control i* How can I leverage my current investment in Window* How do I host a Windows Forms control in a WPF app* How can I use Windows Forms in a WPF application ?* How can I set the Owner property of the WPF window* How can I HwndSource Treats ComponentDispatcher Ev* How can I write Message Loops ?* Does WPF support MDI ?* How do I host Windows Forms control in a WPF Windo* How do I create a child window in WPF ?* How launch conditions are useful and how to add on* How do I deploy shared components ?* How do I add registry entries in a setup project ?* How to navigate between pages in an application ?* When I run an XBAP application, I get Application * Are XAML Browser Applications OS independent ?* How does Rendering work in Frame control ?* What is the difference between Frame and Navigatio* Can I add prerequisites in my ClickOnce deployment* How does ClickOnce deployment work ?* Can I override the default categories for platform* How can I specify in the .proj file whether to lea* How can I set the substitution property by overrid* How can I set the Language property to the current* What are the three types of Localizability Attribu* What are the objects involved in DragandDrop?* How to use binding in XAML ?* How to get the default template of a control progr* How to edit templates using Microsoft Expression B* How do I build an ItemsControl ControlTemplate ?

  • 8/8/2019 Dot Net Questions 35

    9/23

    * How do I get the associated Icon from a file in th* Is there any way to get to the Edit control or the* How can I use Hooks in .NET?* How do I maximize my main window?* How do I convert LParam in a message from IntPtr t

    * How can I capture output from an arbitrary console* How do I hit a web page from within a button handl* How to add an extern reference to a Win32 API?* Using a wide pen, how do I draw a series of line s* How to access elements that are embedded inside th* What is the use of a ControlTemplate ?* What are the different models for Control authorin* Where can I find information about guidelines to b* How do I remove the Adorner from an element ?* How do I bind an Adorner to an Element ?* How to add a custom adorner ?

    * Where can adorners be used ?* What is an adorner ?* How HitTest methods in VisualTreeHelper is useful * How do I enumerate child objects in a visual tree * What is the order in which the controls are render* How can I use a DoubleAnimation to rotate the text* How can I create a combine hard and soft shadow ?* How can I programmatically print XPS Files ?* Can I embed a figure into a paragraph of text ?* How can I use the BlockUIContainer element to host* How can I define three paragraphs under one sectio* How can I create an application that is used to de* How can I Match Annotations with Annotated Objects* How can I use MemoryStream to create a deep clone * How can I store a given document in a specific for* How do I add controls to Panel Content Model type * How can I use Event Trigger to control a StoryBoar* How can I animate a BorderThickness value ?* How do I create a Borderless Window in WPF ?* How can I get an enumerator to the ContentControl* Can I create a ContentTemplate and apply the templ* How can I create Four Button controls with the con* How can I apply the TypeConverter Attribute?* What way can a custom class can be defined in XAML* Which namespace is used to associate namespace ide* How can I map CLR Namespaces to XML Namespaces in * What are the limitations of Inline Styles and Temp* How can I create a custom WPF button whose look an* How can I set a ControlTemplate ?* How can I create an extended style ?

  • 8/8/2019 Dot Net Questions 35

    10/23

    * How can I restrict the use of style ?* How placing controls in a WrapPanel differs from a* When I try to add multiple controls to a button it* How can I add a CommandBinding to a window using m* How do I create a CommandBinding using a RoutedCom

    * What is Commanding in WPF?* How can I obtain a writable copy of a Read-Only Fr* How can I determine whether a Freezable Is Frozen?* What is a Freezable?* What is Path animation?* ow do I trigger an animation when the data in the * ow do I trigger an animation when the data in the * How can I use an application resource ?* How can I handle the input event through XAML?* What is a Routed event?* How can I set an attached property in code?

    * What is Attached Properties and how to register it* How can I register the default value of the State * How can I use Dependency Property MetaData?* How can I create Custom Read-Only Dependency Prope* How can I enumerate all the descendants of a visua* How can I override the Logical Tree ?* What is WPF?

    WPF

    1 :: What is WPF?Windows Presentation Foundation (WPF) is the presentation subsystem feature of the.NET Framework 3.0. It is pre-installed in as a part of Windows Vista, It is also availablefor installation on Windows XP SP2 and Windows Server 2003. It supports the rich User Experiences (UX) that have been made possible by advances in hardware and technologysince the GDI based UI architecture was initially designed in the 1980's.2 :: What is XBAP?XBAP stands for XAML Browser Application. XBAP allows for WPF applications to beused inside a browser. The .NET framework is required to be installed on the clientsystem. Hosted applications run in a partial trust sandbox environment. They are notgiven full access to the computer's resources and not all of WPF functionality isavailable.3 :: What is XAML extensible markup language?XAML is an extensible markup language based on XML. XAML can be thought of as adeclarative script for creating .NET 3.0 UI. It is particularly used in WPF as a user interface markup language to define UI elements, data binding, eventing and other features. It is also used in Windows Workflow Foundation (WF), in which the workflowsthemselves can be defined in XAML code.4 :: How can I enumerate all the descendants of a visual object?

  • 8/8/2019 Dot Net Questions 35

    11/23

    You can enumerate all the descendants of a visual object as follows :

    [C#]

    // Enumerate all the descendants of the visual object.

    static public void EnumVisual(Visual myVisual){for (int i = 0; i < VisualTreeHelper.GetChildrenCount(myVisual); i++){// Retrieve child visual at specified index value.Visual childVisual = (Visual)VisualTreeHelper.GetChild(myVisual, i);

    // Do processing of the child visual object.

    // Enumerate children of the child visual object.EnumVisual(childVisual);

    }}5 :: How can I create Custom Read-Only Dependency Properties?The typical reason for specifying a read-only dependency property is that these are the

    properties that is used to determine the state, but where the state is defined in a multitudeof factors. A typical example for a read-only property is IsMouseHover

    This example shows how to 'register' an attached property as read-only. You can usedependency properties on any 'DependencyObject' types.

    [C#] public static readonly DependencyProperty IsBubbleSourceProperty =DependencyProperty.RegisterReadOnly("IsBubbleSource",typeof(Boolean),typeof(AquariumObject),new FrameworkPropertyMetadata(false,FrameworkPropertyMetadataOptions.AffectsRender));

    6 :: How can I mark the default value of a custom dependency property to be false?Here is an example :

    [C#]

    public class MyStateControl : ButtonBase{

    public MyStateControl() : base() { } public Boolean State{

  • 8/8/2019 Dot Net Questions 35

    12/23

    get { return (Boolean)this.GetValue(StateProperty); }set { this.SetValue(StateProperty, value); }}

    public static readonly DependencyProperty StateProperty =DependencyProperty.Register(

    "State", typeof(Boolean), typeof(MyStateControl),new PropertyMetadata(false));}7 :: How can I set an attached property in code?The following example shows how you can set an attached property in code.

    [C#]

    DockPanel myDockPanel = new DockPanel();CheckBox myCheckBox = new CheckBox();myCheckBox.Content = "Hello";myDockPanel.Children.Add(myCheckBox);

    DockPanel.SetDock(myCheckBox, Dock.Top);8 :: How can I use an application resource?The following example shows an application definition file. The application definitionfile defines a resource section (a value for the Resources property). Resources defined atthe application level can be accessed by all other pages that are part of the application. Inthis case, the resource is a declared style. Because a complete style that includes a controltemplate can be lengthy, this example omits the control template that is defined withinthe ContentTemplate property setter of the style.

    [XAML]

    ...

    Commanding is an input mechanism in Windows Presentation Foundation (WPF) which provides input handling at a more semantic level than device input.

    The routed command model in WPF can be broken up into four main concepts: thecommand, the command source, the command target, and the command binding:

  • 8/8/2019 Dot Net Questions 35

    13/23

    The command is the action to be executed. The command source is the object which invokes the command. The command target is the object that the command is being executed on. The command binding is the object which maps the command logic to the

    command.

    A CommandBinding associates a command with the event handlers that implement thecommand.

    The CommandBinding class contains a Command property, and PreviewExecuted ,Executed , PreviewCanExecute , and CanExecute events.

    The command library consists of the following classes: ApplicationCommands , NavigationCommands , MediaCommands , EditingCommands , and theComponentCommands . These classes provide commands such as Cut, BrowseBack andBrowseForward , Play , Stop , and Pause .

    What is a Routed event?

    In a typical WPF application, it contains many elements. These elements exist in anelement tree relationship with each other. A routed event is a type of event that caninvoke handlers on multiple listeners in an element tree, rather than just on the object thatraised the event.

    WCF

    1 :: What is WCF?Windows Communication Foundation (WCF) is an SDK for developing and deployingservices on Windows. WCF provides a runtime environment for services, enabling you toexpose CLR types as services, and to consume other services as CLR types.

    WCF is part of .NET 3.0 and requires .NET 2.0, so it can only run on systems thatsupport it.2 :: What is service and client in perspective of data communication?

    A service is a unit of functionality exposed to the world.

    The client of a service is merely the party consuming the service.3 :: What is address in WCF and how many types of transport schemas are there in WCF?Address is a way of letting client know that where a service is located. In WCF, everyservice is associated with a unique address. This contains the location of the service andtransport schemas.

    http://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.command.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.previewexecuted.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.executed.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.previewcanexecute.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.canexecute.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.canexecute.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.applicationcommands.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.applicationcommands.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.navigationcommands.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.mediacommands.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.mediacommands.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.documents.editingcommands.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.documents.editingcommands.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.componentcommands.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.applicationcommands.cut.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.navigationcommands.browseback.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.navigationcommands.browseback.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.navigationcommands.browseforward.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.mediacommands.play.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.mediacommands.play.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.mediacommands.stop.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.mediacommands.pause.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.command.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.previewexecuted.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.executed.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.previewcanexecute.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.commandbinding.canexecute.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.applicationcommands.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.navigationcommands.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.mediacommands.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.documents.editingcommands.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.componentcommands.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.applicationcommands.cut.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.navigationcommands.browseback.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.navigationcommands.browseforward.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.mediacommands.play.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.mediacommands.stop.aspxhttp://msdn.microsoft.com/en-us/library/system.windows.input.mediacommands.pause.aspx
  • 8/8/2019 Dot Net Questions 35

    14/23

    WCF supports following transport schemas

    HTTPTCPPeer network

    IPC (Inter-Process Communication over named pipes)MSMQ

    The sample address for above transport schema may look like

    http://localhost:81http://localhost:81/MyServicenet.tcp://localhost:82/MyServicenet.pipe://localhost/MyPipeServicenet.msmq://localhost/private/MyMsMqServicenet.msmq://localhost/MyMsMqService

    4 :: What are contracts in WCF?In WCF, all services expose contracts. The contract is a platform-neutral and standardway of describing what the service does.

    WCF defines four types of contracts.

    Service contracts

    Describe which operations the client can perform on the service.There are two types of Service Contracts.ServiceContract - This attribute is used to define the Interface.OperationContract - This attribute is used to define the method inside Interface.

    [ServiceContract]

    interface IMyContract

    {

    [OperationContract]

    string MyMethod( );

    }

    class MyService : IMyContract

    {

  • 8/8/2019 Dot Net Questions 35

    15/23

    public string MyMethod( )

    {

    return "Hello World";

    }

    }

    Data contracts

    Define which data types are passed to and from the service. WCF defines implicit

    contracts for built-in types such as int and string, but we can easily define explicit opt-indata contracts for custom types.

    There are two types of Data Contracts.DataContract - attribute used to define the classDataMember - attribute used to define the properties.

    [DataContract]

    class Contact

    {

    [DataMember]

    public string FirstName;

    [DataMember]

    public string LastName;

    }

    If DataMember attributes are not specified for a properties in the class, that property can't be passed to-from web service.

  • 8/8/2019 Dot Net Questions 35

    16/23

    Fault contracts

    Define which errors are raised by the service, and how the service handles and propagateserrors to its clients.5 :: Where we can host WCF services?

    Every WCF services must be hosted somewhere. There are three ways of hosting WCFservices.

    They are

    1. IIS2. Self Hosting3. WAS (Windows Activation Service)

    6 :: What is binding and how many types of bindings are there in WCF?A binding defines how an endpoint communicates to the world. A binding defines the

    transport (such as HTTP or TCP) and the encoding being used (such as text or binary). A binding can contain binding elements that specify details like the security mechanismsused to secure messages, or the message pattern used by an endpoint.

    WCF supports nine types of bindings.

    Basic binding

    Offered by the BasicHttpBinding class, this is designed to expose a WCF service as alegacy ASMX web service, so that old clients can work with new services. When used bythe client, this binding enables new WCF clients to work with old ASMX services.

    TCP binding

    Offered by the NetTcpBinding class, this uses TCP for cross-machine communication onthe intranet. It supports a variety of features, including reliability, transactions, andsecurity, and is optimized for WCF-to-WCF communication. As a result, it requires boththe client and the service to use WCF.

    Peer network binding

    Offered by the NetPeerTcpBinding class, this uses peer networking as a transport. The peer network-enabled client and services all subscribe to the same grid and broadcastmessages to it.

    IPC binding

  • 8/8/2019 Dot Net Questions 35

    17/23

    Offered by the NetNamedPipeBinding class, this uses named pipes as a transport for same-machine communication. It is the most secure binding since it cannot accept callsfrom outside the machine and it supports a variety of features similar to the TCP binding.7 :: What is endpoint in WCF?Every service must have Address that defines where the service resides, Contract that

    defines what the service does and a Binding that defines how to communicate with theservice. In WCF the relationship between Address, Contract and Binding is calledEndpoint.

    The Endpoint is the fusion of Address, Contract and Binding.8 :: How to define a service as REST based service in WCF?WCF 3.5 provides explicit support for RESTful communication using a new bindingnamed WebHttpBinding.The below code shows how to expose a RESTful service

    [ServiceContract]

    interface IStock

    {

    [OperationContract]

    [WebGet]

    int GetStock(string StockId);

    }

    By adding the WebGetAttribute, we can define a service as REST based service that can be accessible using HTTP GET operation.9 :: What is the address formats of the WCF transport schemas?Address format of WCF transport schema always follow

    [transport]://[machine or domain][:optional port] format.

    for example:

    HTTP Address Format

    http://localhost:8888the way to read the above url is

  • 8/8/2019 Dot Net Questions 35

    18/23

    "Using HTTP, go to the machine called localhost, where on port 8888 someone iswaiting"When the port number is not specified, the default port is 80.

    TCP Address Format

    net.tcp://localhost:8888/MyService

    When a port number is not specified, the default port is 808:

    net.tcp://localhost/MyService

    NOTE: Two HTTP and TCP addresses from the same host can share a port, even on thesame machine.

    IPC Address Format

    net.pipe://localhost/MyPipeWe can only open a named pipe once per machine, and therefore it is not possible for twonamed pipe addresses to share a pipe name on the same machine.

    MSMQ Address Formatnet.msmq://localhost/private/MyServicenet.msmq://localhost/MyService10 :: What is Proxy and how to generate proxy for WCF Services?The proxy is a CLR class that exposes a single CLR interface representing the servicecontract. The proxy provides the same operations as service's contract, but also hasadditional methods for managing the proxy life cycle and the connection to the service.The proxy completely encapsulates every aspect of the service: its location, itsimplementation technology and runtime platform, and the communication transport.

    The proxy can be generated using Visual Studio by right clicking Reference and clickingon Add Service Reference. This brings up the Add Service Reference dialog box, whereyou need to supply the base address of the service (or a base address and a MEX URI)and the namespace to contain the proxy.

    Proxy can also be generated by using SvcUtil.exe command-line utility. We need to provide SvcUtil with the HTTP-GET address or the metadata exchange endpoint addressand, optionally, with a proxy filename. The default proxy filename is output.cs but youcan also use the /out switch to indicate a different name.

    SvcUtil http://localhost/MyService/MyService.svc /out:Proxy.cs

    When we are hosting in IIS and selecting a port other than port 80 (such as port 88), wemust provide that port number as part of the base address:

  • 8/8/2019 Dot Net Questions 35

    19/23

    SvcUtil http://localhost:88/MyService/MyService.svc /out:Proxy.cs

    11 :: What are different elements of WCF Srevices Client configuration file?WCF Services client configuration file contains endpoint, address, binding and contract.A sample client config file looks like

    12 :: What is Transport and Message Reliability?Transport reliability (such as the one offered by TCP) offers point-to-point guaranteeddelivery at the network packet level, as well as guarantees the order of the packets.Transport reliability is not resilient to dropping network connections and a variety of other communication problems.

    Message reliability deals with reliability at the message level independent of how many packets are required to deliver the message. Message reliability provides for end-to-endguaranteed delivery and order of messages, regardless of how many intermediaries areinvolved, and how many network hops are required to deliver the message from the clientto the service.13 :: How to configure Reliability while communicating with WCF Services?Reliability can be configured in the client config file by adding reliableSession under

    binding tag.

  • 8/8/2019 Dot Net Questions 35

    20/23

    address = "net.tcp://localhost:8888/MyService"

    binding = "netTcpBinding"

    bindingConfiguration = "ReliableCommunication"

    contract = "IMyContract"

    />

    Reliability is supported by following bindings only

    NetTcpBindingWSHttpBindingWSFederationHttpBindingWSDualHttpBinding14 :: How to set the timeout property for the WCF Service client call?The timeout property can be set for the WCF Service client call using binding tag.

  • 8/8/2019 Dot Net Questions 35

    21/23

    binding = "wsHttpBinding"

    bindingConfiguration = "LongTimeout"

    ...

    />

    If no timeout has been specified, the default is considered as 1 minute.15 :: How to deal with operation overloading while exposing the WCF services?By default overload operations (methods) are not supported in WSDL based operation.However by using Name property of OperationContract attribute, we can deal withoperation overloading scenario.

    [ServiceContract]

    interface ICalculator

    {

    [OperationContract(Name = "AddInt")]

    int Add(int arg1,int arg2);

    [OperationContract(Name = "AddDouble")]

    double Add(double arg1,double arg2);

    }

  • 8/8/2019 Dot Net Questions 35

    22/23

    Notice that both method name in the above interface is same (Add), however the Name property of the OperationContract is different. In this case client proxy will have two

    methods with different name AddInt and AddDouble.

    LINQ

    1 :: What is LINQ?It stands for Language Integrated Query. LINQ is collection of standard query operatorsthat provides the query facilities into .NET framework language like C# , VB.NET.2 :: Why can not datareader by returned from a Web Services Method?Because, it is not serializable3 :: What is the extension of the file, when LINQ to SQL is used?The extension of the file is .dbml

    4 :: How LINQ is beneficial than Stored Procedures?There are couple of advantage of LINQ over stored procedures.

    1. Debugging - It is really very hard to debug the Stored procedure but as LINQ is partof .NET, you can use visual studio's debugger to debug the queries.

    2. Deployment - With stored procedures, we need to provide an additional script for stored procedures but with LINQ everything gets complied into single DLL hencedeployment becomes easy.

    3. Type Safety - LINQ is type safe, so queries errors are type checked at compile time. Itis really good to encounter an error when compiling rather than runtime exception!5 :: What is a Lambda expression?A Lambda expression is nothing but an Anonymous Function, can contain expressionsand statements. Lambda expressions can be used mostly to create delegates or expressiontree types. Lambda expression uses lambda operator => and read as 'goes to' operator.

    Left side of this operator specifies the input parameters and contains the expression or statement block at the right side.

    Example: myExp = myExp/10;

    Now, let see how we can assign the above to a delegate and create an expression tree:

    delegate int myDel(int intMyNum);static void Main(string[] args){//assign lambda expression to a delegate:myDel myDelegate = myExp => myExp / 10;

  • 8/8/2019 Dot Net Questions 35

    23/23

    int intRes = myDelegate(110);Console.WriteLine("Output {0}", intRes);Console.ReadLine();

    //Create an expression tree type

    //This needs System.Linq.ExpressionsExpression myExpDel = myExp => myExp /10;}

    No te:The => operator has the same precedence as assignment (=) and is right-associative.

    Lambdas are used in method-based LINQ queries as arguments to standard queryoperator methods such as Where.

    6 :: What is the LINQ file extension that interacts with Code Behind objects.

    its .dbml7 :: Why Select clause comes after from clause in LINQ?The reason is, LINQ is used with C# or other programming languages, which requires allthe variables to be declared first. From clause of LINQ query just defines the range or conditions to select records. So thats why from clause must appear before Select inLINQ.