P2Pprogrammer 2 programmer


Home > Interview Question and Answer > C# and VB.Net > Windows Service, COM+ and XML Web Services interview questions and answers

Interview questions and Answers for .NET Server Components, Windows Service, COM+ and XML Web Service


Interview questions and answers Server Components, Windows Service, COM+ and XML Web Services interview questions and answers

.NET Framework Server Componentes, Windows Services, COM+, XML Web Services, Service Application, Event Logs, Service Control manager, Windows DNA, EnterpriseServices, remoting boundaries, channels, remoting applications, XML Documents, XPathNavigator, XML Web service, Web configuration Advanced .NET Framework C#, VB.NET Interview Question and Answers for .NET Framework Version 2.0, 3.0, 3.5, 4.0, 4.5



Interview questions and answers for .NET Server Components, Windows Service, COM+ and XML Web Service


1. What are the states of a service application?

The states in which a service application can remain are running, paused, stopped, and pending.

2. What are the different types of Windows services?

Windows services are of two types: Win32OwnProcess and Win32ShareProcess services. Each Win32OwnProcess runs in its own process space, whereas Win32ShareProcess services share a process space with other services.

3. What are the tasks that you perform to create a Windows service?

These tasks are performed when creating a Windows service:

  1. Create a blank Windows service by using the Windows Service template for Visual Studio .NET.
  2. Change the default properties of the Windows Service template according to your requirements.
  3. Write code in the service application project to handle various events.
  4. Add installers to your service application.
  5. Install your service application by using the installation tools.

4. How do you add functionality to a service application?

To add functionality to a service application, you override the OnStart and OnStop methods of the ServiceBase class. You can also override the OnPause, OnContinue, and OnCustomCommand methods of the ServiceBase class to increase the functionality of a service application.

5. How do you log custom information in the default event logs?

To enable your service application to access the default event logs and write information in them, set the AutoLog property of a service application to False. You then use the WriteEntry method of the EventLog class log to write information in the default event logs.

6. Why do you need to include installers in your service application?

The installers enable you to install a Windows service and resources, such as custom logs and performance counters, that a service application uses on a computer. The installers automatically install these resources when you install a service application using the Installutil tool.

7. Why do you need to add instances of both the ServiceProcessInstaller and ?ServiceInstaller classes to install your service application?

A service application can contain more than one service. The methods of the ServiceProcessInstaller class perform the tasks that are common for all the services within a service application, such as writing entries in the system registry for all the services within the service application. The ServiceInstaller class performs tasks specific to a service, such as creating an entry for a service in the registry of a computer.

8. How do you specify the security context of a user account within which a service application runs?

You use the Account property of the ServiceProcessInstaller class to specify the security context for your service application. To specify the security context of a user account, set the Account property to User. You then need to specify the user name and password of a user account when you install the service application.

9. What administrative tasks can you perform on your service using the SCM?

You can perform the following administrative tasks using the SCM:

  1. Change the state of a service
  2. Specify how to start a service
  3. Specify the recovery actions in case of a service failure
  4. Specify a user account for a service
  5. View service dependencies

10. What are the steps to run custom commands on your service application?

The steps to run custom commands on your service application are

  1. Create a Windows application that you use to control your service application.
  2. Create a method that calls the ServiceController.ExecuteCommand method in the Windows application.
  3. Override the OnCustomCommand method in your service application to specify the tasks that you want your service application to perform.

11. What are the steps to attach a debugger to your service application?

The steps to attach a debugger to your service application are:

  1. Start your service application using the SCM.
  2. Choose Processes from the Debug menu.
  3. Select Show System Processes.
  4. Select the process for your service application and click Attach. The Attach To Process dialog box appears.
  5. Select Common Language Runtime, click OK to specify a debugger, and close the Attach To Process dialog box.

12. How is COM+ related to the DNA architecture?

Windows DNA provides the infrastructure and services that enable you to create and deploy applications based on the three-tier architecture. COM+ services, which are an integral part of Windows DNA, include services such as transactions, queued components (QC), security, loosely coupled events, JIT activation, and object pooling.

