Exam Prep Questions

Team-Fly    

Developing XML Web Services and Server Components with Visual C#™ .NET and the .NET Framework, Exam Cram™ 2 (Exam 70-320)
By Amit Kalani, Priti Kalani

Table of Contents
Chapter 8.  Component Services


Question 1

You have been given an assignment to develop the order-processing application for your organization. The application needs to support a large number of users and should perform well between 8:00 a.m. and noon, which is the peak time for receiving and processing orders. Which of the following COM+ services would you use in your application? (Select all that apply.)

  • A. Queued components

  • B. Automatic transactions

  • C. Object pooling

  • D. Just-in-time activation

A1:

Answers C and D are correct. For achieving maximum performance, you can use COM+ object pooling and just-in-time activation services. Answer A is not correct because queued components are useful only for asynchronous processing of messages. Answer B is incorrect because automatic transactions are useful only for increasing the reliability of an application.

Question 2

You create a serviced component named OrderProcess. This component updates several SQL Server databases to complete a customer's order. The OrderProcess class includes the following code:

 [Transaction(TransactionOption.Required)] public class OrderProcess : ServicedComponent {    public void PlaceOrder(OrderInfo o)    {       // code to update various databases    } } 

You must ensure the reliability of the PlaceOrder() method. The PlaceOrder() method should update either all or none of the databases. What should you do?

  • A. Add the following attribute to the OrderProcess class:

     [JustInTimeActivation(false)] 
  • B. Add the following attribute to the PlaceOrder() method:

     [AutoComplete()] 
  • C. Add the following line of code at the end of the PlaceOrder() method:

     ContextUtil.EnableCommit(); 
  • D. Add the following line of code at the end of the PlaceOrder() method:

     ContextUtil.SetComplete(); 
A2:

Answer B is correct. When you use the AutoComplete attribute with a method, COM+ intercepts the method call to set the done bit and the consistent bit after the method call returns. If there are no errors in the method call, the consistent bit is set to true; otherwise, the consistent bit is set to false. This setting ensures that the changes to the database are committed or rolled backed reliably. Answer A is incorrect because the JustInTimeActivation attribute must be set to true for automatic transactions to correctly work. Answers C and D are incorrect because both the ContextUtil.EnableCommit() and ContextUtil.SetComplete() methods instruct the COM+ context to vote for always committing the current transaction.

Question 3

You are developing a distributed order-processing application for your company. The sales associates receive orders over the telephone. The orders are entered in the ordering system through a Windows form application. The Windows form application calls a set of serviced components to accomplish tasks. You must continue to receive orders even if one or more order-processing components fail. Which of the following COM+ services should you use in the serviced components to ensure high availability of the system?

  • A. Queued components

  • B. Automatic transactions

  • C. Object pooling

  • D. Just-in-time activation

A3:

Answer A is correct. To ensure high availability of the components, you should use the COM+ queued component service. Answers B, C, and D are incorrect because these services require an object to be directly available for invoking the methods.

Question 4

You are creating a serviced component that will be called from both managed and unmanaged client applications. You use a class library project to write the business logic and then compile the project into a strongly named assembly. As a next step, you want to register the assembly in the COM+ catalog. You want to detect and correct any registration errors before any client applications use the component. Which of the following tools should you use to register the assembly?

  • A. Use the Assembly Registration tool (regasm.exe) to create entries in the Registry that describe the assembly.

  • B. Use the Type Library Exporter (tlbexp.exe) to export the definition for the assembly.

  • C. Use the Global Assembly Cache tool (gacutil.exe) to add the component to the Global Assembly Cache.

  • D. Use the .NET Services Installation tool (regsvcs.exe) to add the component to the COM+ Catalog.

A4:

Answer D is correct. Among the given options, the only tool that actually registers a strongly named assembly with the COM+ catalog is the .NET Services Installation tool (regsvcs.exe). Answer A is incorrect because regasm.exe is used to make the .NET classes accessible to COM clients. Answer B is incorrect because tlbimp.exe is used to convert the type definitions found within a COM type library into equivalent definitions in a .NET assembly. Answer C is incorrect because gacutil.exe manipulates only the Global Assembly Cache.

Question 5

You create a queued component named OrderProcess. This component receives orders from the client applications in an asynchronous fashion. The OrderProcess class includes the following code:

 namespace Exam70320 {    public interface IOrderProcess    {      bool PlaceOrder(OrderInfo o);    }   [Transaction(TransactionOption.Required)]    [InterfaceQueuing(Enabled=true,             Interface="IOrderProcess")]    public class OrderProcess :       ServicedComponent, IOrderProcess    {       public bool PlaceOrder(OrderInfo o)       {         // code to update various databases       }    } } 

You get no compilation errors, but when you register this component using the .NET Services Installation tool (regsvcs.exe), you get an error message "Queuing not supported on interface 'IorderProcess.'" What should you do to resolve this error?

  • A. Apply the following attribute to the class:

     [ApplicationQueuing( Enabled=true, QueueListenerEnabled=true)] 
  • B. Apply the InterfaceQueuing attribute on the IOrderProcess interface rather than on the OrderProcess class.

  • C. Change the interface definition as follows and then change OrderProcess to implement this interface:

     public interface IOrderProcess {    void PlaceOrder(OrderInfo o); } 
  • D. Apply the AutoComplete attribute on the OrderProcess class.

A5:

Answer C is correct. The interface that a queued component uses for queuing must have void methods having only pass-by-value parameters. Therefore, you need to change the return type of the PlaceOrder() method from bool to void. Answer A is incorrect because the ApplicationQueuing attribute is applied at the assembly level instead of the class level. Answer B is incorrect because the InterfaceQueuing attribute is applied to the class level instead of the interface level. Answer D is incorrect because, if needed, the AutoComplete attribute can be applied to a queued component without any errors.

Question 6

You create a serviced component that will be used by only the .NET client programs. You want to use the COM+ object creation service from the serviced component. Which of the following steps must you take for the programs to use the serviced component? (Select all that apply.)

  • A. Register the component in the Windows Registry.

  • B. Install the component in the Global Assembly Cache.

  • C. Sign the component with a strong name.

  • D. Register the component in the COM+ catalog.

A6:

Answers C and D are correct. You must at least sign the component with a strong name and then register the component in the COM+ catalog. Answer A is incorrect because the component must be available to COM+, and just registering the component with the Windows Registry is not sufficient. Answer B is incorrect because installing the component in the Global Assembly Cache is not required as long as you make sure that the process can locate the assembly.

Question 7

You are developing a serviced component that several client applications will use. Some client applications are COM-based, whereas the other client applications run on the .NET Framework. In the future, you plan to release new versions of your serviced component, but you do not want to recompile the client applications. How should you design the interfaces for such a serviced component?

  • A. Define an interface and then use that interface to implement the serviced component. On the serviced component, set the following attribute:

     [ClassInterface(ClassInterfaceType.None)] 
  • B. Set the following attribute on the serviced component:

     [ClassInterface(ClassInterfaceType.AutoDual)] 
  • C. Define an interface and then use that interface to implement the serviced component. Set the following attribute on the serviced component:

     [ClassInterface(ClassInterfaceType.AutoDual)] 
  • D. Set the following attribute on the serviced component:

     [ClassInterface(ClassInterfaceType.AutoDispatch)] 
A7:

Answer A is correct. ClassInterfaceType.None is the recommended setting for the ClassInterface attribute. Answers B and C are incorrect because ClassInterfaceType.AutoDual causes versioning problems. Answer D is incorrect because ClassInterfaceType.AutoDispatch supports only late binding and does not allow configuration of methods through the Component Services administrative tool.

Question 8

You have created a business object in Visual C# .NET. You want the business object to be used by COM clients as well as .NET clients. You want to deploy the business object on the client computers in such a way that the client can take advantage of late binding as well as early binding with the interfaces exposed by the business object. Which of the following methods would you use to accomplish this?

  • A. Use Visual Studio .NET, open the project's property pages, and change the Register for the COM Interop option to true.

  • B. Use the Assembly Registration tool (regasm.exe) with its /tlb option.

  • C. Use the Type Library Exporter tool (tlbexp.exe) that ships as a part of the .NET Framework SDK.

  • D. Use the ConvertAssemblyToTypeLib() method of the TypeLibConverter class in the System.Runtime.InteropServices namespace.

A8:

Answer B is correct. When used with the /tlb option, regasm.exe registers the assembly in the Registry (for late binding) and creates a CCW in a tlb file, which can be used by the client programs at the time of compilation (early binding). Answers A and C are incorrect because these options supports only early binding. Answer D is incorrect because this option is useful only for late binding.

Question 9

You create a serviced component named OrderProcess. This component receives orders from the client applications in an asynchronous fashion. The OrderProcess class includes the following code:

 namespace Exam70320 {    public interface IOrderProcess    {      void PlaceOrder(OrderInfo o);    }   [Transaction(TransactionOption.Required)]    [InterfaceQueuing(Enabled=true,             Interface="IOrdering")]    public class OrderProcess :       ServicedComponent,  IOrderProcess    {       public void PlaceOrder(OrderInfo o)       {         // code to update various databases       }    } } 

You need to write code for a client program that uses the OrderProcess component to place an order. Which code segment should you use?

  • A.

     IOrderProcess order = new IOrderProcess(); Order.PlaceOrder(orderInfo); 
  • B.

     IOrderProcess order; order = (IOrderProcess) Activator.GetObject         (typeof(IOrderProcess),     @"queued:/new:Exam70320.OrderProcess"); order.PlaceOrder(orderInfo); 
  • C.

     IOrderProcess order; order = (IOrderProcess) Marshal.BindToMoniker     (@"queue:/new:Exam70320.OrderProcess"); order.PlaceOrder(orderInfo); 
  • D.

     IOrderProcess order; order = (IOrderProcess) Assembly.CreateInstance     (@"queue:/new:Exam70320.OrderProcess"); order.PlaceOrder(orderInfo); 
A9:

Answer C is correct. You use the Marshal.BindToMoniker() method to record messages for a queued component. Answers A, B, and D are incorrect because, with a queued component, your objective is not to create an instance of an object; instead, you need a way in which you can record the message for the client and place it in the queue for later retrieval.

Question 10

You have written the following code for a serviced component:

 namespace Exam70320 {    public interface IOrderProcess    {      bool PlaceOrder(OrderInfo o);    }    [JustInTimeActivation(true)]    [Transaction(TransactionOption.Required)]    public class OrderProcess : ServicedComponent,                 IOrderProcess    {       public bool PlaceOrder(OrderInfo o)       {         // code to update various databases       }    } } 

In the PlaceOrder() method, you decide whether all the databases have been updated correctly. If they have, you commit the transaction and deactivate the current OrderProcess object. Which of the following methods should you use in the PlaceOrder() method to accomplish this requirement?

  • A. DisableCommit()

  • B. EnableCommit()

  • C. SetAbort()

  • D. SetComplete()

A10:

Answer D is correct. You should use the SetComplete() method because it sets the consistent bit as well as the done bit to true. Answer B is incorrect because using the EnableCommit() method sets the consistent bit to true but also sets the done bit to false, which does not deactivate the object after the method call returns. Answers A and C are incorrect because the DisableCommit() and SetAbort() methods always vote for aborting the current transaction.


    Team-Fly    
    Top


    MCAD Developing XML Web Services and Server Components with Visual C#. NET and the. NET Framework Exam Cram 2 (Exam Cram 70-320)
    Managing Globally with Information Technology
    ISBN: 789728974
    EAN: 2147483647
    Year: 2002
    Pages: 179

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net