13. Briefly explain the use of the following COM+ services, JIT activation, Queued components, Object pooling

  1. Just-in-time activation. The Just-In-Time (JIT) Activation services of COM+ ensure that the client application has references to objects as long as they require them. As a result, the client application does not need to use the valuable memory resources of the server to save the object references.
  2. Queued components. The Queued Component service of COM+ is based on the Microsoft Message Queue Server (MSMQ) model that is a part of Windows 2000 and Windows XP. MSMQ is a middle-tier service that facilitates the asynchronous delivery of messages to named queues. The MSMQ system queues up the method calls and executes them automatically as and when the component is available. You can, therefore, use queued components to execute client methods even after the component is unavailable or offline, ensuring the continuous running of a distributed application.
  3. Object pooling. COM+ provides an automated service for configuring a component so that it can maintain ready-to-use and active object instances in a pool to process client requests. To configure and monitor the pool, you specify characteristics such as the pool size and the creation request time-out values. Next, the COM+ service is responsible for managing the pool and ensuring the activation and reuse of the pool objects according to the configured specifications.

14. What is a serviced component?

A serviced component is a class that derives from the System.Enterprise?Services.ServicedComponent class, which is the base class for all classes that use COM+ component services. You create and register each service component before it can access the COM+ services.

15. Which class do you need to define when creating serviced components?

To create a serviced component, you need to define a class that is derived directly from the ServicedComponent base class.

16. How do you assign a name and ID to a COM+ application?

The application ID serves as an index for all application searches made during the registration process. The application ID is assigned by using the ApplicationID attribute that is derived from the System.EnterpriseServices namespace.

17. What is the importance of the activation type attribute in the registration of a serviced component?

You use the activation type attribute to specify whether the created serviced component is created in the library of the caller process or in a new process of the server.

18. Which tool is used to add a strong name to an assembly?

You can use the Strong Name Tool (sn.exe) to create the file containing the public key information.

19. Which procedures can be used to register serviced components?

COM+ services use the following three types of registration for a serviced component:

  1. Manual registration
  2. Dynamic registration
  3. Programmatic registration

20. How do you configure a serviced component for implementation of role-based security at the interface level?

To assign roles to a component, method, or interface, complete the following steps:

  1. In the console tree of the Component Services tool, locate the COM+ application for which the role is defined.
  2. Expand the tree to view the components, interfaces, or methods of the application, depending on whom you are assigning the role.
  3. Right-click the item to which you want to assign the role and click Properties.
  4. In the properties dialog box, click the Security tab.
  5. In the Roles Explicitly Set For Selected Item(s) list box, select the roles that you want to assign to the item.
  6. Click OK.

21. What are the requirements to enable communication between objects across remoting boundaries?

To enable communication between objects across remoting boundaries, you need

  1. A server object that exposes the functionality to callers outside its boundary
  2. A client that makes calls to the server object
  3. A transportation mechanism to pass the calls from one end to the other

22. Describe the two types of remotable objects.

The two types of remotable objects are

  1. Marshal-by-value objects. These objects are copied and passed by value out of the application domain.
  2. Marshal-by-reference objects. The clients that use these objects need a proxy to access the object remotely

23. Describe the two types of activation modes of the .NET Remoting system.

The two types of activation modes in the .NET Remoting system are

  1. Server activation. In server activation, objects are created on the server when you call a method in the server class. However, objects are not created when you use the new keyword to create an instance of the server class.
  2. Client activation. In client activation, objects are created on the server when you create an instance using the new keyword.

24. How can you renew lifetime leases of objects?

You can renew the lifetime lease of an object in the following two ways:

  1. A client application calls the ILease.Renew method.
  2. A sponsor renews the lease.

25. What are channels?

Channels enable an application that is running in one application domain, process, or computer to send messages to an application running in a different application domain, process, or computer. In addition, channels allow applications to send and receive messages using protocols, such as TCP and HTTP.

26. List the tasks you need to perform to publish a service outside the service domain.

To publish a service outside the service domain, you need to:

  1. Identify the application domain that will host the service.
  2. Identify the activation model: server activation or client activation.
  3. Identify and create a channel and a port.
  4. Identify how the client application obtains the metadata information about the service.

27. Why do you use delegates in your remoting applications?

You use delegates to implement callback functions, event programming, and asynchronous programming in your remoting applications. Events use delegates to enable callback functions to the client in remoting applications. This enables the client and the remote application to function as domain servers. Therefore, you need to design a server/server application instead of designing a client/server application.

28. What steps do you perform to implement asynchronous programming in a remoting application?

The steps to implement asynchronous programming in a remoting application are:

  1. Create an instance of an object that can receive a remote call to a method.
  2. Wrap that instance method with an AsyncDelegate method.
  3. Wrap the remote method with another delegate.
  4. Call the BeginInvoke method on the second delegate, passing any arguments, the AsyncDelegate method, and some object to hold the state.
  5. Wait for the server object to call your callback method.

29. What information do you need to provide to the .NET Remoting system to configure remote objects?

You must provide the .NET Remoting system with the following information to configure remote objects:

  1. The activation type for the remote object
  2. The channels that the remote object will use to receive messages from clients
  3. The URL of the remote object
  4. The type metadata that describes the type of your remote object

30. Which method will you use to load the contents of an XML file into an ?XmlDocument object?

You need to use the Load method to load the contents of an XML file into an XmlDocument object. Alternatively, you can use the LoadXml method to load the XML data from a string format into the XmlDocument object.

31. Which method will you use to write the contents of the XmlDocument object into an XML file?

You need to use the Save method of the XmlDocument class to write the contents of the XmlDocument object into an XML file.

32. How do you read the contents of an XML document using XmlTextReader?

You need to perform the following tasks to read the contents of an XML document using XmlTextReader:

  1. Create an object of the XmlTextReader class.
  2. Call the Read() method on the reader object until all the data is read.
  3. While reading the data from the XML document, check the type of the data being read using the XmlTextReader.NodeType property.

33. Which class do you use to write data to an XML file?

You use the XmlTextWriter class to write to an XML file. The XmlTextWriter class provides methods such as WriteStartDocument, WriteStart?Element, WriteAttributeString, WriteEndElement, and WriteEndAttribute, which you use to write data in a well-formed XML document.

34. How does XPathNavigator read data from an XML document?

The XPathNavigator object reads data from an XML document by using a cursor that enables forward and backward navigation within the nodes. XPathNavigator enables you to randomly access any node in an XML document. However, the XPathNavigator cursor is read-only; therefore, you cannot edit an XML document with XPathNavigator.

35. Which methods of the XPathNavigator class do you use to navigate within the nodes selected from an XML document?

You can use the MoveTo, MoveToNext, MoveToPrevious, MoveToFirst, MoveToFirstChild, MoveToParent, MoveToRoot, and MoveToId methods to navigate within the nodes selected from an XML document.

36. What objects are used to create the structure of an XML document within a schema?

The simpleType and complexType elements are used to specify the structure of the XML document in the XSD schema file.

37. Which event is raised for validating the semantics of the XML Schema?

The XmlValidatingReader.ValidationEventHandler event for the ?Compile method is raised for semantic validation checking of the XML Schema.

38. How can you ensure your XML document is valid?

You can ensure the validity of XML documents by using the Xml?Validating?Reader class. The XmlValidatingReader class provides DTD, XDR, and XSD schema validation services. The XmlValidatingReader class takes XmlTextReader as input. XmlValidatingReader applies the property that you specify in XmlTextReader

39. How can you read fragments of an XML document?

You can use XmlValidatingReader to read XML fragments. Xml?ValidatingReader parses a given string as a fragment of XML. This enables you to bypass the root-level rules of an XML document. The value you pass to the XmlNodeType parameter of XmlValidatingReader determines how to parse an XML string.

40. Which method enables you to retrieve the XSD schema for the XML representation of the data stored in the DataSet?

The GetXmlSchema method enables you to retrieve the XSD schema for the XML representation of the data stored in the DataSet.

41. Which method of the DataSet class enables you to write the contents of a DataSet into an XML file?

The WriteXml method of the DataSet class enables you to write the contents of a DataSet into an XML file.

42. What is an XML Web service?

XML Web services are program components that allow you to build scalable, loosely coupled, platform-independent applications. XML Web services enable disparate applications to exchange messages using standard protocols such as HTTP, XML, XSD, SOAP, and Web Services Description Language (WSDL).

43. What are the components of the XML Web service infrastructure?

The components of the XML Web service infrastructure include XML Web services directories, XML Web services discovery, XML Web services description, and XML Web service wire formats.

44. What are the steps to deploy a Web service?

Follow these steps to deploy a Web service:

  1. Copy the files for your XML Web service application to the ?Inetpub\Wwwroot folder.
  2. Open Internet Services Manager from the Administrative Tools folder.
  3. Expand the Default Web Site node.
  4. Right-click the Web service folder you copied to the Inetpub\Wwwroot folder to open its properties dialog box.
  5. Click Create in the properties dialog box to configure the virtual folder as the root of your Web application.

45. What are the components that are published when you deploy a Web service?

The components that are published when you deploy a Web service are

  1. The Web application directory
  2. The <WebService>.asmx file
  3. The <WebService>.disco file
  4. The Web.config file
  5. The \Bin directory

46. What does the .disco file contain?

A .disco file contains links to other resources that describe your XML Web service and enables clients to discover an XML Web service. The discovery document contains information regarding other XML Web services that reside on the same or a different Web server.

47. What are the steps to configure discovery information for an XML Web service

To configure discovery information for an XML Web service, perform the following tasks:

  1. Create an XML document and insert the <?xml version="1.0" ?> tag in the first line.
  2. Add a <discovery> element.
  3. Add references to service descriptions, XSD schemas, and other discovery documents within the <discovery> element.
  4. Deploy the discovery document to a Web server.

48. What tasks do you need to perform to consume a Web service in a client application?

To consume a Web service from a client application, you need to perform the following tasks:

  1. Add a Web reference to the XML Web service in the client application by discovering the XML Web service you want to consume.
  2. Generate a proxy class for the XML Web service.
  3. Create an object of the XML Web service proxy class in the client application.
  4. Access the XML Web service by using the proxy object.

49. Which attribute is used to create a Web method?

In C# you use the [WebMethod] attribute to declare a Web method that exposes the functionality of the XML Web service. In Visual Basic .NET, you use the <WebMethod> attribute to create a Web method.

50. Which file contains configuration information, such as debug mode?

The Web.config file contains configuration information, such as the debug mode and the authentication mode for a Web project. It also includes information about whether to display custom errors for a Web project.

51. Which file allows you to handle application-level events?

The Global.asax file enables you to manage application-level events. This file resides in the root directory of an ASP.NET Web application or ASP.NET Web service. The Global.asax.cs or Global.asax.vb class file is a hidden, dependent file of Global.asax, which contains the code for handling application events such as the Application_OnError event.

52. Which property of the WebMethod attribute allows you to maintain the state of objects across sessions in a Web method?

The EnableSession property of the WebMethod attribute allows you to enable session state for a Web method.

53. What steps do you need to perform to enable transactions in a Web method?

To enable transactions in a Web method, you need to perform the following steps:

  1. Add a reference to the System.EnterpriseServices.dll by using the Solution Explorer.
  2. Include the System.EnterpriseServices namespace in the XML Web service project.
  3. Set the TransactionOption property to an appropriate value.

54. When should you use asynchronous programming?

You should use asynchronous programming when your application calls a method on an object that takes significant time to execute and you do not want the program to wait for the method to return.

55. Explain how you implement asynchronous programming using callbacks.

A client calls the Begin method on the server object and passes a reference to the callback method. When the asynchronous method finishes execution, the server object calls the callback method on the client object. The callback method in turn calls the End method on the server object. The End method returns a value to the client.

56. Which method do you call for the first time when you access an XML Web ?service or service method with which the SOAP extension is configured to ?execute?

You call the GetInitializer method the first time when you access an XML Web service or service method with which the SOAP extension is configured to execute.

57. What are the different properties of the <add> XML element?

Type, Priority, and Group are the three properties of the XML element. The Type property of the element represents the type of SOAP extension. The Priority property represents the relative priority of the SOAP extension within a group. The Group property represents the group name to which the SOAP extension belongs.

58. Which element in the Web.config file do you use to manage custom error messages

You use the <customErrors> element to manage custom error messages. You can set the <customErrors> mode attribute to On or RemoteOnly to enable custom error messages, and Off to disable the error messages.

59. How can you ensure that only authorized users access your Web service?

You can use the <authorization> element to specify the users and roles that can access your Web service. This element enables you to implement both positive and negative authorization assertions. You can use this element to allow or deny access to your Web service based on specific users or roles.

More C# and VB.Net Interview Question and Answers

  1. .NET Framework interview questions and answers
  2. VB.NET and C# User Interface interview questions and answers
  3. .NET Object-Oriented Programming (OOPs) interview questions and answers
  4. ADO.NET interview questions and answers
  5. Advanced .NET Framework Topics interview questions and answers
  6. Windows Service, COM+ and XML Web Services interview questions and answers
  7. .NET Assemblies, Configuration, and Security interview questions and answers
  8. VB.NET and C# setup and deployment interview questions and answers
  9. VB.NET and C# general interview questions and answers


Home > Interview Question and Answer > C# and VB.Net > .NET Framework