70-310 - Developing XML Web Services and Server Components with Visual Basic .NET

1. Contoso buys and sells used refrigerators. External vendors frequently send you
XML documents that
list one type of used appliances for sale. The documents that you receive contain
either only washers or
only refrigerators as in the following example.<BR>
&lt;!-&gt;<BR>
&lt;saleList&gt;<BR>
&nbsp;&nbsp;&lt;refrigerators&gt;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;refrigerator type=freezer on bottom , price=210/&gt;<BR>
&nbsp;&nbsp;&lt;/refrigerators&gt;<BR>
&lt;/saleList&gt;<BR>
&lt;!-&gt;<BR>
&lt;saleList&gt;<BR>
&nbsp;&nbsp;&lt;washers&gt;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;washer type=front load , price=145/&gt;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;washer type=top load , price=130/&gt;<BR>
&nbsp;&nbsp;&lt;/washers&gt;<BR>
&lt;/saleList&gt;<BR><BR>
All incoming XML documents are loaded into a MemorySystem object named
usedList.
You need to automate a process that will discover XML documents contain
refrigerator elements. As
soon as you ascertain that a document contains refrigerators, you can stop
processing the document.
You decide to use Visual studio .NET to develop an application that will contain a
Boolean variable
named hasRefrigerator. A value of True for this variable means that a document
contains refrigerator
elements. A value of false means that it does not. You want to ensure that the
discovery process occurs as
quickly as possible.
What should you do?
A. Create an XmlDocument object and load it from usedList.
Use the SelectSingleNode method to search the XmlDocument object for the
saleList/refrigerators
node.
If this node is found, set hasRefrigerator to True.
Otherwise, set hasRefrigerator to False.
B. Create an XmlXPathDocument object and load it from usedList.
Use an XPathNavigator object to search the XmlXPathDocument for the
saleList/refrigerators node.
If this node is found, set hasRefrigerator to True.
Otherwise, set hasRefrigerator to False.
C. Create an XmlTextReader object on usedList.
Loop through usedList by using the MoveToContent method of the XmlTextReader
object and
comparing for the saleList/refrigerators node.
If this node is found, set hasRefrigerator to True.
Otherwise, set hasRefrigerator to False.
D. Create a DataSet object and use its ReadXml method to load usedList into the object.
If the Count property of the Rows collection of the refrigerators entry in the object is
not equal to
zero, set hasRefrigerator to True.
Otherwise, set hasRefrigerator to False.

Answer: A

The SelectSingleNode method selects the first XmlNode that matches the
XPath expression. If no
nodes match the query, it returns Null. This suggested procedure would meet the
requirements of this scenario.
Furthermore, this would be the fastest solution.
Note: An XMLDocument object represents an XML document and enables the
navigation and editing of this
document.
Reference: .NET Framework Class Library, XmlNode.SelectSingleNode Method [Visual
Basic]
Incorrect Answers
B: There is no such thing as a XmlXPathDocument.
C: XmlReader provides forward-only, read-only access to a stream of XML data. The
MoveToContent method
can be used on a XmlReader stream to provide a possible solution in this scenario.
However, it would be
fastest solution.
Note: The MoveToContent method checks whether the current node is a content (nonwhite
space text,
CDATA, Element, EndElement, EntityReference, or EndEntity) node. If the node is not a
content node, the
reader skips ahead to the next content node or end of file.
D: This proposed solution is not straightforward, and is therefore slow.

2. You create an XML web service that retrieves data from Microsoft SQL Server
database. You instantiate
a SqlConnection object named TestKConnection and set the Max Pool Size property
of the
connectionString to 50.
All 50 connections are now in use. However, a request for connection number 51 is
received.
What is the most likely result?
A. An exception is immediately thrown.
B. The current connection pool is expanded by 50 additional connections.
C. A new connection pool is created that has the same maximum number of connections.
D. The request is queued until a connection becomes available or until the timeout limit is
reached.

Answer: D

The Max Pool Size property denotes the maximum number of connections
allowed in the pool. If
the maximum pool size has been reached and no usable connection is available, the
request is queued. The
object pooler satisfies these requests by reallocating connections as they are released back
into the pool. If the
time-out period elapses before a connection object can be obtained, an error occurs.
Reference: .NET Framework Developer's Guide, Connection Pooling for the SQL Server
.NET Data Provider
Incorrect Answers
A: An exception is only thrown after the request has been queued and after the timeout
limit is reached.
B: The maximum number of concurrent connections has been reached. No further
connections would be
allowed at the moment.
C: No new connection pool is created.

3.You have a strongly types DataSet object named ContosoDataSet. This object
contains three DataTable
objects named Customers, Orders and OrderDetails.
Customers and Orders have a data column named CustomerID. Orders and
OrderDetails have a data
column named OrderID.
Orders have a foreign key constraint between Customers and Orders on
CustomerID. OrderDetails has a
foreign key constraint between Orders and OrderDetails on OrderID.
You want to populate Customers, Orders and OrderDetails with data from
Microsoft SQL Server
database.
In which order should you fill the Data table objects?
A. Customers
OrderDetails
Orders
B. OrderDetails
Orders
Customers
C. Customers
Orders
OrderDetails
D. Orders
OrderDetails
Customers

Answer: C

We most populate the tables that are references by the foreign-key
constraints first, namely the
Customers and the Orders table. We should populate the OrderDetails table last.
Incorrect Answers
A B: There would be no corresponds rows in the Orders table if we populate the
OrderDetails table before the
Orders table.
D: There would be no corresponds rows in the Customers table if we populate the
OrderDetails table before the
Customers table.

4.Your Microsoft SQL Server 6.5 database contains a table named ContosoPurchases
that consists of
more than 1 million rows.
You are developing an application to populate a DataReader object with data from
ContosoPurchases.
You want to ensure that the application processes the data as quickly as possible.
You create a SQL SELECT statement in a local variable named tkSQLSelect. You
need to initiate a
SqlConnection object and a SqlCommand object you will use to populate the
DataReader object.
Which code segment should you use?
A. Dim myConnection As New OleDbConnection(myOleDbConnectionString)<BR>
Dim tkCommand As New OleDbCommand(tkSQLSelect)
B. Dim myConnection As New OleDbConnection(myOleDbConnectionString)<BR>
Dim tkCommand As New OleDbCommand(tkSQLSelect, myConnection)
C. Dim myConnection As New SqlConnection(mySqlConnectionString)<BR>
Dim tkCommand As New SqlCommand(tkSQLSelect)
D. Dim myConnection As New SqlConnection(mySqlConnectionString)<BR>
Dim tkCommand As New SqlCommand(tkSQLSelect, myConnection)

Answer: B

For Microsoft SQL Server version 6.5 and earlier, you must use the OLE
DB Provider for SQL
Server. Furthermore, we specify both the CommandText and the OleDBConnection
properties of the
OleDBCommand.
Reference:
.NET Framework Developer's Guide, .NET Data Providers [Visual Basic]
.NET Framework Class Library, OleDbCommand Members
Incorrect Answers
A: We create the OleDbCommand we must specify the OleDBConnection, not just the
CommandText.
C, D: Only SQL Server 7.0, SQL Server 2000 or later can use SqlConnection.

5.Your Microsoft SQL Server database has a stored procedure named
GetContosoCustomer.
getContosoCustomer accepts one parameter named @CustomerID and returns the
appropriate
company name.
You initiate a SqlCommand object named myCommand. You need to initialize
myCommand to return
the company name for @CustomerID with a value of ALFKI.
Which code segment should you use?
A. myCommand.CommandText = ContosoCustomer, ALFKI<BR>
myCommand.Parameters.Add (@CustomerID)
B. myCommand.CommandText = ContosoCustomer<BR>
myCommand.Parameters.Add (ContosoCustomer, ALFKI)
C. myCommand.CommandText = @CustomerID<BR>
myCommand.Parameters.Add (ContosoCustomer, ALFKI)
D. myCommand.CommandText = ContosoCustomer<BR>
myCommand.Parameters.Add (@CustomerID, ALFKI)

Answer: D

The SqlCommand.CommandText Property gets or sets the SQL statement
or stored procedure to
execute at the data source. Here we should set it to the name of the stored procedure:
ContosoCustomer.
The Parameter should contain ParameterName (here @CustomerID) and the Value (here
the string ALFKI).
Note: A SqlCommand object represents a Transact-SQL statement or stored procedure to
execute against a
SQL Server database.
Reference:
.NET Framework Class Library, SqlCommand.CommandText Property [Visual Basic]
.NET Framework Class Library, SqlParameter Members
Incorrect Answers
A, C: The CommandText should be set to the named of the stored procedure. We should
not specify any
parameters in the CommandText.
B: The name of the parameter, not the name of the stored procedure, should be included
in the parameter.

6.You have a DataSet object named myDataSet. This object contains two DataTable
objects named
Customers and Orders. Customers has a column named CustomerID, which is
unique to each customer.
Orders also has a column named CustomerID. You want to use the GetChildRows
method of the
DataRow object to get all orders for the current customers.
What should you do?
A. Add a foreign key constraint on CustomerID of Orders between Customers and
Orders.
B. Add a data relation to myDataSet on OrderID between Customers and Orders.
C. Create a unique constraint on CustomerID of Customers.
D. Create a primary key on CustomerID of Customers.

Answer: B

The GetChildRows Method use a DataRelation to retrieve the child rows
of this DataRow using
the specified DataRelation. In this scenario we would be required to add a data relation
between the two tables.
Note: A Datarelation represents a parent/child relationship between two DataTable
objects.
Reference:
.NET Framework Class Library, DataRow.GetChildRows Method (DataRelation) [Visual
Basic]
.NET Framework Class Library, DataRelation Class [Visual Basic]
Visual Database Tools, Foreign Key Constraints
Incorrect Answers
A: A foreign key constraint works in conjunction with primary key or unique constraints
to enforce referential
integrity among specified tables. However, the GetChildRows method uses a
DataRelation, not a foreign
key constraint.
C: A unique constraint on CustomerID of Customers would only make sure that the
CustomerID column will
have unique values.
D: A primary key constraint would ensure that CustomerID column will have unique
values.

7.You are developing an application that queries a table named Products in a
Microsoft SQL Server
database. The query will be stored in a string variable named TKQuery. The query
includes the
following SQL code.
SELECT * FROM Products For XML AUTO
You must iterate the query results and populate an HTML table with product
information.
You must ensure that your application processes the results as quickly as possible.
What should you do?
A. Use a SqlDataAdapter object and set its SelectCommand property to TKQuery.
Use the Fill method of the SqlDataAdapter object to read the data into a DataSet object.
Loop through the associated rows to read the data.
B. Use a SqlDataAdapter object and set its SelectCommand property to TKQuery.
Use the Fill method of the SqlDataAdapter object to read the data into a DataSet object.
Use the ReadXml method of the DataSet object to read the data.
C. Set the SqlCommand objects Command Text to TKQuery.
Use the ExecuteReader method of the SqlCommand object to create a SqlDataReader
object.
Use the Read method of the SqlDataReader object to read the data.
D. Set the SqlCommand objects Command Text to TKQuery.
Use the ExecuteXmlReader method of the SqlCommand object to create a XmlReader
object.
Use the XmlReader object to read the data.

Answer: D

You can execute SQL queries against existing relational databases to
return results as XML
documents rather than as standard rowsets. To retrieve results directly, use the FOR XML
clause of the
SELECT statement like in this scenario.
XmlReader provides non-cached, forward-only, read-only access.to an XML data source,
such as the XML
produces by the T-SQL statement of this scenario.
Reference:
SQL Server 2000 Books Online, Retrieving XML Documents Using FOR XML
.NET Framework Developer's Guide, Reading XML with the XmlReader
Incorrect Answers
A: We must take since the data is in XML format. Furthermore, a Dataset is not required.
B: DataSet.ReadXml method reads XML data into the DataSet. However, it is not
necessary to use a dataset.
Reading the data into a Dateset brings an unnecessary overhead.
C: The SQLDateReader provides a means of reading a forward-only stream of rows from
a SQL Server
database. However, it operates on relational data not on XML data.

8.You use a function to maintain a table named Categories in a Microsoft SQL Server
database. The
function creates a DataTable object named Categories in a DataSet object named
categoriesDataSet.
These two objects capture all insertions, updates and deletions to the Categories
table.
The function instantiates a SqlDataAdapter object named TKDataAdapter. This
object is configured to
select, insert, update and delete rows in the Categories DataTable object.
You need to update the database to include the changes in the Categories DataTable
object and capture
all data errors in a batch after all rows have been processed.
Which code segment should you use?
A. Try<BR>
TKDataAdapter.Update (CategoriesDataSet, Categories)<BR>
Catch mySqlException as SqlException<BR>
Dim myDataRow( ) As DataRow = _<BR>
CategoriesDataSet.Tables (0).GetErrors ( )
End Try<BR>
 Code to process errors goes here.
B. TKDataAdapter.ContinueUpdateOnError = True<BR>
Try<BR>
TKDataAdapter.Update (CategoriesDataSet, Categories)<BR>
Catch mySqlException as SqlException<BR>
Dim myDataRow( ) As DataRow = _<BR>
CategoriesDataSet.Tables (0) .GetErrors ( )<BR>
End Try<BR>
 Code to process errors goes here.
C. TKDataAdapter.Update (CategoriesDataSet, Categories)<BR>
If categoriesDataSet.Tables(0).HasErrors Then<BR>
Dim myDataRow ( ) As DataRow = _<BR>
CategoriesDataSet.Tables(0).GetErrors ( )<BR>
 Code to process errors goes here.<BR>
End If
D. TKDataAdapter.ContinueUpdateOnError = True<BR>
TKDataAdapter.Update (CategoriesDataSet, Categories)<BR>
If categoriesDataSet.Tables (0).HasErrors Then<BR>
Dim myDataRow ( ) As DataRow = _<BR>
CategoriesDataSet.Tables(0).GetErrors ( )<BR>
 Code to process errors goes here.<BR>
End If

Answer: D


Line 1: TKDataAdapter.ContinueUpdateOnError = True
The DataAdapter.ContinueUpdateOnError property gets or sets a value that specifies
whether to generate an
exception, or the row in error when an error is encountered during a row update. The
value true is used to
continue the update without generating an exception.. The default is false. In this scenario
the value of this
property must be true. We dont want exceptions.
Line 2: TKDataAdapter.Update (CategoriesDataSet, Categories)
We update the database. All updated rows in the Dataset are updated in the database as
well.
Line 3: If categoriesDataSet.Tables (0).HasErrors Then
We check if there exist any errors in the dataset with the HasErrors method.
Line 4, 5, 6: We collect the rows with errors with the GetErrors method.
Reference: .NET Framework Class Library, DataAdapter.ContinueUpdateOnError
Property [Visual Basic]
Incorrect Answers
A, B: We dont want the errors that occur while processing rows to not generate
exceptions. Instead we want
to collect the rows where errors occurred. The Try.Catch construct is useless here.
C: By default an error to update, insert or delete a row causes an exception. We must set
the DataAdapter
property ContinueUpdateOnError to True.

9.Your company frequently receives product information from external vendors in
the form of XML data.
You receive XML document files, an .xdr schema file, and an .xsd schema file.
You need to write code that will create a typed DataSet object on the basis of
product information. Your
code will be used in several Visual studio .NET applications to speed up data
processing.
You need to create this code as quickly as possible.
What should you do?
A. Create the code manually.
B. Use XmlSerializer.Serialize to generate the code.
C. Use the XmlSerializer.Deserialize to generate the code.
D. Use the Xml Schema Definition tool (Xsd.exe) to generate the code.

Answer: D

 The XML Schema Definition tool generates XML schema or common
language runtime classes
from XDR, XML, and XSD files, or from classes in a runtime assembly. The code would
be produced quickly.
Reference: .NET Framework Tools, XML Schema Definition Tool (Xsd.exe)
.NET Framework Class Library, XmlSerializer Class [Visual Basic]
Incorrect Answers
A: Manually creating code would be tedious.
B: The XmlSerializer.Serialize is used to produce XML documents from objects. It is the
wrong way around.
C: At run time XML documents can be deserialized into run time objects with the
XmlSerializer.Deserialize
method. However, we would have to manually produce this code.

10.You create a DataSet object named ContosoProductsDataset that contains product
information from a
Microsoft SQL Server database. This object has a primary key on a column named
ProductID.
You want to create a new DataSet object that has the same structure as
ContosoProductsDataset,
including the primary key. You want the new DataSet object to be empty of data.
Which code segment should you use?
A. Dim NewDataSet As DataSet = ContosoProductsDataset.Clone
B. Dim NewDataSet As DataSet = ContosoProductsDataset.Copy
C. Dim NewDataSet as New DataSet ( )
newDataSet.Tables.Add (ContosoProductsDataset)
D. Dim newDataSet as New Dataset ( )
newDataSet.Tables.Add (ContosoProductsDataset.Tables (0))

Answer: A

 DataSet.Clone method copies the structure of the DataSet, including all
DataTable schemas,
relations, and constraints. It does not copy any data.
Reference: .NET Framework Class Library, DataSet.Clone Method [Visual Basic]
Incorrect Answers
B: DataSet.Copy method Copies both the structure and data for this DataSet.
C: A Dataset it cannot be added as a table.
D: We want the new dataset be same as the old. Here we just copy a single table.

11.Your Microsoft SQL Server database contains a table named ContosoOrders. Due
to recent increase in
product sale. ContosoOrders now contains more than 500,000 rows.
You need to develop an application to produce a report of all orders in the table.
You need to ensure that
the application processes the data as quickly as possible.
Which code segment should you use?
A. Dim myOleDbConnection As New OleDbConnection _
(Data Source=(local);_
& Initial Catalog=Contoso;_
& Integrated Security=true)
Dim myOleDbCommand As New OleDbCommand_
(SELECT * FROM ContosoOrders , myOleDbConnection)
Dim ordersData Reader As OleDbDataReader
MyOleDbconnection.Open()
OrdersDataReader = myOleDbcommand.ExecuteReader
B. Dim myOleDbConnection As New OleDbConnection _
(provider=sqloleDb;Data Source=(local);_
& Initial Catalog=Contoso; _
& Integrated Security=true)
Dim myOleDbCommand As New OleDbCommand_
(SELECT * FROM ContosoOrders , myOleDbConnection)
Dim ordersData Reader As OleDbDataReader
myOleDbconnection.Open()
ordersDataReader = myOleDbCommand.ExecuteReader
C. Dim myConnection As New SqlConnection _
(Data Source=(local);Initial Catalog=Contoso;_
& Integrated Security=true)
Dim myCommand as new SqlCommand_
(SELECT * FROM ContosoOrders , myConnection)
Dim ordersData Reader As SqlDataReader
Myconnection.Open()
OrdersDataReader = mycommand.ExecuteReader
D. Dim myConnection As New SqlConnection _
(Data Source=(local); Initial Catalog=Contoso; _
& Integrated Security=true)
Dim myCommand as new SqlCommand(SELECT * FROM ContosoOrders)
Dim ordersData Reader As SqlDataReader
Myconnection.Open()
ordersDataReader = myCommand.ExecuteReader

Answer: C

 A SqlConnection gives better performance than an OleDBConnection
when working with a SQL
Server data source. Furthermore, the SqlCommand object should contain both a text
query and a SqlConnection.
The critical command:
Dim myCommand as new SqlCommand (SELECT * FROM ContosoOrders , MyConnection)
Reference: .NET Framework Class Library, SqlCommand Constructor [Visual Basic]
Incorrect Answers
A, B: If we assume that the SQL Server is Version 7.0 or later, a SqlConnection would be
more effective than
an OleDBConnection.
D: The SqlCommand should include the SqlConnection as well.

12.You are debugging a visual studio .Net application named ContosoApp. The
application produces an
Xml documents object and then consumes the same object. This object moves data
in the application. The
object has no schema, but it contains a declaration line that you must inspect.
You decide to transform the XML code and its declaration into a string for easy
inspection.
What should you do?
A. Assign the ToString method of the Xml Document object to a string variable.
B. Assign the OuterXml property of the Xml document object to a string variable
C. Assign the OuterXml property of the Xml document element property of the Xml
document
object to a string variable.
D. Use the WriteContentTo method of the XmlDocument object to write the document
into a
MemoryStream object. Use the GetXml method of the DataSet object to get a string
version of
the document.

Answer: B

 The XmlNode.OuterXml property gets the markup representing this node
and all its children.
Reference: .NET Framework Class Library, XmlNode.OuterXml Property [Visual
Basic]
Incorrect Answers
A: The ToString method returns a String that represents only the current Object.
C: There is no XmlDocument element property.
D: This proposed solution is complicated. Furthermore the GetXml method of the
DateSet object cannot be
used on a stream.

13.You are developing a order-processing application that retrieves data from a
Microsoft SQL Server
database contains a table named TestKCustomers and a table named Orders.
Customer has a primary key of customerID. Each row in orders has a CustomerID
that indicates which
customer placed the order.
Your application uses a DataSet object named ordersDataSet to capture customer
and order information
before it applied to the database. The ordersDataSet object has two Data Table
objects named Customers
and Orders.
You want to ensure that a row cannot exist in the Orders Data Table object without
a matching row
existing in the customers Data Table object.
Which two actions should you take? (Each correct answer presents part of the
solution. Choose two.)
A. Create a foreign key constraint named ConstraintOrders that has Orders.CustomersID
as the
parent column and Customers. CustomerID as the child column.
B. Create a foreign key constraint named ConstraintCustomers that has
Customers.CustomerID as
the parent column and Orders.CustomerID as the child column.
C. Create a unique constraint named UniqueCustomers by using the
Customers.CustomerID
D. Add ConstraintOrders to the Orders Data Table.
E. Add ConstraintOrders to the Customer Data Table.
F. Add ConstraintCustomers to the Orders Data Table.
G. Add ConstraintCustomers to the Customers Data Table.
H. Add UniqueCustomers to the Customers Data Table.

Answer: B, F


B: The parent column is located in the table on the one-side, while the child column is
located on the manyside.
Here the Customers table is the parent domain and Orders is the child domain: each
Customer can
have several orders, but for each specific order there must exists exactly one
corresponding row in the
Customers table. We should use the ConstraintsCustomers constraints.
F: The constraint must be added to the Orders table.
Incorrect Answers
A: This is incorrect. The parent column must be CustomerID in the Customers table.
B, D: The ConstraintCustomers constraint must be used, not ConstraintOrders.
C, F: A unique constraint only applies to one single table.
E: The constraint must be added to the Orders table.

14.You have DataSet object named LoanCustomersDataSet that contains customers
serviced by the loan
department of Contoso. You receive a second DataSet that contains customers
serviced by the asset
management department of Contoso. Both objects have the same structure.
You want to merge assetCustomersDataSet into LoanCustomersDataSet and
preserve the original values
in loanCustomersDataSet.
Which code segment should you use?
A. loanCustomersDataSet.Merge (assetCustomersDataSet)
B. loanCustomersDataSet.Merge (assetCustomersDataSet, True)
C. assetCustomersDataSet.Merge (loanCustomersDataSet)
D. assetCustomersDataSet.Merge (loanCustomersDataSet, True)

Answer: B

 The DataSet.Merge method merges this DataSet with a specified DataSet.
The data will be
merged into the dataset on which the Merge method is applied. We want to merge into
our Dateset, namely the
loanCustomerDataSet. Furthermore, we want to preserve the original values in
loanCustomerDataSet.
The Boolean parameter is the preserveChanges. PreserveChanges indicates a value
indicating whether changes
made to the current DataSet should be maintained. It should be true, if changes should be
maintained, like in
this scenario. .
Reference: .NET Framework Class Library, DataSet.Merge Method (DataSet, Boolean)
[Visual Basic]
Incorrect Answers
A The PreserveChanges parameter must be set to true.
C, D: We must merge into loanCustomerDataSet, not into the Dataset that we have
received.

15.You are creating an XML Web service that generates a SOAP message. Parameter
information in the
SOAP message must be encrypted.
You write the appropriate code to modify the SOAP message. You also write a
method named Encrypt.
This method takes a string an argument, encrypts the string, and returns a new
string that contains the
encrypted string.
Before encryption , the Body element of the SOAP message will be written in the
following format.
&lt;soap:Body&gt;<BR>
&lt;returnToSender xlmns = http://Contoso.com/&gt;<BR>
&lt;aString&gt;<BR>some date&lt;/aString&gt;<BR>
&lt;/returnToSender&gt;<BR>
&lt;/soap:Body&gt;<BR>
After encryption, the Body element must be written in the following format.
&lt;soap:Body&gt;<BR>
&lt;returnToSender xmlns = http://Contoso.com/&gt;<BR>
154 37 146 194 17 92 32 139 28 42 184 202 164 18
&lt;/returnToSender&gt;<BR>
&lt;/soap:Body&gt;<BR>
You write code to isolate the &lt;returnToSender&gt;<BR> XML node in an XmlNode object
named theNode.
You now need to write code to encrypt the parameter information.
Which code segment should you use?
A. Dim encrypted as String = Encrypt(theNode.InnerText)<BR>
theNode.OuterXml = encrypted
B. Dim encrypted as String = Encrypt(theNode.InnerXml)<BR>
theNode.OuterXml = encrypted
C. Dim encrypted as String = Encrypt(theNode.InnerXml)<BR>
theNode.InnerXml = encrypted
D. Dim encrypted as String = Encrypt(theNode.OuterXml)<BR>
theNode.OuterXml = encrypted
E. Dim encrypted as String = Encrypt(theNode.InnerText)<BR>
theNode.InnerText = encrypted

Answer: C

First we retrieve the markup representing the child of the node with the
InnerXml property. Then
we encrypt this string. Finally we set the InnerXml property to this encrypted string.
Note: The XmlAttribute.InnerText property gets or sets the concatenated values of the
node and all its
children. For attribute nodes, this property has the same functionality as the Value
property: it gets or sets the
value of the node.
The XmlDocument.InnerXml property gets or sets the markup representing the children
of the current node.
Setting this property replaces the children of the node with the parsed contents of the
given string.
The XmlNode.OuterXml property gets the markup representing this node and all its
children.
Reference:
.NET Framework Class Library, XmlDocument.InnerXml Property [Visual Basic]
.NET Framework Class Library, XmlAttribute.InnerText Property [Visual Basic]
.NET Framework Class Library, XmlNode.OuterXml Property [Visual Basic]
Incorrect Answers
A, B: The XmlNode.OuterXml property is read only and cannot be used in the
statemement:
theNode.OuterXml = encrypted
D: theNode.OuterXml would produce the whole node, however we only want to encrypt
the string some
date.,
E: Just encrypting the InnerText property would result in a body element where the
&lt;astring&gt;<BR> markup still
would be present:
&lt;soap:Body&gt;<BR>
&lt;returnToSender xmlns = http://Contoso.org/&gt;<BR>
&lt;aString&gt;<BR>154 37 146 194 17 92 32 139 28 42 184 202 164 18&lt;/aString&gt;<BR>
&lt;/returnToSender&gt;<BR>
&lt;/soap:Body&gt;<BR>

16.You create an XML Web Service project that consists of three services, named
BronzeService,
SilverService, and GoldService. All three services are located in the same virtual
directory on a
production computer. When customers subscribed to your service, they select only
one of the three
available services.
A new customer subscribes to SilverService. You need to create a discovery
document that enables this
customer to use only SilverService.
Which discovery document should you create?
A. &lt;disco:discovery
xmlns:disco=http://schemas.contoso.org/disco/
xmlns:sc1=http://schemas.contoso.org/disco/scl/&gt;<BR>
&lt;scl:contractRef ref=SilverService.asmx?wsdl/&gt;<BR>
&lt;/disco:discovery&gt;<BR>
B. &lt;disco:discovery
xmlns:disco=http://schemas.contoso.org/disco/
xmlns:sc1=http://schemas.contoso.org/disco/scl/&gt;<BR>
&lt;scl:contractRef ref=SilverService.asmx/&gt;<BR>
&lt;/disco:discovery&gt;<BR>
C. &lt;dynamicDiscovery xmlns=urn:schemas-dynamicdiscovery:disco.2000-
03-17&gt;<BR>
&lt;exclude path=_vti_cnf/&gt;<BR>
&lt;exclude path=_vti_pvt/&gt;<BR>
&lt;exclude path=_vti_log/&gt;<BR>
&lt;exclude path=_vti_script/&gt;<BR>
&lt;exclude path=_vti_txt/&gt;<BR>
&lt;exclude path=Web References/&gt;<BR>
&lt;/dynamicDiscovery&gt;<BR>
D. &lt;dynamicdiscovery xmlns=urn:schemas-dynamicdiscovery:disco.2000-
03-17&gt;<BR>
&lt;exclude path=_vti_cnf/&gt;<BR>
&lt;exclude path=_vti_pvt/&gt;<BR>
&lt;exclude path=_vti_log/&gt;<BR>
&lt;exclude path=_vti_script/&gt;<BR>
&lt;exclude path=_vti_txt/&gt;<BR>
&lt;exclude path=Web References/&gt;<BR>
&lt;exclude path=BronzeService.asmx/&gt;<BR>
&lt;exclude path=GoldService.asmx/&gt;<BR>
&lt;/dynamicDiscovery&gt;<BR>

Answer: A

 We should create a static discovery file. We use a &lt;discovery&gt;<BR> element.
Service description
references are specified in a discovery document by adding a &lt;contractRef&gt;<BR> element.
We should use the
SilverService.asmx?wsdl query string, since the web page may and the web service may
not be located in the
same directory.
Note: XML Web service discovery is the process of locating and interrogating XML
Web service descriptions,
which is a preliminary step for accessing an XML Web service. Programmatic discovery
can be enabled when
an XML Web service publishes a .disco file, which is an XML document that can
contains links to other
discovery documents.
Note Dynamic Discovery: Dynamic discovery is a process by which ASP.NET can
perform an iterative search
through a hierarchy of folders on a development Web server to locate available XML
Web services. A dynamic
discovery (.vsdisco) file is an XML-based file with a root node called
&lt;dynamicDiscovery&gt;<BR>. To maintain
positive control over which XML Web services clients can discover, you should only use
dynamic discovery on
development Web servers. When deploying an XML Web service to a production Web
server, you should
instead create a static discovery file (.disco) for those XML Web services you want to
enable clients to discover.
Reference: .NET Framework Developer's Guide, Enabling Discovery for an XML Web
Service
Visual Basic and Visual C# Concepts, Deploying XML Web Services in Managed Code
Incorrect Answers
B: A file path to a Web Service must include the ?WSDL query string. The short form of
the URL
(SilverService.asmx) is sufficient, provided that the Web service is located in the same
folder as the Web
page using the WebService behavior.
C, D: We should create a static discovery file, not a dynamic discovery file.

17.You create version 1.0.0.0 of an assembly named TestKAssembly. You register the
assembly cache.
MyAssembly cosist of two .NET Remoting objects named TK1 and TK2. These
objects are configured in
the App.config file of MyAssembly as shown in the following code segment:
&lt;system.runtime.remoting&gt;<BR>
&lt;application&gt;<BR>
&lt;service&gt;<BR>
&lt;activated type=TestKAssembly.TK1,
MyAssembly, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=28dckd8349lduj/&gt;<BR>
&lt;wellknown mode=SingleCall
objectUri=TK2.rem
type=TestKAssembly.TK2.rem
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=28dckd8349lduj/&gt;<BR>
&lt;channels&gt;<BR>
&lt;channel ref=http/&gt;<BR>
&lt;/channels&gt;<BR>
&lt;/service&gt;<BR>
&lt;/application&gt;<BR>
&lt;/system.runtime.remoting&gt;<BR>
You create an application named MyApp that resides on a different computer than
TestKAssembly.
MyApp references version 1.0.0.0 of TestKAssembly. MyApp contains code that
activates instances of
TK1 and TK2 to use their services.
Due to change in business needs, you must update TestKAssembly. You create
version 2.0.0.0 of My
Assembly. Which is backward compatible, but you do not update any information
in the App.config file
of TestKAssembly. You register version 2.0.0.0 of TestKAssembly in the global
assembly cache. You then
rebuild MyApp.
Which version of the remote objects will MyApp activate?
A. version 1.0.0.0 of TK1; version 1.0.0.0 of TK2
B. version 1.0.0.0 of TK1; version 2.0.0.0 of TK2
C. version 2.0.0.0 of TK1; version 1.0.0.0 of TK2
D. version 2.0.0.0 of TK1; version 2.0.0.0 of TK2

Answer: B


Version 1.0.0.0 of TK1 is used since the following client-activated configuration is used:
&lt;activated type=TestKAssembly.TK1, Version=1.0.0.0
The &lt;wellknown&gt;<BR> element Contains information about server-activated objects the
application exposes to
clients. TK2 is therefore server-activated. The server controls what version is activated
when a client connects
to a server-activated object. Therefore Version 2.0.0.0 will be used for TK2.
Note 1:
When a client activates a client-activated (that is, an &lt;activated&gt;<BR>) object, a network call is
immediately sent to
the server where the requested object is activated and an object reference to the object is
returned to the client.
Because the client directs the activation of the object, the client also chooses the version
of the object to be
activated.
Note 2: For Web applications, the source controlled configuration file is called
Web.config. For non-Web
applications, the source controlled file is called app.config.
Reference: .NET Framework Developer's Guide, Versioning
Incorrect Answers
A: TK2 is server-activated (or &lt;wellknown&gt;<BR>) so the latest available version (2.0.0.0) will
be used.
C, D: Client-Side activation is used (see note 1). The version specified (1.0.0.0) is used.

18.You creating Windows-based application named TestKWinApp. To the application,
you add a Windows
Form named MyForm and a reference to a SingleCall .Net Remoting object named
TheirObject.
You need to ensure that MyForm creates an instance of TheirObject to make the
necessary remote object
calls.
Which code segment should you use?
A. RemotingConfiguration.RegisterActivatedClientType( _
GetType(TheirObject) ,
http://ContosoServer/TheirAppPath/TheirObject.rem)
Dim theirObject As New TheirObject()
B. RemotingConfiguration.RegisterWellKnownClientType( _
GetType(TheirObject) ,
http://ContosoServer/TheirAppPath/TheirObject.rem)
Dim theirObject As New TheirObject()
C. RemotingConfiguration.RegisterActivatedServiceType( _
GetType(TheirObject) ,
Dim theirObject As New TheirObject()
D. RemotingConfiguration.RegisterWellKnownServiceType( _
GetType(TheirObject) ,
http://ContosoServer/TheirAppPath/TheirObject.rem, _
WellKnownObjectMode.Singleton)
Dim theirObject As New TheirObject()

Answer: B

 The RemotingConfiguration Class provides various static methods for
configuring the remoting
infrastructure. The RegisterWellKnownClientType method registers an object Type on
the client end as a
well-known type (single call or singleton).
Reference: .NET Framework Class Library, RemotingConfiguration Members
Incorrect Answers
A: The RegisterActivatedClientType method registers an object Type on the client end
as a type that can be
activated on the server.
C: The RegisterActivatedServiceType method registers an object Type on the service
end as one that can be
activated on request from a client.
D: The RegisterWellKnownServiceType method registers an object type on the service
end as a well-known
type (single call or singleton).

19.You are preparing to deploy an XML Web service named ContosoInventoryService.
This service
queries a Microsoft SQL Server database and return information to the caller.
You are Visual Studio .Net to create a setup project. You need to install
ContosoInventorySystem. You
also need to run a script to create the necessary SQL Server database and tables to
store the data. To
accomplish this, you need to configure the project to have administrator rights to
the SQL Server
database.
You add a custom dialog box to the project that prompts the user for the
administrator user name and
password that are used to connect to the SQL Server database. You need to make
the user name and
password available to a custom Installer class that will execute the script.
What should you do?
A. Add a launch condition that passes the user name and password to the Install
subroutine.
B. Add a merge module to the project that captures the user name and password. Use the
merge module to access these values in the Install subroutine.
C. Retrieve the user name and password from the savedState object in the install
subroutine.
D. Create a custom install action. Set the CustomActionData property to the entered user
name and password. Then access these values in the Install subroutine.

Answer: D

 The CustomActionData Property specifies additional data that can be
evaluated by a custom
action during installation. Custom actions are run at the end of an installation and cannot
access information
about the installation; the CustomActionData property allows you to store information
about the installation that
can be read by the custom action.
Reference: Visual Studio, CustomActionData Property
Incorrect Answers
A: It is not possible to achieve the goal with a launch condition.
B: Merge modules would be of no use here.
Note: A merge module is like a snapshot of a particular version of a component. A new
merge module
should be created for each successive version of a component in order to avoid version
conflicts.
C: The savedStateGets property gets an IDictionary that represents the current state of
the installation.

20.You have an ASP.NET application named TestKWebApp. This application uses a
private assembly
named Employee to store and retrieve employee data. Employee is located in the bin
directory of
TestKWebApp.
You develop a new ASP .NET application named TestKWebApp2 that also needs to
use employee. You
assign Employee a strong name, set its version to 1.0.0.0, and install it in the global
assembly cache. You
then create a publisher policy assembly for version 1.0.0.0 and install it in the global
assembly cache.
You complete TestKWebApp2 against version 1.0.0.0. You do not recompile
TestKWebApp. You then
run MyWebApp.
What is the most likely result?
A. A VersionNotFoundException is Thrown.
B. Employee is loaded from the bin directory.
C. Version 1.0.0.0 of Employee is loaded from the global assembly cache.
D. Version 1.0.0.0 of Employee is loaded by the publisher policy assembly.

Answer: D

 Vendors of assemblies can state that applications should use a newer
version of an assembly by
including a publisher policy file with the upgraded assembly.
Reference:
.NET Framework Developer's Guide. Creating a Publisher Policy File
.NET Framework Developer's Guide, Versioning
Incorrect Answers
A: A VersionNotFoundExceptio represents the exception that is thrown when attempting
to return a version of
a DataRow that has been deleted.
B, C: The Publisher Policy Assembly will be used.

21.You create an XML Web service named TestKService. You must ensure that this
service meets the
following URL authorization requirements.
 Anonymous access must be disabled for TestKService.
 An authenticated user named User1 cannot access TestKService.
 All other authenticared users can access TestKService.
You configure Internet Information Services (IIS) to meet these requirements. You
now need to
configure the authorization section in the Web.config file to properly authorize the
users.
Which code segment should you use?
A. &lt;allow users=* /&gt;<BR>
&lt;deny users=User1 /&gt;<BR>
B. &lt;allow users=? /&gt;<BR>
&lt;deny users=User1 /&gt;<BR>
C. &lt;deny users=* /&gt;<BR>
&lt;deny users=User1 /&gt;<BR>
&lt;allow users=? /&gt;<BR>
D. &lt;deny users=? /&gt;<BR>
&lt;deny users=User1 /&gt;<BR>
&lt;allow users=* /&gt;<BR>

Answer: D

 The elements are applied in order one by one. The first matching element
decides whether the
user should be granted access or not.
Step 1: We deny access permissions to anonymous users with &lt;deny users=? /&gt;<BR>
Step 2: We deny access to User1 with &lt;deny users=User1 /&gt;<BR>
Step 3: We allow access for all other users with &lt;allow users=* /&gt;<BR>
Note:
Identity Description
* Refers to all identities
? Refers to the anonymous identity
Reference: .NET Framework Developer's Guide, ASP.NET Authorization
Incorrect Answers
A: All users are allowed access. We must deny before we allow.
B: All anonymous users are allowed access.
C: All users are denied access.

22.You are creating a serviced component named UserManager. UserManager adds
user accounts to
multiple transactional data sources.
The UserManager class includes the following code segment.
&lt;Transaction (TransactionOption.Required) , _
SecurityRole (Admin) &gt;<BR> _
Public Class UserManager
Inherits ServicedComponent
Public Sub AddUser (ByVal name As String, _
ByVal password As String)
 Code to add the user to data sources goes here.
End Sub
End Class
You must ensure that the AddUser method reliably saves the new user to either all
data sources or no
data sources. What should you do?
A. To AddUser, add the following attribute:
&lt;AutoComplete ( ) &gt;<BR>
B. To UserManager, add the following attribute:
&lt;JustInTimeActivation (False) &gt;<BR>
C. To the end of AddUser, add the following line of code:
ContextUtil.EnableCommit ( )
D. To the end of AddUser, add the following line of code:
ContextUtil.MyTransactionVote = True

Answer: A

 The TransactionOption.Required shares a transaction, if one exists, and
creates a new
transaction, if necessary. &lt;AutoComplete()&gt;<BR> automatically commits the transaction.
Note: The System.EnterpriseServices.AutoCompleteAttribute causes an object
participating in a transaction to
vote in favor of completing the transaction if the method returns normally. If the method
call throws an
exception, the transaction is aborted.
Reference:
.NET Framework Developer's Guide, Voting in an Automatic Transaction [Visual Basic]
.NET Framework Class Library, ContextUtil Methods
Incorrect Answers
B: Just-in-time (JIT) activation is a COM+ service that enables you to create an object as
a nonactive, contextonly
object. JIT does not apply here.
C: The ContextUtil.EnableCommit method sets the consistent bit to true and the done
bit to false in the
COM+ context. It is not useful in this scenario.
D: The ContextUtil.MyTransactionVote property gets or sets the consistent bit in the
COM+ context. It is not
useful here.

23.You develop a Windows-based application named MyWinApp that contain a
Windows Form named
Contoso1. To MyWinApp, you add a Web reference to an XML Web Service named
Service1.
Service1 exposes two Web methods named Authentication and RetrieveData. Both
methods have sessions
enabled. Authenticate authenticates a caller. If the caller is authenticated,
Authenticate creates a unique
key, stores that key by using the Session object, and returns that key.
RetrieveData expects a valid key that has been generated by Authenticate as input
before it will return
data. If the key matches the key in the current session, retrieveData will return data
to the customer.
You write the following code segment in the Page_load event of Contoso1. (Line
numbers are included
for reference only)
01 Dim service1 As New localhost.Service1 ( )
02 Dim key As String
03 Dim userData As DataSet
04  Insert new code.
05 key = service1.Authenticate (myUser, myPassword)
06 userData = service1.RetrieveData (key)
07 DataGrid1.DataSource = userData
You run the application. When line 06 executes, the Web service returns an
exception, which indicates
that the key is invalid. To ensure that the application runs without exceptions, you
must insert additional
code on line 04.
Which code segment should you use?
A. service1.PreAuthenticate = True
B. service1.InitializeLifetimeService()
C. service1.CookieContainer = New _
System.Net.CookieContainer()
D. Dim cookie As New System.Net.Cookie(Key , key)

Answer: B

 InitializeLifetimeService method obtains a lifetime service object to
control the lifetime policy
for this instance. We need to set InitializeLifeTimeService() so that the Session state is
kept.
Reference:
.NET Framework Developer's Guide, Initializing Leases [Visual Basic]
.NET Framework Class Library, AuthenticationManager.PreAuthenticate Method
Incorrect Answers
A: The PreAuthenticate property indicates whether to send authentication information
with the initial request.
If the problem was with setting service1.PreAuthenticate = True, Contoso1 would fail
at line 05 and NOT
on line 06.
C, D: Cookies would not help in making in keeping the session state.

24.You are creating an XML Web service named ShoppingCartService. All requests
made to web methods
of ShoopingCartservice require that callers present a valid key input. This key
indicates that the user has
been authenticated to make ShoppingCartService requests.
To obtain a valid key, the callers must first call GetKey.
You write the following code segment. (Line numbers are include for reference only)
01 &lt;WebMethod ( ) &gt;<BR> _
02 Public Function GetKey (ByVal caller As String) As String
03 Dim Key As String
04 If Not Context.Session (key) Is Nothing
05 key = Context.Session (key)
06 Return key
07 Else
08 Dim isAuthenticated As Boolean
09  Code to validate the caller goes here.
10 If isAuthenticated Then
11  Code to generate key goes here.
12 Context.Session (Key) = key
13 Return key
14 Else
15 Throw New Exception (User not authenticated)
16 End If
17 End If
18 End Function
You run the code and an exception is thrown on line 04. You want this code to run
without exceptions.
What should you do?
A. Delete lines 04 through 07 and delete line 17.
B. Delete Context. From lines 04, 05, and 12.
C. On line 01, set the EnableSession property of the WebMethod Attribute to true.
D. On line 01, set the CacheDuration property of the WebMethod attribute to a value
greater than zero.

Answer: C

 The EnableSession property of the WebMethod attribute enables session
state for an XML Web
service method. Once enabled, the XML Web service can access the session state
collection directly from
HttpContext.Current.Session or with the WebService.Session property if it inherits from
the WebService base
class. The default value is false.
Reference: Visual Basic and Visual C# Concepts, Using the WebMethod Attribute
Incorrect Answers
A: We should keep the key for the session. Furthermore, the Context.Session (Key) =
key
statement on line 12 would fail.
B: We should keep the key for the session. Furthermore, there would be an End If
statement with no matching
If statement.
D: Changing caching configuration would not help with the session data.

25.You are creating an XML Web service that tracks employee information. The
service contains a Web
method named RetrieveContosoEmployees. The service also contains a base class
named Employee and
two classes named Manager and Engineer, which are derived from Employee.
RetrieveContosoEmployees takes a roleID as input that specifies the type of
employee to retrieve, either
Manager or Engineer. RetrieveContosoEmployees returns an array type Employee
that contains all
employees that are in the specified role.
You want to ensure that Manager and Engineer object types can be returned from
RetrieveContosoEmployees.
What should you do?
A. Set the TypeName property of the XmlType attribute to Employee for both Manager
and Engineer.
B. Apply two XmlInclude attributes to RetrieveContosoEmployees, one of type Manager
and one of
type Engineer.
C. Apply an XmlRoot attribute to the Employee class
Apply an XmlAttribute attribute to the Manager and Engineer classes.
D. Apply an XmlRoot attribute to the Employee class
Apply an XmlElement attribute to the Manager and Engineer classes.

Answer: B

 The XmlIncludeInclue alows the XmlSerializer to recognize a type when it
serializes or
deserializes an object. We specify the two types as XmlInclude attributes to our serialzer
RetrieveContosoEmployees.
Reference:
.NET Framework Class Library, XmlIncludeAttribute Class
.NET Framework Class Library, XmlRootAttribute Class
Incorrect Answers
A: The XmlAttributes.XmlType property gets or sets an object that specifies how the
XmlSerializer serializes a
class to which the XmlTypeAttribute has been applied.
C: The XMLRoot attribute is not useful here.
Note: The XmlRootAttribute identifies a class, structure, enumeration, or interface as the
root (or top-level)
element of an XML-document instance.*
The XmlAttributes.XmlAttribute property gets or sets an object that specifies how the
XmlSerializer
serializes a public field or public read/write property as an XML attribute.
D: The XMLRoot attribute is not useful here.
Note: The XmlAttribute Indicates that a public field or property represents an XML
element when the
XmlSerializer serializes or deserializes the containing object.

26.Your Microsoft SQL Server database contains a table named ContosoOrders.
ContosoOrders is used to
store new purchase orders as they are entered into an order-entry application. To
keep up with customer
demand, the order fulfillment department wants to know at 15-minute intervals
when new orders are
entered.
You need to develop an application that reads ContosoOrders every 15 minutes and
sends all new
orders to the order fulfillment department. The application will run on computer
that is used by several
users who continuously log on and log off from the network to perform
miscellaneous tasks.
Which type of .NET application should you use?
A. Windows Form
B. Windows service
C. XML Web service
D. .NET Remoting object

Answer: B

 A Windows service would still be running even though users logs on and
off.
Incorrect Answers
A: A Windows Form would be closed when a user logs off.
C: An XML Web service is not guaranteed to keep running if a user logs off.
D: You can use .NET Remoting to enable different applications to communicate with one
another. However, a
remoting object would be destroyed when a user logs off the system.

27.You are creating an XML Web service named Accountinformation for a community
bank.
Accountinformation exposes a Web method named GetAccountBalance that returns
the account balance
as a string. You must limit access to GetAccountBalance to users who have
credentials stored in your
Microsoft SQL Server database.
You need to design GetAccountBalance to receive encrypted user credentials by
using two customs fields
named Username and password in the SOAP header. To accomplish this goal, you
must write the code
for GetAccountBalance.
Which code segment should you use?
A. Public Class AuthenticateUser Inherits SoapHeader<BR>
Public username As String<BR>
Public Password As String<BR>
End Class<BR>
 In the accountInformation class add this code:<BR><BR>
Public authenticateUserHeader As AuthenticateUser<BR>
&lt;WebMethod(), SoapHeader(authenticateUserHeader)&gt;<BR> _<BR>
Public Function GetAccountBalance() As String<BR>
If (authenticateUserHeader Is ) Then<BR>
Return Please supply Credentials.<BR>
Else<BR>
 Code to authenticate the user and return<BR>
 the account balance goes here.<BR>
End If<BR>
End Function
B. Public Class AuthenticateUser<BR>
Public username As String<BR>
Public Password As String<BR>
End Class<BR>
 In the accountInformation class add this code:<BR><BR>
Public authenticateUserHeader As AuthenticateUser<BR>
&lt;WebMethod(), SoapHeader(authenticateUserHeader)&gt;<BR> _<BR>
Public Function GetAccountBalnce() as String<BR>
If (authenticateUserHeader Is ) Then<BR>
Return Please supply Credentials.<BR>
Else<BR>
 Code to authenticate the user and return<BR>
 the account balance goes here.<BR>
End If<BR>
End Function
C. Public Class AuthenticateUser Inherits SoapHeader<BR>
Public Username As String<BR>
Public Password As String<BR>
End Class<BR>
 In the accountInformation class add this code:<BR><BR>
Public authenticateUserHeader As AuthenticateUser<BR>
&lt;WebMethod()&gt;Public Function GetAccountBalance() As String<BR>
If (authenticateUserHeader Is ) Then<BR>
Return Please supply credentials."<BR>
Else<BR>
 Code to authenticate the user and return<BR>
 the account balance goes here.<BR>
End If<BR>
End Function
D. Public Class AuthenticateUser<BR>
Public username As String<BR>
Public Password As String<BR>
End Class<BR><BR>
 In the accountInformation class add this code:<BR>
Public authenticateUserHeader As AuthenticateUser<BR>
&lt;WebMethod() &gt;<BR> _<BR>
Public Function GetAccountBalnce() As String<BR>
If (authenticateUserHeader Is ) Then<BR>
Return Please supply Credentials.<BR>
Else<BR>
 Code to authenticate the user and return<BR>
 the account balance goes here.<BR>
End If<BR>
End Function

Answer: A


Step 1: Defining a SOAP header is accomplished by defining a class representing the
data in a particular SOAP
header and deriving it from the SoapHeader class.
Step 2: Apply a SoapHeader attribute to each XML Web service method that intends to
process the SOAP
header. Set the MemberName property of the SoapHeader attribute to the name of the
member variable created
in the first step.
In this scenario:
&lt;WebMethod(), SoapHeader(authenticateUserHeader)&gt;<BR>
Reference: .NET Framework Developer's Guide, Using SOAP Headers [Visual Basic]
Incorrect Answers
B, D: The class must inherit from the SoapHeader class.
C: We must add a SoapHeader attribute to the XLM Web service method. We cant use
just
&lt;WebMethod()&gt;<BR>.

28.You create a serviced component named SessionDispenser. This computer is in the
Contoso.Utilities
assembly and is registered in a COM+ server application. SessionDispenser has
multiple callers.
You discover that there are logic problems in the Create New Session method. You
want to debug any
calls to this method.
What should you do?
A. Open the SessionDispenser solution.
Set a breakpoint on the CreateNewSession method.
Start the debugger.
B. Attach the debugger to the client process.
Set a breakpoint on the SessionDispenser.CreateNewSession method.
C. Attach the debugger to the Contoso.Utilites.exe process.
Set a breakpoint on the CreateNewSession method.
D. Attach the debugger to a Dllhost.exe process.
Set a breakpoint on the CreateNewSession method.

Answer: D

 Since this is a COM+ SERVER application we have to attach the debugger
to the Dllhost.exe.
Reference: .NET Framework Developer's Guide, Using Serviced Components with the
Global Assembly
Cache
Incorrect Answers
A: The debugger must be attached to the program that should be debugged.
B: The debugger should be attached to Dllhost.exe, not to the client process.
C: We are not debugging a Library application, so we should not attach the debugger to
the
Contoso.Utilities.exe process.

29.You create an XML Web service named ContosoCode. Your project source includes
a code-behind file
and a file named ContosoCode.asmx.
During implementation, you use the Debug class to record debugging log messages,
to verify values, and
to report debugging failures.
You want to deploy ContosoCode to a production computer. You do not want any of
the debugging code
to execute on the production computer.
What should you do?
A. Set the projects active configuration to Release and rebuild the DLL.
B. Modify the trace element of the Web.config file by setting the enabled attribute to
false.
C. Modify the compilation element of the Web.config file by setting the debug attribute
to false.
D. Add code to the constructor of the ContosoCode class to set the AutoFlash property of
the Debug class
to false.
E. Add code to the constructor of the ContosoCode class to call the Clear method of the
Debug.Listeners
property.

Answer: A

 We can only exclude the debugging code from being executed by setting
the Project Active
Configuration to Release and rebuild the Web Server again.
Note: Project build configurations are listed in the Project Property Pages dialog box and
list all of the available
types of project builds, such as Debug or Release
Reference: Visual Studio, Creating Solution and Project Build Configurations

30.You create an XML Web service named TimeService. Each time TimeService is
started, it checks for the
existence of an event log named TimeServiceLog. If TimeServiceLog does not exist,
TimeService creates
it.
You discover that when TimeService creates TimeServiceLog, it throws a
System.Security.SecurityException. The exception includes the following message:
Requested registry
access is not allowed. You need to resolve this problem.
What should you do?
A. Configure Inetinfo.exe to run as the local administrator user account.
B. Create an installer for TimeService, and create the new event log in the installer code.
C. Modify the Web.config file by adding an identity element to impersonate the LOGON
user specified by
Internet Information Services (IIS).
D. Modify the permissions of the
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog registry
key to give full
control to the IUSR_computername user account.

Answer: A

 ASP.NET applications run under inetinfo.exe (the IIS process) or the ASP
worker process
aspnet_wp.exe, depending on security settings. Running as the local administrator
account the IIS process
would be able to create TimeServiceLog.
Reference: Visual Studio, Error: Unable to Start Debugging on the Web Server
Incorrect Answers
B: This would not allow registry access.
C: The account which the IIS service is running would not necessarily have permissions
to modify the
TimeServiceLog.
D: For anonymous access the IUSR_computername user account is used.

31.You create a serviced component named Scheduler. Scheduler is registered in a
library application. The
Scheduler methods parse String objects into Date Time objects.
You write a console application named TKCoverage.exe to test each method in
Scheduler. You want
Coverage.exe to test Scheduler for multiple cultures to verify its globalization
support.
What should you do?
A. Create a CultureInfo object for each culture locale before calling the Scheduler
methods.
B. Create a RegionInfo object for each culture locale before calling the Scheduler
methods.
C. Set the current threads CurrentCulture property to each culture locale before calling
the Scheduler
methods.
D. Create a TKCoverage.exe.config file and add a &lt;location&gt;<BR> element to the
configuration file for each
culture locale.

Answer: C

 We set the CurrentCulture property to a local culture, then we call the
Scheduler method. We
repeat this step for each local culture.
Reference: Visual Studio, Globalization Testing
Incorrect Answers
A: CultureInfo objects would not by themselves be tested.
B: RegionInfo objects would not by themselves be tested.
D: This is not how to set up this.

32.You create a Windows service that processes XML messages placed in a MSMQ
queue. You discover that
the service is not functioning properly.
You need to debug the service to correct the program.
What should you do?
A. Start the Windows service.
Then attach a debugger to the process.
B. Attach a debugger to the Windows service.
Then start the Windows service.
C. Start the Windows service.
Then run the .NET Services Installation tool (Regsvcs.exe).
D. Place a breakpoint in the Main method of the Windows service.
Then run the application within the Visual Studio .NET integrated development
environment (IDE).

Answer: A

 First we start the service, and then we attach the debugger to it. We must
attach to available
running processes.
Note: Microsoft Message Queuing Services (MSMQ) enables applications running at
different times to
communicate across heterogeneous networks and systems that may be temporarily
offline.
Reference: Visual Studio, Attaching to a Running Program
Incorrect Answers
B: We must attach the debugger to a running service.
C: The NET Services Installation Tool (Regsvcs.exe) cannot help in debugging the
service processing the
MSMQ queue.
Note: Regsvsc.exe loads and registers an assembly, generates, registers, and installs a
type library into a
specified COM+ 1.0 application, and configures services that you have added
programmatically to your
class.

33.You are creating an XML Web service that processes highly confidential messages.
The service exposed a
Web method named RetrieveMessage that takes as input a code name and returns
an encrypted message.
You create a SOAP extension and override the extensions ProcessMessage method
so that you can
encrypt the message before it is sent back to the caller.
You need to encrypt only the data within the RetrieveMessageResult node of the
SOAP response. You
create a function named EncryptMessage that encrypts the RetrieveMessageResult
node. You need to
ensure that this method gets called before sending the message back to the caller.
During which SoapMessageStage should you call EncryptMessage?
A. BeforeSerialize
B. AfterSerialize
C. BeforeDeserialize
D. AfterDeserialize

Answer: B

 An encryption SOAP extension might encrypt the XML portion of the
SOAP message, after
ASP.NET serializes the client's arguments, and then decrypt the SOAP message on the
Web server before
ASP.NET deserializes the SOAP message. The SOAP extension is encrypting in the
AfterSerialize stage and
decrypting in the BeforeDeserialize stage.
Note: The AfterSerialize stage occurs just after a SoapMessage is serialized, but before
the SOAP message is
sent over the wire.
Reference:
.NET Framework Developer's Guide, Altering the SOAP Message Using SOAP
Extensions
.NET Framework Class Library, SoapMessageStage Enumeration
Incorrect Answers
A: The BeforeSerialize stage occurs just prior to a SoapMessage being serialized.
C: The BeforeDeserialize stage occurs just before a SoapMessage is deserialized from
the SOAP message sent
across the network into an object.
D: The AfterDeserialize stage occurs just after a SoapMessage is deserialized from a
SOAP message into an
object.

34.You are developing an application named ContosoApp by using Visual C# .NET
and Visual Basic .NET.
The application will use functions form a DLL written in unmanaged code.
One function requires the calling application to allocate unmanaged memory, fill it
with data, and pass
the address of the memory to the function. On returning from the function, the
calling application must
deallocate the unmanaged memory.
You need to decide how your application will handle unmanaged memory.
What should you do?
A. Use a byte array.
B. Use the methods of the Marshal class.
C. Use the methods of the MemoryStream class.
D. Derive a new class from the Stream class, and override the allocation methods.

Answer: B

 The Marshal class provides a collection of methods pertaining to allocating
unmanaged memory,
copying unmanaged memory blocks, and converting managed to unmanaged types.
Reference: .NET Framework Class Library, Marshal Class [Visual Basic]
Incorrect Answers
A, D: Bytes and streams can not be used for allocating and deallocating memory.
C: The MemoryStream class creates a stream whose backing store is memory.

35.You are creating an ASP.NET application named TKWebApp. To TKWebApp, you
add a Web reference
to an XML Web service named UserService.
UserService consists of a Web method named RetrieveUserInfo. This Web method
takes a userID as
input and returns a DataSet object containing user information. If the userID is not
between the values 1
and 1000, a System ArgumentException is thrown.
In TKWebApp, you write a try/catch block to capture any exceptions that are
thrown by UserService.
You invoke RetrieveUserInfo and pass 1001 as the user ID.
Which type of exception will be caught?
A. System.ApplicationException
B. System.ArgumentException
C. System.Web.Service.Protocols.SoapException
D. System.Web.Service.Protocols.SoapHeaderException

Answer: C

 The SoapException is thrown when an XML Web service method is called
over SOAP and an
exception occurs.
Note: Simple Object Access Protocol (SOAP) codifies the practice of using XML and
HTTP to invoke methods
across networks and computer platforms. SOAP is a XML-based protocol that lets you
activate applications or
objects within an application across the Internet.
Reference: .NET Framework Class Library, SoapException Class
Incorrect Answers
A: The ApplicationException is thrown when a non-fatal application error occurs.
ApplicationException is
thrown by a user program, not by the common language runtime.
B: The ArgumentException exception is thrown when one of the arguments provided to a
method is not valid.
D: The SoapHeaderException is thrown when an XML Web service method is called
over SOAP and an
exception occurs during processing of the SOAP header.

36.You create three Windows services named TKService1, TKService2, and
TKService3. You want to install
all three services on a computer named ContosoA by using the Installer tool
(Installutil.exe).
On the command line of ContosoA, you enter and run the following command:
Installutil TKService1 TKService2 TKService3
During the installation process, TKService3 throws an installation error. The
installation process
completes.
How many of the three services are now installed on Contoso1?
A. None
B. One
C. Two
D. Three

Answer: A

 Installutil.exe performs installation in a transactional manner; if one of the
assemblies fails to
install, it rolls back the installations of all other assemblies.
Reference: .NET Framework Tools, Installer Tool (Installutil.exe)
Incorrect Answers
B, C; D: The installation of TKService3 fails and the installation of TKService2 and
TKService1 is rolled
back.

37.You create two serviced components named OrderPipeline and OrderAdmin. Each
component is
registered in a separate COM+ server application.
Both components use pricing data. OrderPipeline reads the pricing data for placing
user orders.
OrderAdmin modifies the pricing data.
You want to ensure that OrderPipeline accesses the pricing data as quickly as
possible, while still being
able to immediately retrieve any pricing changes made by OrderAdmin.
What should you do?
A. Store the pricing data in the Shared Property Manager.
B. Store the pricing data in Microsoft SQL Server database.
C. Store the pricing data in a Hashtable object within OrderAdmin.
Expose the Hashtable object through a property on OrderAdmin.
D. Store the pricing data in an XmlDocument object within OrderAdmin.
Expose the XmlDocument object through a property on OrderAdmin.

Answer: C

 A Hashtable can safely support one writer and multiple readers
concurrently. This is the most
efficient solution
Reference:
.NET Framework Class Library, Hashtable.IsSynchronized Property
Platform SDK: COM+ (Component Services), The Shared Property Manager
Incorrect Answers
A: A Shared Property Manager would be a possible solution. However it is not required
and is not the most
efficient solution.
Note: In COM+, shared transient state for objects is managed by using the Shared
Property Manager (SPM).
The SPM is a resource dispenser that you can use to share state among multiple objects
within a server
process.
B: SQL Server could provide a solution. However, it would not be the most efficient
solution.
D: A hast table would be more efficient.

38.You have a .NET Remoting object named ContosoUtils. The ContosoUtils class is a
client-activated
.NET Remoting object.
You want to write a client application that creates and uses a ContosoUtils object.
You want the client
application to hold onto a reference to a ContosoUtils object for the duration of its
execution.
What should you do?
A. Construct the ContosoUtils object, and hold the object in a member variable.
B. Construct the ContosoUtils object, and set the LifeTimeService.LeaseTime to 0.
C. In the client application, create an Implementation of the ISponsor interface.
Implement the Renewal
method to extend the lease.
D. In the client application, create an Implementation of the ILease interface.
Implement the CurrentLeaseTime property to return Int32.MaxValue.

Answer: C

We must create a sponsor, on the ISponser interface, that implements the
renewal method to
extend the lease. This will ensure that the object lease will be renewed as long the client
application is running.
Note: Each Marshal-by-reference object (MBR) has a lifetime that is controlled by a
combination of leases, a
lease manager, and some number of sponsors. A sponsor is an object that can request a
new a lease for a
particular object by registering itself with the lease manager. The lease manager
periodically examines all leases
for expired lease times. If a lease has expired, the lease manager walks its list of sponsors
for that object and
requests whether any of them want to renew the lease. If no sponsor renews the lease, the
lease manager
removes the lease and the object is deleted and its memory reclaimed by garbage
collection. The
CurrentLeaseTime can be changed, either from an ILease.Renew call or when the lease
manager calls
ISponsor.Renewal on a sponsor.
Reference: .NET Framework Developer's Guide, Lifetime Leases
.NET Framework Class Library, ILease.CurrentLeaseTime Property [Visual Basic]
Incorrect Answers
A: This would not renew the release of the object. The default lease time is 5 minutes.
B: A lease time of zero sets the lease to an infinite lifetime.
D: The ILease.CurrentLeaseTime is a read-only property of the ILease interface. We
cannot configure this
property.

39.You create a serviced component named Tracker that uses attributes to dynamically
register itself for
COM+ services. Tracker is in an assembly file named Contoso.dll. Tracker uses
transactions and rolebased
security. The roles and the application identity for Tracker are configured on the
development
computer.
You are preparing to hand off Tracker to and administrator for deployment to
production computers.
You want all the COM+ configuration information for Tracker to be installed on
the production
computers.
What should you do?
A. Use the Component Services tool to export Tracker to an .msi file.
Provide to the administrator the .msi file with instructions to run the installer.
B. Provide to the administrator the Contoso.dll file.
Instruct the administrator to copy Contoso.dll to all production computers and to install it
in the global
assembly cache.
C. Provide to the administrator the Contoso.dll file.
Instruct the administrator to use the .NET Services Installation tool (Regsvcs.exe) to
install Tracker.
D. Add a new merge module to your solution.
Add Contoso.dll to the merge module.
Provide to the administrator the .msm file with installation instructions.

Answer: A

 We use the Components services tool to create an installation package. The
installation package
will include COM+ configuration information. The installation package can be installed
on a separate system.
Procedure to create the .msi package:
Step 1: Open the Component Services Console: Start-&gt;<BR>Program-&gt;<BR>Administrative Tools-
&gt;<BR>Component Services
Step 2: Right click the appropriate COM+ service and select export.
Step 3: Finish the Welcome to COM+ Application Export Wizard.
Note: The Component Services administrative tool enables you to configure and
administer COM components
and COM+ applications. With Component Services, administrators can deploy and
administer Component
Services applications through a graphical user interface or automate administrative tasks
by using a scripting or
programming language. Software developers can use Component Services to visually
configure routine
component and application behavior, such as security and participation in transactions,
and to integrate
components into Component Services applications.
Reference: Windows XP Help.
Incorrect Answers
B: The dll file does not include COM+ configuration information.
C: Regsvcs.exe cannot be used to transfer the COM+ dll from one computer to another.
Note: The .NET Services Installation tool performs the following actions:
* Loads and registers an assembly.
* Generates, registers, and installs a type library into a specified COM+ 1.0 application.
* Configures services that you have added programmatically to your class.
D: To install a merge module, it must first be merged by using a merge tool into a .msi
file. Note: A merge
module is like a snapshot of a particular version of a component. A new merge module
should be created for
each successive version of a component in order to avoid version conflicts.

40.You are creating an XML Web service that provides a daily quotation from literary
works to its
customers. This quotation is requested in many different languages, thousands of
times every day, and by
thousands of Web sites operating many different platform.
A Web method named GetTKQuotes takes a languageID as input. GetTKQuotes
uses this language ID to
retrieve a translated version of the daily quotation from a Microsoft SQL Server
database and to return
that quotation to the customer.
You want to minimize the time it takes to return the translated version.
What should you do?
A. Store each translated quotation by using the Cache object.
B. Store each translated quotation by using the Session object.
C. Set the BufferResponse property of the WebMethod attribute to false.
D. Set the CacheDuration property of the WebMethod attribute to an interval greater than
zero.

Answer: A

 We should store each translated quotation in the Cache, more specifically
we use the translation
quotation to construct a Cache object.
Reference:
.NET Framework Developer's Guide, Adding Items to the Cache [Visual Basic]
.NET Framework Class Library, WebMethodAttribute.BufferResponse Property
.NET Framework Class Library, WebMethodAttribute.CacheDuration Property [Visual
Basic]
Incorrect Answers
B: The Session object is used to store information needed for a particular user-session.
The objects would have
to be recreated for every single session.
C: The BufferResponse property gets or sets whether the response for this request is
buffered. If set to false, no
buffering would be used. This is the opposite to the requirements.
Note: Setting BufferResponse to true, serializes the response of the XML Web service
method into a
memory buffer until either the response is completely serialized or the buffer is full. The
default value is
True.
D: WebMethodAttribute.CacheDuration property gets or sets the number of seconds the
response should be
held in the cache.

41.You are creating a .NET Remoting object named PropertyCache. PropertyCache
will hold a Hashtable
object or name/value pairs.
A variety of remote client applications will communicate with PropertyCache to set
and get property
values. You need to ensure that properties set by one client application are also
accessible to other client
applications.
Which two actions should you take? (Each correct answer presents part of the
solution. Choose two)
A. Configure PropertyCache to be a client-activated object.
B. Configure PropertyCache to be a server-activated Singleton object.
C. Configure PropertyCache to be a server-activated SingleCall object.
D. Derive the PropertyCache class from MarshalByRefObject and override
InitializeLifetimeService() to
return null.
E. Mark the PropertyCache class with the Serializable attribute.
Implement the ISponsor interface in the PropertyCache class.
F. Implement the ISerializable and ILease interfaces in the PropertyCache class.
Implement ILease.CurrentLeaseTime to return Int32.MaxValue.

Answer: B, E


B: Singleton types never have more than one instance at any one time. If an instance
exists, all client requests
are serviced by that instance. If one does not exist, the server creates an instance and all
subsequent client
requests will be serviced by that instance.
E: The ISponsor interface can be used to renew the lease of the object.
Reference:
.NET Framework Developer's Guide, Server Activation [Visual Basic]
.NET Framework Developer's Guide, Initializing Leases [Visual Basic]
.NET Framework Developer's Guide, Client Activation [Visual Basic]
Incorrect Answers
A: Client-activated objects are objects whose lifetimes are controlled by the calling
application domain, just as
they would be if the object were local to the client.
C: SingleCall types always have one instance per client request.
D: No lease is created if the lease time is 0 (zero) or a null lease is returned from
InitializeLifetimeService().
F: The ILease.CurrentLeaseTime is a read-only property of the ILease interface. We
cannot configure this
property.

42.You create a .NET Remoting object named TKPatientinfo that exposes medical
patient information.
Because of the confidential nature of the information, you must ensure that the data
remains secure.
You want client applications to connect to TKPatientinfo over a secure
communication channel. You
want to accomplish this task by writing the minimum amount of code.
What should you do?
A. Create your own host application and use a TcpChannel and BinaryFormatter.
B. Create your own host application and use an HttpChannel and a SoapFormatter.
C. Install TKPatientinfo in an Internet Information Services (IIS) virtual directory.
Configure TKPatientinfo to use a TcpChannel and a BinaryFormatter.
Configure IIS to use SSL.
D. Install TKPatientinfo in an Internet Information Services (IIS) virtual directory.
Configure TKPatientinfo to use an HttpChannel and a SoapFormatter.
Configure IIS to use SSL.

Answer: D

 To minimize the coding we use IIS to deploy the .NET Remoting Object.
We then use SSL to
encrypt the HTTP traffic.
Reference: SSL in WinHTTP
Incorrect Answers
A, B: Creating your own host application would require more coding.
C: SSL encrypts HTTP traffic, not TCP traffic.

43.You are creating an XML Web service named InventoryService for a national
automobile dealership.
Each branch of the dealership will build its own client application to consume
InventoryService. Each
branch connects to the main office of the dealership by using a virtual private
network (VPN). All
computers in the dealership run on Microsoft Windows operating systems.
You need to ensure that callers of InventoryService are authenticated based on their
Windows logon
name and password. You configure Internet Information Services (IIS) according to
your security needs.
You need to configure the authentication type in the Web.config file.
Which code segment should you use?
A. &lt;authentication mode=Basic /&gt;<BR>
B. &lt;authentication mode=Forms /&gt;<BR>
C. &lt;authentication mode=Integrated /&gt;<BR>
D. &lt;authentication mode=Windows /&gt;<BR>

Answer: D

 Integrated Windows authentication can delegate security credentials
among computers running
Windows 2000 and later that are trusted and configured for delegation.
Note: ASP .NET supports Forms Authentication, Passport Authentication, Windows
Authentication, and None.
In the Web.config file these are denoted Cookie, Passport, Windows and None.
Reference: Building Distributed Applications, Authentication in ASP .NET: .NET
Security Guidance
Incorrect Answers
A: Basic authentication does not use the Windows logon name and password.
B: Integrated is not a valid authentication mode in the Web.config file. Furthermore
Cookie authentication
mode does not use Windows login and Windows password.
C: Integrated is not a valid authentication mode in the Web.config file.

44.You have a DataSet object that contains a single DataTable object named
ContosoEmployees.
ContosoEmployees has a column named EmployeeID. EmployeeID contains no
duplicate data.
You are creating a function that accepts a parameter of EmployeeID and searches
Employees to return
the DataRow object for the specified EmployeeID.
You want to use the Find method of the rows collection in ContosoEmployees to
return the requested
DataRow object from the function. You need to ensure that you can use the Find
method to accomplish
this goal.
What should you do?
A. Ensure that EmployeeID is the first column in ContosoEmployees.
B. Ensure that EmployeeID is unique for each row in ContosoEmployees.
C. Ensure that ContosoEmployees has a primary key on EmployeeID.
D. Ensure that ContosoEmployees is sorted in ascending order on EmployeeID.

Answer: C

 To use the Find method, the DataTable object to which the
DataRowCollection object belongs to
must have at least one column designated as a primary key column.
Incorrect Answers
A: The first column has no particular significance.
B: The unique constraint is not enough. Employees must have a primary key column.
D: Sorting will not help.

45.You are developing an application to monitor store inventory. When inventory falls
below a specified
level, the application automatically generates a purchase request. Suppliers have
requested that you
transmit purchase requests to them in an XML document. Suppliers will accept the
XML document in
any valid form, except they do not want the data set definition to be included in the
XML file.
You create a method named GeneratePurchaseRequest. You write the code to
populate a DataSet object
named myDataSet with the purchase request data. You define a variable named
fileName that contains
the name and path of the output file.
You need to create an XML file from the data in myDataSet by adding code to
GeneratePurchaseRequest. You want to accomplish this task by writing the
minimum amount of code.
Which code segment should you use?
A. myDataSet.WriteXML(fileName, XmlWriteMode.IgnoreSchema)
B. myDataSet.WriteXML(fileName, XmlWriteMode.WriteSchema)
C. myDataSet.WriteXMLSchema(filename)
D. TextWriter myWriter = new StreamWriter(fileName)
myDataSet.WriteXMLSchema(myWriter)

Answer: A

 The DataSet.WriteXml method (String, XmlWriteMode) method writes
data and optionally the
schema to the specified file. The IgnoreSchema XmlWriteMode writes the current
contents of the DataSet as
XML data, without an XSD schema as was required by the suppliers.
Reference:
.NET Framework Class Library, DataSet.WriteXml Method (String, XmlWriteMode)
[Visual Basic]
.NET Framework Class Library, XmlWriteMode Enumeration [Visual Basic]
Incorrect Answers
B: XmlWriteMode.WriteSchema writes the current contents of the DataSet as XML data
with the relational
structure as inline XSD schema. However, the suppliers do not want the data set
definitions.
C: The DataSet.WriteXmlSchema (String) method writes the DataSet structure as an
XML schema to a file.
The schema includes table, relation, and constraint definitions, but not the actual data.
D: The DataSet.WriteXmlSchema (Stream) method writes the DataSet structure as an
XML schema to the
specified System.IO.Stream object.

46.You are planning to create a DataSet object named TKDataSet to be used in a bondtrading
application.
Several developers will need to write code to manipulate TKDataSet, and you want
to ensure that
myDataSet is easy for them to use. You decide to create TKDataSet as a strongly
typed data set.
Which two actions should you take? (Each correct answer presents part of the
solution. Choose two)
A. Create an XSD schema that defines TKDataSet.
B. Create an XDR schema that defines TKDataSet.
C. Create a class for TKDataSet that is based on the schema and that inherits from the
DataSet class.
D. Create a class for TKDataSet that is based on the schema and that inherits from the
XmlSchema class.
E. Create a key pair for TKDataSet by using the Strong Name tool (Sn.exe).

Answer: A, C


A: The XML Schema definition language (XSD) enables you to define the structure and
data types for XML
documents. Given an XML Schema that complies with the XML Schema definition
language (XSD)
standard, you can generate a strongly typed DataSet,
C: The class should inherit from the DataSet class.
Reference:
.NET Framework Developer's Guide, Generating a Strongly Typed DataSet [Visual
Basic]
.NET Framework General Reference, XML Schema Reference (XSD)
Incorrect Answers
B: XML-Data Reduced (XDR) schemas are used to validate XML documents.
D: The class should inherit from the DataSet class.
E: The Strong Name tool (Sn.exe) helps sign assemblies with strong names. However,
we are creating a
DataSet not an assembly.

47.Contoso Inc. provides a credit card processing application for its customers. The
current application
supports only computers that run on a Microsoft Windows operating system.
You are asked to rewrite the current application as a .NET application. This .NET
application does not
need to be backward compatible with the current application.
You must ensure that this new application meets the following requirements:
 Must support asynchronous processing.
 Must be able to pass data through firewalls.
 Must pass only SOAP-Compliant formatted data validated by using an XSD
schema.
 Must not be limited to client computers running on a Microsoft operating system.
You want to accomplish this task by using the minimum amount of development
effort.
Which type of .NET application should you use?
A. Windows service
B. XML Web service
C. Serviced component
D. .NET Remoting object

Answer: B

 An XML Web service would:
* support asynchronous processing.
* XML traffic would be allowed to passed through firewalls
* can use SOAP-compliant formatted data validated by an XSD schema.
* could be implemented on heterogeneous systems.
Reference: Designing Distributed Applications with Visual Studio .NET, Programming
the Web with XML
Web Services
Incorrect Answers
A: A Windows service can only run on a Windows computer.
C: Serviced components cannot be run on heterogenous systems.
Note: A serviced component is a class that is authored in a CLS-compliant language and
that derives
directly or indirectly from the System.EnterpriseServices.ServicedComponent class.
Classes configured in
this way can be hosted by a COM+ application and can use COM+ services.
D: .NET Remoting objects can be run on different operating systems. However, a XML
Web service meets the
requirement in a better way.

48.You are creating a .NET Remoting object named ContosoPayroll. The
ContosoPayroll class allows
remote client applications to access payroll data for your company. Client
applications are developed by
using Windows Forms and Web Forms.
You must ensure that remote client applications are securely authenticated prior to
gaining access to
Payroll object. You want to accomplish this task by writing the minimum amount of
code.
What should you do?
A. Use a TcpChannel and a BinaryFormatter for the ContosoPayroll class.
B. Use an HttpChannel and a SoapFormatter for the ContosoPayroll class.
C. Host the ContosoPayroll class in Internet Information Services (IIS) and implement
Basic
authentication.
D. Host the ContosoPayroll class in Internet Information Services (IIS) and implement
Integrated
Windows authentication.

Answer: D

 Hosting the application on an IIS server configured for Windows
authentication would:
 client applications are securely authentication prior to gaining access to the Class.
 miniminal coding would be required
Incorrect Answers
A: This proposed solution does not address the secure authentication requirement.
Note: A TcpChannel provides an implementation for a sender-receiver channel that uses
the TCP protocol
to transmit messages.
The BinaryFormatter Class serializes and deserializes an object, or an entire graph of
connected objects, in
binary format.
B: This proposed solution does not address the secure authentication requirement.
Note: A Http channel provides an implementation for a sender-receiver channel that uses
the HTTP
protocol to transmit messages.
The SoapFormatter serializes and deserializes an object, or an entire graph of connected
objects, in SOAP
format.
C: Basic authentication is not secure.

49.You are creating an XML Web service named ListBoxService. This service provides
content, such as
states, countries, and geographical regions, for use in drop-down list boxes.
ListBoxService contains a Web method named RetrieveRegionsListBox. This
method runs a DataSet
object that contains every geographical region in the world.
RetrieveRegionsListBox calls a Microsoft SQL Server database to load the DataSet
object with region
data. You want to minimize the amount of time the method takes to return to the
caller.
What should you do?
A. Use a stored procedure to return the data.
B. Store each DataSet object by using the Session object.
C. Set the BufferResponse property of the WebMethod attribute to false.
D. Set the CacheDuration property of the WebMethod attribute to an interval greater than
zero.

Answer: D

 The BufferResponse property denotes the number of seconds the response
should be held in the
cache. The default is 0, which means the response is not cached. Caching the response
would improve
performance.
Reference:
.NET Framework Class Library, WebMethodAttribute.CacheDuration Property [Visual
Basic]
.NET Framework Class Library, WebMethodAttribute.BufferResponse Property [Visual
Basic]
Incorrect Answers
A: A stored procedure is located at the SQL Server computer. It improves performance,
especially if the code is
run repeatedly. However, this is not the case in this scenario.
B: Storing each DataSet object by using session object would increase the overhead.
C: The WebMethodAttribute.BufferResponse property gets or sets whether the response
for this request is
buffered. Setting the value to false would not buffer the request.

50.You are creating an XML Web service that will be accessed by callers who cannot
use SSL encryption
because if firewall restrictions. To protect sensitive data, you want to encrypt a
portion of the data
returned from the service by using objects in the Cryptography namespace.
The service will use a standard encryption routine to encrypt the data before it is
sent to the caller. The
caller will decrypt the data by using instructions provided by you.
You need to write code to encrypt the sensitive data that is in a local variable named
TestKData. First,
you create an instance of a Cryptography Service Provider.
What should you do next?
A. Create an Encryptor object that passes in a key and an initialization vector (IV) as
parameters.
Call the GetHashCode method of the Encryptor object to generate a new hash code.
Convert the generated hash code to a stream and use the CryptoStream object to write the
value of the
hash code to an encrypted stream.
Convert the output stream to a string.
B. Create a UnicodeEncoding object and use it to encode the value of TestKData into a
byte array.
Use the ComputeHash method of the Cryptography Service Provider to create a hash
from the encoded
byte array.
Convert the output of ComputeHash from a byte array to a string.
C. Create a UnicodeEncoding object and use it to encode the value of TestKData into a
byte array.
Use the GetHashCode method of the Cryptography Service Provider to create a hash
from the encoded
byte array.
Convert the output of GetHashCode from a byte array to a string.
D. Create an Encryptor object that passes in a key and an initialization vector (IV) as
parameters.
Create a CryptoStream object that passes in an output stream and the Encryptor object as
parameters.
Convert TestKData to a stream and use the CryptoStream object to write the value of
TestKData to an
encrypted stream.
Convert the output stream to a string.

Answer: D

 The common language runtime uses a stream-oriented design for
cryptography. The core of this
design is CryptoStream.
The SymmetricAlgorithm.CreateEncryptor Method creates a symmetric encryptor object
with the current Key
and initialization vector (IV). We then use this encryptor object and pass it to stream. The
stream will then be
encrypted. The value of myDate can be written to the encrypted stream by the send, and
the receiver can
retrieve it and decrypt it to a string.
Reference:
.NET Framework Developer's Guide, Encrypting Data [Visual Basic]
.NET Framework Class Library, CryptoStream Class [Visual Basic]
.NET Framework Class Library, SymmetricAlgorithm.CreateEncryptor Method [Visual
Basic]
Incorrect Answers
A: The Encryptor object will be required when setting up the CryptoStream. We cannot
use a hash code of the
Encryptor object.
B, C: UniEncoding is used to convert characters between the Unicode and ASCII
standards. UniEncoding is
not used for encryption.

51.You have a .NET Remoting object named ProductLoaderTK. The
ProductLoaderTK class is a serveractivated
Singleton object.
The ProductLoaderTK class loads product data into a Microsoft SQL Server
database. The Load method
of the ProductLoaderTK class is a time-consuming method to call.
You are developing a client application that uses the ProductLoaderTK class. You
want to ensure that
the client application can continue to respond to user input while the Load method
of the
ProductLoaderTK class is called.
What should you do?
A. Use an AsyncDelegate instance to call the Load method.
B. Modify the ProductLoaderTK class to be derived from IAsyncResult.
C. Configure the ProductLoaderTK class to be a client-activated .NET Remoting object.
D. Configure the client application to have its own remoting channel that matches the
servers channel and
formatter.

Answer: A

 Asynchronous executation will enable the caller to continue to execute.
One of the innovations
provided by the asynchronous pattern is that the caller decides whether a particular call
should be asynchronous.
It is not necessary for a called object to do additional programming for supporting
asynchronous behavior by its
clients; asynchronous delegates provide for this in the pattern.
Reference: .NET Framework Developer's Guide, Asynchronous Design Pattern
Overview
Incorrect Answers
B: Incomplete solution.
C: Remoting objects do not meet the requirements of this scenario.
D: Channels are just a way to communicate.

52.You are creating a .NET Remoting object named BankOps. BankOps exposes
methods for creating,
finding, and modifying objects in a class named BankCustomer. BankCustomer has
a large number of
read/write properties.
You expect a large number of remote client applications to frequently connect to
BankOps. You expect
these remote client applications to use many of the BankCustomer properties. You
want to ensure that
network traffic is minimized.
What should you do?
A. Add the Serializable attribute to the BankCustomer class.
B. Implement the IDisposable interface in the BankCustomer class.
C. Derive the BankCustomer class from ContextBoundObject.
D. Derive the BankCustomer class from MarshalByRefObject.
Override the inherited InitializeLifetimeService method to return null.

Answer: A

 Making the Class Serializable would make the properties available.
The easiest way to make a class serializable is to mark it with the Serializable attribute.
Note: The basic idea of serialization is that an object should be able to write its current
state, usually indicated
by the value of its member variables, to persistent storage. Later, the object can be recreated
by reading, or
deserializing, the object's state from the storage.
Reference:
.NET Framework Class Library, MarshalByRefObject Class
Incorrect Answers
B: The IDisposable interface defines a method to release allocated unmanaged resources.
C: A context is a set of properties or usage rules that define an environment where a
collection of objects
resides. The rules are enforced when the objects are entering or leaving a context. Objects
that reside in a
context and are bound to the context rules are called context-bound objects.
D: A MarshalByRefObjec enables access to objects across application domain
boundaries in applications that
support remoting.
The InitializeLifetimeService method obtains a lifetime service object to control the
lifetime policy for this
instance.

53.You are developing an ASP.NET application that consumes an XML Web service
named
AccountInformation. AccountInformation exposes a Web method named
GetAccountBalance that
expects encrypted user credentials to be passed in the SOAP header.
AccountInformation also exposes a public class named AuthenticateUser.
AuthenticateUser has two
properties named Username and Password that are both defined as string.
In the application, you create two local variable named encryptedUsername and
encryptedPassword that
you will use to pass user credentials to GetAccountBalance. You need to write code
that will execute the
GetAccountBalance Web method.
Which code segment should you use?
A. Dim TKAccountInformation As New AccountInformation()
Dim TKAuthenticateUser As New AuthenticateUser()
TKAuthenticateUser.Username = encryptedUsername
TKAuthenticateUser.Password = encryptedPassword
TKAccountInformation.AuthenticateUserValue = _myAuthenticateUser
Dim accountBalance As String accountBalance = myAccountInformation.
GetAccountBalance()
B. Dim TKAccountInformation As New AccountInformation()
Dim TKAuthenticateUser As New AuthenticateUser()
TKAuthenticateUser.Username = encryptedUsername
TKAuthenticateUser.Password = encryptedPassword
Dim accountBalance As String accountBalance =
TKAccountInformation.GetAccountBalance()
C. Dim TKAccountInformation As New AccountInformation()
Dim TKAuthenticateUser As New AuthenticateUser()
Dim Username As New SoapHeaderAttribute(Username)
Username.MemberName = encryptedUserPassword
Dim accountBalance As String accountBalance =
TKAccountInformation.GetAccountBalance()
D. Dim TKAccountInformation As New AccountInformation()
Dim TKAuthenticateUser As New AuthenticateUser()
TKAuthenticateUser.Username = encryptedUsername
TKAuthenticateUser.Password = encryptedPassword
Dim TKSoapHeaderCollection As New SoapHeaderCollection()
TKSoapHeaderCollection.Add(myAuthenticateUser)
Dim accountBalance As String accountBalance =
TKAccountInformation.GetAccountBalance()

Answer: A

54.You are creating an XML Web service named TestKService. This service has a
function named
WriteMessage that writes messages to a flat file in the C:\TKServiceLog directory.
You want to implement security for WriteMessage so that WriteMessage and all the
code it calls can
write messages only to the TKServiceLog directory.
Which code segment should you use?
A. Dim filePermission As New
FileIOPermission_(FileIOPermissionAccess.Write, C:\TKServiceLog)
filePermission.Demand()
B. Dim filePermission As New
FileIOPermission_(FileIOPermissionAccess.Write, C:\TKServiceLog)
filePermission.Deny()
C. Dim filePermission As New
FileIOPermission_(FileIOPermissionAccess.Write, C:\TKServiceLog)
filePermission.PermitOnly()
D. Dim filePermission As New
FileIOPermission_(FileIOPermissionAccess.Write, C:\TKServiceLog)
filePermission.Assert()

Answer: C

 The CodeAccessPermission.PermitOnly method prevents callers higher in
the call stack from
using the code that calls this method to access all resources except for the resource
specified by the current
instance.
Reference:
.NET Framework Developer's Guide, PermitOnly
.NET Framework Class Library, CodeAccessPermission.Demand Method
.NET Framework Class Library, CodeAccessPermission.Assert Method
Incorrect Answers
A: We want to grant permission, not check the permission.
Note: The CodeAccessPermission.Demand method forces a SecurityException at run
time if all callers
higher in the call stack have not been granted the permission specified by the current
instance.
B: We must allow permission, not deny it.
D: The CodeAccessPermission.Assert method asserts that calling code can access the
resource identified by the
current permission through the code that calls this method, even if callers higher in the
stack have not been
granted permission to access the resource.

55.You develop an application named TKApp. This application needs to run on the
same computer as a
Windows service named TKService.
You want to ensure that TKService starts from TKApp if TKService is not already
running.
Which code segment should you use?
A. Dim myServiceController As New _
ServiceController(TKService)
If myServiceController.Status = _
ServiceControllerStatus.Stopped
Then myServiceController.Start()
End If
B. Dim myServiceController As New _
ServiceController(TKService)myServiceController.Start()
C. Dim myServiceController As New _
ServiceController() Dim myArgs(1)As String my Args(0)=TKService
If myServiceController.Status = ServiceControllerStatus.Stopped
Then myServiceController.Start(myArgs)
End If
D. Dim myServiceController As New _
ServiceController() Dim myArgs(1) As String my Args(0)= TKService
myServiceController.Start(myArgs)

Answer: A

 First we create a new instance of MyService. Then we check the current
state of it with the
Status property. Finally we use the ServiceController start method to start it if it was
stopped..
Note: A Service Controller object represents a Windows service and allows you to
connect to a running or
stopped service, manipulate it, or get information about it.
Reference:
.NET Framework Class Library, ServiceController Class
.NET Framework Class Library, ServiceController Members
.NET Framework Class Library, ServiceControllerStatus Enumeration [Visual Basic]
.NET Framework Class Library, ServiceController Constructor [Visual Basic]
Visual Basic and Visual C# Concepts, Creating ServiceController Component Instances
Incorrect Answers
B: The constructor is incorrect.
C, D: Here the ServiceController constructor is used with two parameters. The first
parameter correctly
references the existing server TKService. The second parameter, my, specifies the
computer that the
service runs on. My has no special significance (we dont know the name of the
computer). Furthermore, we
do not have to specify the computer name if the service runs on the local computer.

56.You are creating an XML Web service named LegalContosoService. This service
exposes two Web
methods named SendMessage and ReceiveMessage.
SendMessage is used to send highly confidential messages to its customers.
ReceiveMessage is used to
receive highly confidential messages from its customers and to process these
messages for future use.
You need to ensure that these messages cannot be intercepted and viewed by anyone
other than
LegalContosoService and the customers who access LegalContosoService.
Which security mechanism should you use?
A. SSL
B. Authorization
C. Authentication
D. Impersonation

Answer: A

 Secure Sockets Layer (SSL) meets the requirements of this scenario. SSL
encrypts data, which
protects the data from being viewed from outside parties.
Incorrect Answers
B: Authorization is used to assign permissions and rights to users. It is not used to secure
transmitted data.
C: Authentication is used to identify users. It is not enough to secure the data transmitted.
D: Impersonation is the ability of a to execute in a security context other than from that
of the original user-It
would not help protecting the transmitted data however.

57.You are creating an XML Web service named ContosoSalesInformation. This
service provided sales
information to regional managers and directors by using a virtual private network
(VPN).
ContosoSalesInformation exposes a Web method named GetSalesInfo that returns
sales information to
the caller. You must use role-based security to restrict access to GetSalesInfo to only
members if the two
Windows groups named Manager and Director. You configure
ContosoSalesInformation to use
Integrated Windows authentication.
You write the following code to create permissions in GetSalesInfo:
Dim myPermission1 As New_PrincipalPermission(Nothing, Manager)
Dim myPermission2 As New_PrincipalPermission(Nothing, Director)
You need to write the remaining code in GetSalesInfo to ensure that only users in
the Manager group and
the Director group can access SalesInformation.
Which code segment should you use?
A. myPermission1.Intersect(myPermission2).Demand()
B. myPermission1.Union(myPermission2).Demand()
C. myPermission1.Demand() myPermission2.Demand()
D. myPermission2 = myPermission1.Copy() myPermission2.Demand()

Answer: B

 The Union method creates a permission that is the union of the current
permission and the
specified permission. We want a union of the Manager and the Director group.
Reference:
.NET Framework Class Library, SecurityPermission.Union Method [Visual Basic]
.NET Framework Class Library, PrincipalPermission.Demand Method [Visual Basic]
Incorrect Answers
A: An intersect would only give permissions of to users that are members of both the
Manager and the Director
groups.
C: This code first test the membership of the Managers groups and the tests the
membership of the Director
group. Unless both these conditions match an exception will be thrown.
D: The copy method creates and returns an identical copy of the current permission. The
code would only test
the membership of the Manager group.

58.You develop an ASP.NET application that consumes a third-party XML Web
service named
CreditService. CreditService contains a Web method named ChargeCard.
ChargeCard takes as input a
credit card number, a billing address, and a monetary amount and returns a
Boolean variable that
indicated whether or not the card was charged.
Calls to ChargeCard take one minute to complete. You do not want users to have to
wait while
ChargeCard executes. You wan users to be taken automatically to the next Web
page of application.
Which code segment should you use to call CreditService?
A. CreditService.ChargeCard(ccNumb,_
billAddress, amount)
Server.Transfer(process.aspx)
B. CreditService.ChargeCard(ccNumb,_
billAddress, amount)
Response.Redirect(process.aspx)
C. CreditService.BeginChargeCard(ccNumb, billAddress,_
amount, New AsyncCallback(AddressOf_
CCResponse), Nothing)
Server.Transfer(process.aspx)
Private Sub CCResponse(aRes As IAsyncResult)
CreditService.EndChargeCard(aRes)
End Sub
D. Dim AsyncResult As IasyncResult
AsyncResult = CreditService.BeginChargeCard(ccNumb,_
billAddress, amount, Nothing, Nothing)
AsyncResult.AsyncWaitHandle.WaitOne()
CreditService.EndChargeCard(AsyncResult)
Server.Transfer(process.aspx)

Answer: C

 AsyncCallback provides a way for client applications to complete an
asynchronous operation.
This callback delegate is supplied to the client when the asynchronous operation is
initiated. The event handler
referenced by AsyncCallback contains program logic to finish processing the
asynchronous task for the client.
Reference:
.NET Framework General Reference, Asynchronous Programming Design Pattern
[Visual Basic]
.NET Framework Class Library, AsyncCallback Delegate [Visual Basic]
Incorrect Answers
A, B: Asynchronous operation is not set up.
D: We must use the AsyncCallback delegate.

59.You are creating an XML Web service named TKWebService. Callers must be
authenticated by using
credentials passed in the SOAP header of each Web service call.
You want to use role-based security to secure each method on TKWebService. The
roles that users are
assigned are stored in a custom database table. You need to write code that will
allow you to dynamically
change which roles can execute specific methods at run time.
What should you do?
A. Create a WindowsIdentity object and a WindowsPrincipal object.
Then implement declarative role-based security.
B. Create a WindowsIdentity object and a WindowsPrincipal object.
Then implement imperative role-based security.
C. Create a GenericIdentity object and a GenericPrincipal object.
Then implement declarative role-based security.
D. Create a GenericIdentity object and a GenericPrincipal object.
Then implement imperative role-based security.

Answer: D

 The GenericIdentity class in conjunction with the GenericPrincipal class to
create an
authorization scheme that exists independent of a Windows NT or Windows 2000
domain. Furthermore, we
should use imperative role-based security to allow dynamic permissions that are decide at
runtime.
Reference: .NET Framework Developer's Guide, Creating GenericPrincipal and
GenericIdentity Objects
[Visual Basic]
Incorrect Answers
A, B: WindowsPrincipal allows code to check the Windows group membership of a
Windows user. However,
in this scenario we are creating a customized security scheme and have no use of
WindowsPrincipal objects.
C: Declarative role-based security would not allow dynamic permissions that are decide
at runtime.

60.You are developing a Windows-based application that requires the use of a
calculation function named
CalculateValue. This function includes the following signature:
Calculate Value(x As Integer) As Integer
CalculateValue is located in an unmanaged DLL named ContosoFunctions.dll, and
is not part of a COM
interface. You need to be able to use CalculateValue in your application.
Which action or actions should you take? (Choose all that apply)
A. Use Regsvr32.exe to register ContosoFunctions.dll.
B. Use Visual Studio .NET to add a reference to ContosoFunctions.dll.
C. To your application, add the following code segment:
Imports ContosoFunctions
D. To your application, add the following code segment:
Declare Function CalculateValue_Lib ContosoFunctions.dll (x As
Integer)

Answer: B, D


B: We must add a reference to the dll.
D: We must identify the function we want to use in the unmanaged dll.
Reference: .NET Framework Developer's Guide, Consuming Unmanaged DLL
Functions
.NET Framework Developer's Guide, A Closer Look at Platform Invoke
Incorrect Answers
A: Regsrv32 is not required in Visual Studio .NET. Regsrv32 was used in Visual Basic
6.0, Visual C++ 6.0
C: We are not using the NameSpace of the unmanaged dll.

61.You are creating an XML Web service named myWebService. This service will be
used to exchange
highly confidential information over the Internet with your companys business
partner named Contoso,
Inc.
You want only callers from Contoso, Inc., to be able to access myWebService. You
do not want to have
to accept a user name and password from callers.
Once callers are authenticated, you want to use Windows user accounts to authorize
access to the Web
methods exposed by the Web service. You set up two Windows user accounts named
ContosoAssociate
and ContosoManager. You need to configure myWebService to meet these security
requirements.
Which type of authentication should you use?
A. Basic
B. Digest
C. Anonymous
D. Client Certificate

Answer: D

 Client certificate authentication meets the requirements of this scenario:
 would only allow specific users to gain access
 no username or password would be required.
Incorrect Answers
A, B: Basic authentication and Digest Authentication would require a user name and a
password from the
callers.
C: Anonymous access would allow public access.

62.You create a serviced component named OrderProcessor. OrderProcessor
implements the IOrderInit
interface. The component and the interface contain the following code segments:
&lt;GuidAttribute(0B6ABB29-43D6-40a6-B5F2-83A457D062AC), _
InterfaceType(ComInterfaceType.InterfaceIsDual)&gt;<BR> _
Public Interface IOrderInit
 IOrderInit methods go here
End Interface
Public Class OrderProcessor
Inherits ServicedComponent
Implements IOrderInit
 OrderProcessor methods go here.
End Class
You discover that every time you rebuild OrderProcessor, existing unmanaged
client code fails. The
HRESULT for the exception is 0x80040154.
The exception includes the following message: Class not registered. You need to
resolve this problem.
What should you do?
A. Add a Guid attribute to the OrderProcessor class.
B. Add a ComImport attribute to the IOrderInit interface.
C. To the OrderProcessor class, add the following attribute:
ClassInterface(ClassInterfaceType.AutoDual)
D. To the end of every method, add the following line of code:
Marshal.ReleaseComObject(Me)

Answer: C

 The class interface, which is not explicitly defined in managed code, is an
interface that exposes
all public methods, properties, fields, and events that are explicitly exposed on the .NET
object. This interface
can be a dual or dispatch-only interface. Class interfaces are only generated when the
ClassInterfaceAttrribute is
set to ClassInterfaceType.AutoDual.
Reference: .NET Framework Class Library, ClassInterfaceAttribute Class
Incorrect Answers
A: The Guid attribute is used to specify a globally unique identifier (GUID) for a class or
an interface. This
information is primarily useful for interoperability with COM.
B: When placed on a class, the ComImport attribute marks the class as an externally
implemented Com class.
Such a class declaration enables the use of a C# name to refer to a COM class.
D: The Marshal.ReleaseComObject method decrements the reference count of the
supplied runtime callable
wrapper

63.You are using Visual Studio .NET to develop a new application to replace an older
COM-based
application named ContosoLegacy. The new application will use some of the old
COM components until
they can be replaced by Visual Studio .NET code.
Your application uses a COM DLL named OurCOM.dll. The Visual Studio .NET
assembly for
OurCOM.dll must be named OurDotNetCOM. You must use the name ProjectX
for the namespace of
the COM components. You must ensure that your application uses these naming
guidelines.
What should you do?
A. Reference OurCOM.dll from Visual Studio .NET.
Change the assembly name in Solution Explorer.
Change the namespace name by editing the assembly.
B. Reference OurCOM.dll from Visual .NET.
Change the assembly name in Solution Explorer.
Change the namespace name by using the Namespace property of a
CodeNamespaceImport object.
C. Run the Type Library Importer (Tlbimp.exe) with the /namespace and /out options to
create the
assembly.
D. Run the Type Library Importer (Tlbimp.exe) with the /out option to create the
assembly.
Change the namespace by using the Namespace property of a CodeNamespaceImport
object.

Answer: C

 The Type Library Importer converts the type definitions found within a
COM type library into
equivalent definitions in a common language runtime assembly. We should use the
/namespace option to
specify the namespace in which to produce the assembly. We must use the /out option to
specify output file,
assembly, and namespace in which to write the metadata definitions.
Reference: .NET Framework Tools, Type Library Importer (Tlbimp.exe)
Incorrect Answers
A: Not a practical solution.
B: An incomplete solution.
D: We should use the /namespace option to specify the namespace in which to produce
the assembly.

64.You create an XML Web service named ContosoA. You use the Debug.Assert
method in your code to
verify parameter values and ranges.
You find that ContosoA does not display assertion failure messages. Instead,
ContosoA returns an
HTTP 500 error message when an assertion fails. You want to view the assertion
failure messages.
What should you do?
A. Modify the Web.config file to stop the Debug.Assert method from displaying a
message box.
B. Modify the compilation element of the Web.config file by setting the debug attribute
to true.
C. In the constructor for ContosoA, set the Debug.AutoFlush property to false.
D. In the constructor for ContosoA, add an EventLogTraceListener object to the Listeners
property of the
Debug class.

Answer: D

 We do not want the Web service to return error messages, but we still want
to to view failure
messages. This is accomplished by using a TraceListener.
Note: The default behavior displays a message box when the application runs in userinterface
mode, and
outputs the message to the default trace output. You can customize this behavior by
adding a TraceListener to,
or removing one from, the Listeners collection.
Reference:
.NET Framework Class Library, Debug.Assert Method (Boolean, String) [Visual Basic]
Incorrect Answers
A: We still want to view asserton failure messages.
B: Setting the debug attribute of the compilation element to true does not make any
difference in this scenario.
C: Setting AutoFlush to true means that data will be flushed from the buffer to the
stream. It would not affect
the problem at hand, however.

65.You create an XML Web service that provides stock information to its customers.
You successfully test
the service. You are now ready to deploy the service to a new virtual directory on a
production computer.
You want to deploy the service without having to manually configure any settings on
the production
computer.
Which deployment mechanism should you use?
A. FTP
B. Xcopy command
C. Web setup project
D. Copy Project command

Answer: C

 Using deployment to install files on a Web server provides an advantage
over simply copying
files, in that deployment handles any issues with registration and configuration
automatically.
Reference: Visual Studio, Deployment of a Web Setup Project
Incorrect Answers
A: Download files through FTP would require manual registration and configuration.
B: Just copying the files would require manual registration and configuration.
D: Copying a project, rather than deploying it, is the simpler way to move your project's
content to a target
Web server. However, copying does not automatically configure Internet Information
Services (IIS)
directory settings.

66.You are using Visual Studio .NET to develop an application that uses a non-COM
DLL named
TestKFunctions.dll. This DLL is written in unmanaged code.
The DLL contains a function that parses a string into an array of string words and
an array of numbers.
A call to the function includes the following pseudocode:
input = A string with 6 words and 2 numbers
words = Nothing
Numbers = Nothing
Parse(input, words, numbers)
After execution, words contains all string words found in input and numbers
contains all integers found
in input. You need to enable your application to call this function.
Which code segment should you use?
A. Declare Function Parse Lib TestKFunctions.dll _
(ByVal input As String, ByVal words() As String, ByVal Numbers()
As Integer) As Integer
B. Declare Function Parse Lib TestKFunctions.dll _
(ByVal input As String, ByRef Words() As String, ByRef numbers()
As Integer) As Integer
C. Declare Function Parse Lib TestKFunctions.dll _
(ByRef input As String, ByVal words() As String, ByVal numbers()
As Integer) As Integer
D. Declare Function Parse Lib TestKFunctions.dll _
(ByRef input As String, ByRef words() As String, ByRef numbers()
As Integer) As Integer

Answer: B

 Only the value of the input parameter is used by the function so we must
use ByVal. The words
and the Numbers parameters on the other hand must be changed by the function. We must
pass these parameters
with ByRef.
Note: Functions cannot change a ByVal variables or any of their members. Functions can
ByRef variables and
their members.
Reference: Visual Basic Language Concepts, Argument Passing Mechanism
Incorrect Answers
A, C: The Words are and Numbers parameters are changed by the function, they must be
passed with ByRef.
D: The input parameter is not changed by function, and therefore ByVal is preferred.

67.You create a .NET Remoting object named AdminService, which is hosted in
Internet Information
Services (IIS). The object uses an HttpChannel and a BinaryFormatter.
AdminService is in an assembly named AdminService.dll. The URL for
AdminService is
http://LocalHost/AdminService/AS.rem.
You write a test console application named Tester.exe to test the AdminService
interface. Tester.exe
includes the following code segment:
Module Tester
Sub Main()
Dim service As New AdminService()
End Sub
End Module
You write a configuration file for Tester.exe. The configuration file is named
Tester.exe.config and
includes the following code segment:
&lt;configuration&gt;<BR>
&lt;system.runtime.remoting&gt;<BR>
&lt;application&gt;<BR>
&lt;client&gt;<BR>
&lt;wellknown
url=http://ContosoSrv/AdminService/AS.rem
type=AdminService, AdminService
/&gt;<BR>
&lt;/client&gt;<BR>
&lt;/application&gt;<BR>
&lt;/system.runtime.remoting&gt;<BR>
&lt;/configuration&gt;<BR>
You run Tester.exe. The application immediately throws a
System.NullReferenceException. The
exception includes the following message: Object reference not set to an instance of
an object. You
need to resolve this exception.
What should you do?
A. To the application element of the Tester.exe.config file, add the following code
segment:
&lt;channels&gt;<BR>
&lt;channel ref=http&gt;<BR>
&lt;clientProviders&gt;<BR>
&lt;formatter ref=binary/&gt;<BR>
&lt;/clientProviders&gt;<BR>
&lt;/channel&gt;<BR>
&lt;/channels&gt;<BR>
B. Replace the use of the AdminService constructor in Tester.exe with the following code
segment:
Dim o as Object
o = Activator.CreateInstance(GetType(AdminService))
service = CType(o, AdminService)
C. At the beginning of the Main method in Tester.exe, add the following line of code:
RemotingConfiguration.Configure(Tester.exe.config)
D. Rename the configuration file from Tester.exe.config to Tester.config.

Answer: C

 To use the remoting settings in the Tester.exe.config file, we must call
RemotingConfiguration.Configure on the application configuration file name.
Note: Developers publishing or consuming remotable objects are responsible for
configuration of the .NET
Remoting system so that applications using .NET Remoting work correctly. You can do
this programmatically,
or using the application configuration file or the machine configuration file.
Reference: .NET Framework Developer's Guide, Remote Object Configuration
Incorrect Answers
A, B: There is no need to change the application configuration file.
D: The current file name is appropriate.

68.You are creating an XML Web service that processes credit card information. This
service will be
consumed by computers that run on Microsoft Windows operating systems, as well
as computers that run
on other operating systems.
You must ensure that client credentials passed to the service are secure and cannot
be compromised. You
are not as concerned with the length of time that Web method calls take to maintain
this level of security.
You need to configure authentication for this service.
Which type of authentication should you use?
A. Basic
B. Forms
C. Client Certificate
D. Integrated Windows

Answer: C

 Client certificates can be used on both Windows and non-Windows
systems. Client certificates
provide a secure connection.
Note: Client Certificates is used for secure identification of clients in Internet and
intranet scenarios. It requires
each client to obtain a certificate from a mutually trusted certificate authority.
Reference: .NET Framework Developer's Guide, Securing XML Web Services Created
Using ASP.NET
[Visual Basic]
Incorrect Answers
A: Basic authentication is not secure. Login name and password are transferred
unencrypted in clear text.
B: Forms authentication is not supported by XML Web services. It is a system by which
unauthenticated
requests are redirected to an HTML form using HTTP client-side redirection.
D: Integrated Windows authentication can only be used on Windows computers.

69.You create a serviced component named StockQuote that implements the
IStockQuote interface. The
StockQuote class includes the following code segment:
Public Class StockQuote
Inherits ServicedComponent Implements IStockQuote
Public Function GetQuote(stock as Ticker) as Price_
Implements IStockQuote.GetQuote
Implementation code goes here.
End Function
End Class
You want to secure StockQuote so that it can only be accessed by users in the
Customers and Managers
roles. Which actions should you take? (Each correct answer presents part of the
solution. Choose two)
A. To the StockQuote class, add the following attribute:
&lt;ComponentAccessControl&gt;<BR>
B. To the StockQuote class, add the following attribute:
&lt;Transaction(TransactionOption.Required)&gt;<BR>
C. Implement the ISecurityCallContext COM interface in the StockQuote class.
Implement the IsCallerInRole method for the Customers and Managers roles.
D. To the StockQuote class, add the following attributes:
&lt;SecurityRole(Customers, False),_
SecurityRole(Managers, False)&gt;<BR>
E. To the beginning of the GetQuote method, add the following code segment:
IfNot ContextUtil.IsCallerInRole(Managers,Customers)_
Then Throw New SecurityException(Access is denies.)

Answer: A, D


A: The component attribute ComponentAccessControl is used to enable or disable access
checks at the
component level.
D: You can use the SecurityRole attribute to add the roles at the assembly level. We must
set the
SetEveryoneAccess property to false:
[SecurityRole(Customers, false)]
[SecurityRole(Managers, false)]
Incorrect Answers
B: We are not interested in configuring a transaction.
C: Incomplete.
E: The IsCallerInRole method determines whether the caller is in the specified role. We
must specify a single
role, we cannot specify two roles.

70.You create a collection of serviced components that performs bank transfers for
Contoso Ltd. All the
components are marked with the Transaction(TransactionOption.Required)
attribute. All the methods in
the components are marked with the AutoComplete() attribute. You discover that
incorrect balance
amounts are being transferred. You decide to debug the components. During
debugging, a
System.Runtime.InteropServices.COMException is thrown. The HRESULT for the
exception is
0x8004E002. The exception includes the following message: The root transaction
wanted to commit, but
transaction aborted.
You find that this exception occurs only during the debugging session, and not when
the components run
outside of the debugger. This exception is preventing you from continuing to debug
the components. You
need to resolve this problem.
What should you do?
A. Remove the AutoComplete attribute from each method.
Within each method implementation, add calls to the ContextUtil.SetComplete() and
ContextUtil.SetAbort() methods
B. Remove the AutoComplete attribute form each method.
Within each method implementation, add calls to the ContextUtil.MyTransactionVote
and
ContextUtil.DeactivateOnReturn properties.
C. Increase the transaction timeout in the Component Services tool by using the
Properties dialog box for
My Computer.
D. Replace each method implementation with the following code segment:
Try
 The original method implementation goes here.
Finally
ContextUtil.SetComplete()
End Try

Answer: C

 The debugging process makes the execution time longer. The transactions
will get timed out. We
must therefore increase the transaction timeout interval.
Note: A COMException is thrown when an unrecognized HRESULT is returned from a
COM method call.
Reference: .NET Framework Class Library, COMException Class [Visual Basic]
Incorrect Answers
Note: The COM+ done bit determines how long the object remains active after finishing
its work and can affect
the duration of a transaction. The consistent bit casts a vote to commit or abort the
transaction in which it
executes, and the done bit finalizes the vote.
A: The ContextUtil.SetComplete method sets the consistent bit and the done bit to true in
the COM+ context.
The ContextUtil.SetAbort method sets the consistent bit to false and the done bit to true
in the COM+
context.
B: The ContextUtil.MyTransactionVote property gets or sets the consistent bit in the
COM+ context.
The ContextUtil.DeactivateOnReturn property gets or sets the done bit in the COM+
context.
D: The ContextUtil.SetComplete method sets the consistent bit and the done bit to true in
the COM+ context. If
asked, the COM+ context will commit the current transaction, and the object is
deactivated on method
return.

71.You create an XML Web service named myService. This service exposes a Web
method named
MyMethod. You need to register myService in UDDI. First, you add a new business
name and a new
tModel. You now need to list a valid access point to myService.
Which URL should you use?
A. http://TestKServer/AppPath/myService
B. http://TestKServer/AppPath/myService=wsdl
C. http://TestKServer/AppPath/myService.asmx
D. http://TestKServer/AppPath/myService.asmx?MyMethod

Answer: C

 XML Web services are access through Web browser using an URL. The
URL to access an XML
Web service has the format:
http://servername/apppath/webservicename.asmx
The XML Web service's HTML description file is displayed. The XML Web service's
HTML description page
shows you all the XML Web service methods supported by a particular XML Web
service, including a valid
access to the method.
Note: The UDDI (Universal Description, Discovery and Integration) specifications
define a standard way to
publish and discover information about XML Web services. The XML schemas
associated with UDDI define
four types of information that would enable a developer to use a published XML Web
service. These are:
business information, service information, binding information, and information about
specifications for
services.
Reference: .NET Framework Developer's Guide, Accessing XML Web Services from a
Browser [Visual
Basic]
Incorrect Answers
A: The .asmx extension must be specified as well.
B: Use of Web Services Description Language (WSDL) is not required (and the syntax is
incorrect as well).
D: This is not the format used to access a method within a XML Web service. The format
to directly access an
method within a service is:
http://servername/appath/webservicename.asmx/Methodname?parameter=value

72.You create a serviced component named BankTransfer. BankTransfer is in a
COM+ application named
Contoso Bank. BankTransfer is secured by using the SecurityRole attribute for the
Tellers and
Managers roles.
You want members of the ContosoBankTellers group to be assigned to the Tellers
role.
What should you do?
A. Add another SecurityRole attribute to the BankTransfer class for the
ContosoBankTellers group.
B. Modify the Tellers SecurityRole attribute on the BankTransfer class to include the
ContosoBankTellers
group.
C. Use the Component Services tool to add a new role named ContosoBankTellers.
D. Use the Component Services tool to add the ContosoBankTellers group to the existing
Tellers role.

Answer: D

73.You create an XML Web service named TestK1 that exposed your companys
inventory data. This data
is used by other companies to place orders. TestK1 must conform to existing
formatting standards for
inventory data.
You deploy TestK1. You discover that some client applications are rejecting your
XML formatting
because the XML is inconsistent with the expected standard. You want to debug this
problem by tracing
the XML responses.
What should you do?
A. In the Web.config file, enable tracing by setting the enabled attribute of the trace
element to true.
B. Inside each Web method, use the Debug class to write the contents of the inherited
Context.Response
property to a log file.
C. Create a SOAP extension to log the SoapMessageStage.AfterSerialize output to a log
file.
D. On each Web method, use the SoapHeader attribute to map all SOAP headers to a
member variable for
the TestK1 class.
Then use the Trace.WriteLine method to log the headers to a log file.

Answer: C

 The AfterSerialize stage occurs after a SoapMessage is serialized, but
before the SOAP message
is sent over the wire. Logging the output of this stage is useful in this scenario.
Reference: .NET Framework Class Library, SoapMessageStage Enumeration [Visual
Basic]

74.You are creating a serviced component named TKComponent that will be
distributed to your customers.
You are also creating a setup project that will register the component in the global
assembly cache on
each customers computer.
You anticipate that there will be future updates to TKComponent that you will
provide to your
customers. All updates to TKComponent will be backward compatible. You will
create similar setup
projects for each update of TKComponent that will register the updated assembly in
the global assembly
cache.
You need to ensure that any applications on your customers computer that
reference TKComponent use
the most recent version of the component.
Which action or actions should you take? (Choose all that apply)
A. Sign TKComponent by using a strong name.
B. Compile TKComponent as a satellite assembly.
C. Include a publisher policy file that is registered in the global assembly cache on your
customers
computers.
D. Increment the assembly version for each update of TKComponent.
E. Add an application configuration file to TKComponent that includes assembly binding
information that
redirects prior versions to the updated version.

Answer: A, C, D


A: We must use a strong name for TKComponent.
Note: You cannot redirect versions for assemblies that are not strong-named. The
common language
runtime ignores the version for assemblies that are not strong-named.
C: Vendors of assemblies can state that applications should use a newer version of an
assembly by including a
publisher policy file with the upgraded assembly. In this scenario a publisher policy can
be used since the
newer versions of the component will be backward compatible.
D: We must make sure that we increment the assembly version for each update of the
component.
Reference: .NET Framework Developer's Guide, Redirecting Assembly Versions
Incorrect Answers
B: An satellite assembly is not required.
Note: By definition, satellite assemblies only contain resource files. They do not contain
any application
code. In the satellite assembly deployment model, you create an application with one
default assembly
(which is the main assembly) and several satellite assemblies.
E: An application configuration file can be used redirect one version of an assembly to
another. However, it is
not the preferred solution and is mostly used for non-backward compatible components.

75.You create a serviced component named HealthInfo. The component exposes
patient health records. You
declaratively secure HealthInfo by using role-based security.
You must ensure that the security checks are enforced. You want to prevent
HealthInfo from executing if
administrators turns off security for the COM+ application.
What should you do?
A. To the project source code, add the following attribute:
&lt;Assembly: ApplicationAccessControl(AccessChecksLevel:=
AccessChecksLevelOption.ApplicationComponent)&gt;<BR>
B. To all methods, add the following attribute:
&lt;SecurityRole(Administrators, False)&gt;<BR>
C. To the beginning of all methods, add the following code segment:
IfNot ConnectUtil.IsSecurityEnabled
Then ContextUtil.DisableCommit()
End If
D. To the beginning of all methods, add the following code segment:
IfNot ContextUtil.IsSecurityEnabled
Then Throw New SecurityException(_
Security must be enabled.)
End If

Answer: D

 We use ContextUtil.IsSecurityEnabled property to decide whether rolebased
security is active in
the current context. If it is not active we throw a securityException. This will prevent
HealthInfo from executing
if security is disabled.
Reference: .NET Framework Class Library, ContextUtil.IsSecurityEnabled Property
[Visual Basic]
Incorrect Answers
A: The AccessChecksLevelOption.ApplicationComponent specifies the level of access
checking for an
application. It is not of use here.
B: Does not apply here.
C: The ContextUtil.DisableCommit method is used in the context of transactions. It odes
not apply here.

76.You create a Windows service named FxListener that performs financial
transactions by using files in a
drop directory. When a new XML file appears in the drop directory, FxListener
opens the file and
performs the financial transaction contained within the XML code.
You want updates to each XML file to be logged in the Windows application log. A
String object named
TKMessage contains the message to be logged.
Which code segment should you use?
A. EventLog.WriteEntry(FxListener, TKMessage)
B. Dim log As New EventLog(Application)
log.WriteEntry(TKMessage)
C. Dim log As New EventLog(Application)
Trace.WriteLine(log, my Message)
D. Dim log As New EventLog(FxListener)
log.Source = Application
log.WriteEntry(TKMessage, EventLogEntryType.SuccessAudit)

Answer: D


Statement 1: Dim log As New EventLog(FxListener)
The EventLog (logname) constructor initializes a new instance of the EventLog class. It
associates the instance
with a log on the local computer.
Statement 2: log.Source = Application
We must set the Source property on your EventLog component before writing entries to
the log.
Statement 3: log.WriteEntry(myMessage, EventLogEntryType.SuccessAudit)
The EventLog.WriteEntry (message, EventLogEntryType) method writes an entry of a
specified
EventLogEntryType to the event log.
Reference:
.NET Framework Class Library, EventLog Constructor (String) [Visual Basic]
.NET Framework Class Library, EventLog.WriteEntry Method (String,
EventLogEntryType) [Visual Basic]
.NET Framework Class Library, EventLog.Source Property [Visual Basic]
Incorrect Answers
A: The EventLog.WriteEntry method (source, message) writes an information type entry
with the given
message text to the event log, using the specified registered event source. However, we
specify the
Windows service FXListener not a valid event source. The event source must already be
registered as an
event source for the appropriate log.
B: We should set the Source property on your EventLog component before writing
entries to the log.
C: We are writing log entries, not tracing entries.

77.You have an application named MyApp that contains a reference to version 1.0.0.0
of a strongly named
serviced component named ContosoComponent. This component is located in the
bin directory of
MyApp.
You receive version 2.0.0.0 of ContosoComponent, which you install in the global
assembly cache. You
reconfigure the application configuration file to redirect calls to version 2.0.0.0.
You now receive version 3.0.0.0 of ContosoComponent, which you install in the
global assembly cache.
You do not reconfigure the application configuration file. You then run MyApp.
Which version of ContosoComponent is loaded and from which location is it
loaded?
A. Version 1.0.0.0 from the bin directory.
B. Version 2.0.0.0 from the global assembly cache.
C. Version 2.0.0.0 from the bin directory.
D. Version 3.0.0.0 from the global assembly cache.

Answer: B

 The runtime uses the following steps to resolve an assembly reference:
1. Determines the correct assembly version by examining applicable configuration files,
including the
application configuration file, publisher policy file, and machine configuration file.
In this scenario the application configuration file states that Version 2.0.0.0 should be
used.
2. Checks whether the assembly name has been bound to before and, if so, uses the
previously loaded
assembly.
3. Checks the global assembly cache. If the assembly is found there, the runtime uses this
assembly.
In this scenario Version 2.0.0.0 is installed in the Global assembly cache.
4. Probes for the assembly using additional steps.
Reference: .NET Framework Developer's Guide, How the Runtime Locates Assemblies
Incorrect Answers
A: The application configuration file states that version 2.0.0.0 should be used.
C: The global assembly cache is checked first.
D: The application configuration file states that version 2.0.0.0 should be used. Newer
versions will not be
considered.

78.You create a serviced component named WorkItem that implements an interface
named IWorkItem.
You want to ensure that calls to the serviced component through IWorkItem are
queued.
What should you do?
A. To WorkItem, add the following attribute:
&lt;InterfaceQueuing(True, Interface:=IWorkItem)&gt;<BR>
B. To WorkItem, add the following attribute:
&lt;Transaction(TransactionOption.Disabled,_
Isolation:=TransactionIsolationLevel.Serializable)&gt;<BR>
C. To the WorkItem assembly, add the following attribute:
&lt;Assembly: ApplicationQueuing(Enabled:=True,_
QueueListenerEnabled:=True)&gt;<BR>
D. In the WorkItem implementation, override the Activate method from the
ServicedComponent class.
In the Activate method, add the following code segment:
Dim q As New Queue() q.Enqueue(Me)

Answer: C

 In addition to enabling queued component support at the application level,
you must mark your
interfaces as capable of receiving queued calls. You do that by using setting the
QueueListenerEnabled
attribute to True.
Note: The COM+ Queued Components (QC) service provides an easy way to invoke and
execute components
asynchronously. Processing can occur without regard to the availability or accessibility of
either the sender or
receiver.
Reference: .NET Framework Developer's Guide, Queued Components [Visual Basic]
Incorrect Answers
A: The signature for the InterfaceQueuing attribute as shown in Answer A is wrong.
B: Transactions are not helpful for interface queuing configuration.
D: Creating a new queue in the Active method is not correct in this scenario.

79.You are using Visual Studio .NET to develop an application to replace a COMbased
application. A
former colleague began writing a .NET class for the new application. This class will
be used by client
applications as a COM object. You are assigned to finish writing the class.
The class includes the following code segment:
&lt;ComVisible(False)&gt;<BR>
Public Class TKClass
Public Sub New()
Implementation code goes here.
End Sub
&lt;ComVisible(True)&gt;<BR>_
Public Function TKMethod(param As String) As Integer
Return 0
End Function
&lt;ComVisible(True)&gt;<BR>_
Protected Function TKOtherMethod() As Boolean
Return True
End Function
&lt;ComVisible(True)&gt;<BR>_
Public ReadOnly Property TKProperty() As Integer
Get
Return 0
End get
End Property
More implementation code goes here.
End Class
When this code runs, it will expose one or more methods to the client applications
through COM.
Which member or members will be exposed? (Choose all that apply)
A. TKMethod
B. TKOtherMethod
C. TKProperty
D. TKClass constructor

Answer: A, C

 The ComVisible attribute must be True to make a member visible.
Furthermore, the member
must also be declared as public.
Incorrect Answers
B: A protected function is not visible.
D: ComVisable(False) ensures that the TKClass Constructor is not visable.

80.You are creating an XML Web service named Tracker to track orders for your
company. Tracker
includes a Web method named OrderStatus for tracking the status of individual
orders. You anticipate
that many client applications will use the service.
You want administrators of Tracker to be able to monitor the requests per second
for OrderStatus.
Which code segment should you use?
A. Dim counter As New PerformanceCounter(Tracker,_
Contoso OrderStatus req/sec, False)
B. PerformanceCounterCategory.Create(Tracker,_
category, Contoso OrderStatus req/sec, req/sec)
C. Dim counterData() As CounterCreationData =_
{New CounterCreationData(Contoso OrderStatus req/sec,
help, PerformanceCounterType.RateOfCountsPerSecond32)}
Dim collection As New_
CounterCreationDataCollection(counterData)
PerformanceCounterCategory.Create(Tracker,_
Tracker performance counters, collection)
D. Dim counterData() As CounterCreationData =_
{New CounterCreationData(Int32, second,_
PerformanceCounterType.AverageTimer32)}
Dim collection As New_
CounterCreationDataCollection(counterData)
PerformanceCounterCategory.Create(OrderStatus,_
requests per second, collection)}

Answer: C

 A CounterCreationData object defines the counter type, name, and help
string for a custom
counter. A counter with the RateOfCountsPerSecond32 PerformanceCounterType is a
difference counter that
shows the average number of operations completed during each second of the sample
interval.
Reference: .NET Framework Class Library, CounterCreationData Class [Visual Basic]
.NET Framework Class Library, PerformanceCounterType Enumeration [Visual Basic]
Incorrect Answers
A: The use of the PerformanceCounter constructor is incorrect. The first parameter
should be categoryName
and the second parameter should be counterName.
B: Just creating a new PerformanceCounterCategory would not enable us to use any new
counters.
D: We want to measure the requests per second not the average time it takes to complete
the process. We
should not use the PerformanceCounterType of AverageTimer32.
Note: An AverageTimer32 counter is an average counter that measures the time it takes,
on average, to
complete a process or operation.

81.You create a Windows service named TKService that quires a table named Orders
in a Microsoft SQL
Server database. You want TKService to check every 30 seconds for new rows in
Orders.
You create the following method in myService:
Private Sub ProcessOrders(ByVal source As Object, ByVal eventArguments As
Timers.ElapsedEventArgs)
Code to process orders goes here.
End Sub
You need to add additional code to TKService to invoke the ProcessOrders method.
What should you do?
A. To the OnStart method, add the following code segment:
Dim TKTimer As New Timers.Timer()
AddHandler TKTimer.Elapsed, AddressOfProcessOrders
TKTimer.Interval = 30000
TKTimer.Enabled = True
B. To the OnCustomCommand method, add the following code segment:
Dim TKTimer As New Timers.Timer()
AddHandler TKTimer.Elapsed, AddressOf ProcessOrders
TKTimer.Interval = 30000
TKTimer.Enabled = True
C. To the OnStart method, add the following code segment:
Dim TKTimer As New Timers.Timer()
AddHandler TKTimer.Elapsed, AddressOf ProcessOrders
TKTimer.Interval = 30000
TKTimer.AutoReset = True
D. To the OnCustomCommand method, add the following code segment:
Dim TKTimer As New Timers.Timer()
AddHandler TKTimer.Elapsed, AddressOf ProcessOrders
TKTimer.Interval = 30000
TKTimer.AutoReset = True

Answer: A


Use OnStart to specify the processing that occurs when the service receives a Start
command. OnStart is the
method in which you specify the behavior of the service. OnStart can take arguments as a
way to pass data, but
this usage is rare.
After configuration of the timer we must start it by raising the Enabled event.
Reference:
.NET Framework Class Library, ServiceBase.OnStart Method [Visual Basic]
.NET Framework Class Library, Timer Members
.NET Framework Class Library, ServiceBase.OnCustomCommand Method [Visual
Basic]
Incorrect Answers
B, D: OnCustomCommand executes when the Service Control Manager (SCM) passes a
custom command to
the service. The OnCustomCommand is not a good place to place define and configure a
timer.
C: The Timer.AutoReset property indicates whether the Timer should raise the Elapsed
event each time the
specified Interval elapses or only after the first time it elapses. The default value is True,
so there is no need
to set to true in this scenario. Furthermore, the timer will not start until the Enabled
property is set to true.

82.You are using Visual Studio .NET to develop an application named NewApp to
replace a COM-based
application TKOrderProcessing. You are assigned to write a .NET class that will be
used by client
applications as a COM object. Your class code is being moved and modified while
development continues
on the new application.
You want to minimize any possible disruption to the COM interface as a result of
code changes.
Which code segment should you use?
A. &lt;ClassInterface()&gt;<BR>
Public Class MyClassToExpose
Public Function Calc()as Integer
Implementation code goes here.
End Function
End Class
B. &lt;Guid(9ED54F84-A89D-4fcd-A854-44251E92F09)&gt;<BR>
Public Interface IMyClassToExpose
Public Function Calc() as Integer
End Interface
&lt;ClassInterface(ClassInterfaceType.None)&gt;<BR>_
Public Class MyClassToExpose Implements IMyClassToExpose
Public Function Calc() as Integer
Implementation code goes here.
End Function
End Class
C. &lt;Guid(9ED54F84-A89D-4fcd-A854-44251E92F09),
_ComVisible(true)&gt;<BR>_Public Class MyClassToExpose
Public Function Calc() as Integer
Implementation code goes here.
End Function
End class
D. &lt;ClassInterface(ClassInterfaceType.AutoDispatch)&gt;<BR>
Public Class MyClassToExpose
Public Function Calc() as Integer
 Implementation code goes here.
End Function
End class

Answer: D

 By using AutoDispatch, we indicate that the class only supports late
binding for COM clients. A
dispinterface for the class is automatically exposed to COM clients on request. The type
library produced by
TlbExp does not contain type information for the dispinterface in order to prevent clients
from caching the
DispId s of the interface. The dispinterface does not exhibit the versioning problems.
Reference: .NET Framework Class Library, ClassInterfaceType Enumeration
Incorrect Answers
A, C: The interface would be disrupted if the implementation of it would be changed.
B: .The keyword Public is not valid in an interface method declaration as used for
Function Calc.

83.You are creating a .NET Remoting object. You want to add code to the object to log
error messages and
warning messages. You want to log messages written to both a log file and to the
Windows application
log.
Which code segment should you use?
A. Dim eventLog As New EventLog(remobj)
Dim fileLog As FileStream = File.Create(remobj.log)
Trace.WriteLine(eventLog, contoso sample message)
Trace.WriteLine(fileLog, contoso sample message)
B. Dim eventLog as New EventLog(remobj)
Dim fileLog As FileStream = File.Create(remobj.log)
Trace.Write(eventLog)
Trace.Write(fileLog)
Trace.WriteLine(contoso sample message)
C. Trace.Listeners.Add(new EventLogTraceListener(remobj))
Trace.Listeners.Add(_
new TextFileTraceListener(remobj.log))
Trace.WriteLine(contoso sample message)
D. Trace.Listeners.Add(new EventLogTraceListener())
Trace.Listeners.Add(_
new TextFileTraceListener(remobj.log))
Trace.WriteLine(contoso sample message)

Answer: C

 Listeners direct the tracing output to an appropriate target, such as a log,
window, or text file.
An EventLogTraceListener redirects output to an event log. A TextWriterTraceListener
redirects output to an
instance of the TextWriter class.
We should take care to use the new EventLogTraceListener(remobj) constructor.
Note: Any listener in the Listeners collection gets the same messages from the trace
output methods. If we set
up two listeners: a TextWriterTraceListener and an EventLogTraceListener. Each listener
receives the same
message. The TextWriterTraceListener would direct its output to a stream, and the
EventLogTraceListener
would direct its output to an event log.
Reference: Visual Basic and Visual C# Concepts, Trace Listeners
.NET Framework Class Library, EventLogTraceListener Class [Visual Basic]
Incorrect Answers
A: The EventLog object provides interaction with Windows event logs and filestreams
enables writing of data
to files. However, they are not appropriate for logging warning and error messages.
B: The following statements are incorrect.
Trace.Write(eventLog)
Trace.Write(fileLog)
The correct usage is Trace.Write(Parameter), where Parameter is either an Object or a
String that should be
written.
D: The EventLogTraceListener constructor() (with no parameter) initializes a new
instance of the
EventLogTraceListener class without a trace listener.

84.You are using Visual Studio .NET to develop an application. You have a common
business logic
component that was created in COM that you want to use until you can replace it
with Visual Studio
.NET code.
You create the Visual Studio .NET solution for the new application. You want to use
the COM
component in your Visual Studio .NET solution.
What should you do?
A. Register the COM component by using Regsvr32.exe.
B. Run the Type Library Exporter (Tlbexp.exe) and pass the COM component as the
filename parameter.
C. Use Visual Studio .NET to add a reference to the COM component.
D. Run the Assembly Registration tool (Regasm.exe) and pass the COM component as
the filename
parameter.

Answer: C

 We simply need to add a reference to the COM component.
Reference:
.NET Framework Developer's Guide, Registering Assemblies with COM
.NET Framework Tools, .NET Framework Tools
Incorrect Answers
A: Regsrv32 is not required in Visual Studio .NET. Regsrv32 was used for Visual Basic
6.0, and for Visual
C++ 6.0 components.
B: Tlbexp.exe generates a type library from a common language runtime assembly.
Tlbexp.exe generates a
type library but does not register it.
D: We only use Regasm.exe when we need to access .NET Framework classes in COM
Clients. However, in
this scenario we want to access the COM Component into our Visual Studio .NET
solution.
Note: To register or unregister a .NET class with COM, you must run a command-line
tool called the Assembly
Registration Tool (Regasm.exe). Regasm.exe adds information about the class to the
system registry so COM
clients can use the .NET class transparently.

85.You are creating a serviced component that will perform several distributed
transactions across different
databases. The serviced component will be called from managed and unmanaged
client applications.
You create a new class library project. You write code in the class modules to
implement the logic.
You want to detect and correct any registration errors before any client applications
use the component.
What should you do next?
A. Assign a string name to the assembly.
Compile the assembly.
Run the .NET Services Installation tool (Regsvcs.exe) to add the component to
Component Services.
B. Run the Type Library Exporter (Tlbexp.exe) to export the definition for the assembly.
C. Assign a string name for the assembly.
Compile the assembly.
Run the Global Assembly Cache tool (Gacutil.exe) to add the component to the global
assembly cache.
D. Use the Assembly Registration tool (Regasm.exe) to create entries in the registry that
describe the
assembly.

Answer: A

 The .NET Services Installation tool performs loads and registers an
assembly, generates,
registers, and installs a type library into a specified COM+ 1.0 application, and
configures services that you
have added programmatically to your class.
Reference: .NET Framework Tools, .NET Services Installation Tool (Regsvcs.exe)
Incorrect Answers
B: The Type Library Exporter generates a type library that describes the types defined in
a common language
runtime assembly.
C: The Global Assembly Cache tool allows you to view and manipulate the contents of
the global assembly
cache and download cache.
D: The Assembly Registration tool reads the metadata within an assembly and adds the
necessary entries to the
registry, which allows COM clients to create .NET Framework classes transparently.

86.You create an XML Web service that uses the Trace class to output error messages,
warning messages,
and informational messages to a log file. The service uses a TraceSwitch object to
filter the trace output.
The DisplayName property of the TraceSwitch object is TestKSwitch. On a
development computer, all
trace output appears in the log file.
You move the service to a production computer. You must configure the production
XML Web service to
output only error messages to the log file.
What should you do?
A. To the Web.config file, add the following code segment:
&lt;system.diagnostics&gt;<BR> &lt;switches&gt;<BR> &lt;add name=TestKSwitch value=1 /&gt;<BR>
&lt;/switches&gt;<BR> &lt;/system.diagnostics&gt;<BR>
B. To the Web.config file, add the following code segment:
&lt;system.diagnostics&gt;<BR> &lt;switches&gt;<BR> &lt;add name=TestKSwitch
value=TraceSwitch /&gt;<BR> &lt;/switches&gt;<BR> &lt;/system.diagnostics&gt;<BR>
C. To the Web.config file, add the following code segment:
&lt;system.diagnostics&gt;<BR> &lt;switches&gt;<BR> &lt;add name=TraceSwitch value=1 /&gt;<BR>
&lt;/switches&gt;<BR> &lt;/system.diagnostics&gt;<BR>
D. To the Web.config file, add the following code segment:
&lt;system.diagnostics&gt;<BR> &lt;switches&gt;<BR> &lt;add name=TraceSwitch
value=TestKSwitch /&gt;<BR> &lt;/switches&gt;<BR> &lt;/system.diagnostics&gt;<BR>

Answer: A

 In the Web.config file we should specify the name of the switch
(TestKSwitch) and the
appropriate Tracelevel through the value attribute.Tracelevel corresponds to the values 1
through 4. Tracelevel
1 only displays error messages.
Note: A switch provides an efficient mechanism for controlling tracing and debugging
output at run time using
external settings. The Switch class implements default behavior for switches, allowing
you to change the switch
level at run time.
Reference: .NET Framework Class Library, Switch Class [Visual Basic]
Visual Basic and Visual C# Concepts, Trace Switches
Incorrect Answers
B: Incorrectly the value attribute is set to TraceSwitch. Valid Tracelevel values are 1
through 4.
C, D: We should specify the name of the switch with a name attribute in the Web.config
file. We must specify
TestKSwitch, not TraceSwitch.

87.You create an XML Web service named PhoneNumberService that returns the
telephone numbers of
people in a specified geographical region. If an error occurs when the service is
processing requests, a
custom application exception named PhoneNumberException is thrown.
You create an ASP.NET application named TKPhoneBook that contains a Web
reference to
PhoneNumberService. You need to wrap any calls made to PhoneNumberService in
a try/catch block to
catch any PhoneNumberException that may be thrown.
Which two code segments are possible ways to achieve this goal? (Each correct
answer presents a
complete solution. Choose two)
A. Try
 Code to call PhoneNumberService method goes here.
Catch ex As SoapException
 Handle the exception
End Try
B. Try
 Code to call PhoneNumberService method goes here.
Catch ex As SoapHeaderException
 Handle the exception.
End Try
C. Try
 Code to call PhoneNumberService method goes here.
Catch ex As Exception
 Handle the exception
End Try
D. Try
 Code to call PhoneNumberService method goes here.
Catch ex As ApplicationException
 Handle the exception.
End Try

Answer: A, C.


A: XML Web service methods can generate a SoapException by simply throwing an
exception within the
XML Web service method. If the client accessed the method over SOAP, the exception is
caught on the
server and wrapped inside a new SoapException. This also applies even if the custom
exception class
PhoneNumberException is inherited from ApplicationException class.
C: The Exception class is the base class for all exceptions. Any exception would be
intercepted.
Reference:
.NET Framework Class Library, SoapException Class [Visual Basic]
.NET Framework Class Library, Exception Class [Visual Basic]
.NET Framework Class Library, ApplicationException Class [Visual Basic]
Incorrect Answers
B: The SoapHeaderException exception that is thrown when an XML Web service
method is called over
SOAP and an exception occur during processing of the SOAP header.
D: An applicationException is thrown by a user program, not by the common language
runtime. In this
scenario we use a Web Service, however.

88.You create a class named Billings that stored billing information for Contoso Inc.
Billings connects to a
local Microsoft SQL Server database to store the billing information. Billing must
run under a local user
account to connect to the database.
The billing class includes the following code:
Public Class Billings
Public Sub Submit(By Val name As String, ByVal As DateTime, By Val hours
As Double)
 Method implementation goes here.
End Sub
 Private implementation goes here.
End Class
You want to ensure that client applications on other computers can use Billings by
using .NET Remoting.
What should you do?
A. Derive the Billings class from MarshalByRefObject.
B. Implement the ISerializable interface in the Billings class.
C. Implement the IRemoteDispatch interface in the Billings class.
D. To the Billings class, add the following attribute:
&lt;Serializable()&gt;<BR>

Answer: A

 The MarshalByRefObject enables access to objects across application
domain boundaries in
applications that support remoting.
Reference: .NET Framework Class Library, MarshalByRefObject Class
.NET Framework Class Library, ISerializable Interface
Incorrect Answers
B: The ISerializable interface allows an object to take part in its own serialization and
deserialization. It would
not enable other computer to using the interface by .NET remoting however.
C: The IRemoteDispatch interface supports the .NET Framework infrastructure and is
not intended to be used
directly from your code.
D: The Serializable attribute would not by itself enable other computer to using the
interface by .NET
remoting.

89.You create an XML Web service that uses an existing COM component. You
implement the service so
that it does not return COM exceptions to its callers. Instead, the service translates
the COM exceptions
into more specific exception types based on the HRESULT, as shown in the
following code segment:
&lt;WebMethod&gt;<BR> Try
 Code to call the COM component goes here.
Catch ce As COMException
Select Case ce.ErrorCode
Case &H80070005
Throw New SecurityException(Access denied, ce)
 Additional case statements go here.
End Select
End Try
You want to record the original COM exception that was thrown.
What should you do?
A. At the beginning of the catch block, add the following code segment:
Console.WriteLine({0} COMException caught., ce)
B. At the beginning of the catch block, add the following code segment:
Context.Trace.Write(ce, COMException caught.)
C. Within each case statement add the following code segment:
ce.ToString()
D. Within each case statement, add the following code statement:
Console.WriteLine({0} COMException caught., ce.StackTrace)

Answer: B

 The original exception is caught in the following statement:
Catch ce As COMException
We should immediately save this information with the following statement:
Context.Trace.Write(ce, COMException caught.)
Reference: .NET Framework Class Library, Trace.Write Method (String, String) [Visual
Basic]
Incorrect Answers
A: Console.WriteLine only displays the message on the console. The message will not be
recorded.
C: We should only record the statement in the beginning of the catch block. Furthermore,
ce.ToString() will
not record the exception.
D: We should only record the statement in the beginning of the catch block. Furthermore,
Console.WriteLine
only displays the message on the console. The message will not be recorded.

90.You are developing a Windows-based application that requires the use of a
calculation named
CalculateValue. This function includes the following signature:
CalculateValue (x As Integer) As Integer
CalculateValue is located in an unmanaged DLL named UsefulFunctions.dll, and us
not part of a COM
interface. You need to be able to use CalculateValue in your application. Your
project directory contains
a copy of UsefulFunctions.dll.
While you are working in Debug mode, you attempt to run your application.
However, a
System.DllNotFoundException is thrown.
You verify that you are using the correct function name. You also verify that the
code in the DLL exposes
CalculateValue. You have not modified the project assembly, and you have not
modified machine-level
security. You need to test your application immediately.
What should you do?
A. Move UsefulFunctions.dll to your projects bin directory.
B. Move UsefulFunctions.dll to your projects Debug directory.
C. Immediately before the declaration of CalculateValue, add the following code
segment:
&lt;SuppressUnmanagedCodeSecurityAttribute()&gt;<BR>_
D. Immediately before the call to CalculateValue, add the following code segment:
Dim perm As New _
SecurityPermission(_
SecurityPermissionFlag.UnmanagedCode)
perm.Assert()

Answer: D

 The UnmanagedCode SecurityPermissionFlag denotes the ability to call
unmanaged code. The
proposed solution gives permission to run unmanaged code.
Note: The DllNotFoundException is thrown when a DLL specified in a DLL import
cannot be found.
Reference:
.NET Framework Class Library, DllNotFoundException Class [Visual Basic]
.NET Framework Class Library, SuppressUnmanagedCodeSecurityAttribute Class
[Visual Basic]
.NET Framework Class Library, SecurityPermissionFlag Enumeration [Visual Basic]
Incorrect Answers
A: The dll is located in the Project folder. The debugger should be able to locate the dll
file in this folder.
B: No special directory is used for debugging.
C: The SuppressUnmanagedCodeSecurityAttribute allows managed code to call into
unmanaged code without
a stack walk. It can be applied to methods that want to call into native code without
incurring the
performance loss of a run-time security check when doing so. It only affects performance
and would not
solve the problem of this scenario.

91.You have a .NET Remoting object named ContosoOrder. The ContosoOrder class
allows remote client
applications to submit orders in batches.
Each ContosoOrder object holds state information that is specific to each remote
client application. The
ContosoOrder class has overloaded constructors for initializing an object.
You want to develop a server application to host ContosoOrder objects.
What should you do?
A. Create a Windows service, and register ContosoOrder as a client-activated object.
B. Create a Windows service, and register ContosoOrder as a server-activated Singleton
object.
C. Host ContosoOrder in Internet Information Services (IIS) and create a Web.config file
to register
ContosoOrder as a server-activated SingleCall object.
D. Host ContosoOrder in Internet Information Services (IIS) and create a Web.config file
to register
ContosoOrder as a server-activated object with an infinite lease.
Answer: A
 Client-activated objects are objects whose lifetimes are controlled by the
calling application
domain. This is the appropriate solution in this scenario.
Reference:
.NET Framework Developer's Guide, Client Activation
.NET Framework Developer's Guide, Server Activation
Incorrect Answers
B, C: Singleton types never have more than one instance at any one time. If an instance
exists, all client
requests are serviced by that instance.
D: Server-activated objects with an infinite lease would not be appropriate.

92.You create an XML Web service that calculates taxes. You deploy the service to a
production computer
named Contoso1. The URL of the production XML Web service is
http://Contoso1/WS/TaxCalc.asmx.
The service does not support all international tax rates. You want to find out which
unsupported tax
rates are being requested by users. If a user requests a tax rate that is not
supported, the service records
the request by using a trace message. You want to view the unsupported rates that
have been requested
Which two actions should you take? (Each correct answer presents part of the
solution. Choose two)
A. Modify the trace element in the Web.config file of the service by setting the
pageOutput attribute to
true.
B. Modify the trace element in the Web.config file of the service by setting the enabled
attribute to true.
C. To the constructor of the TaxCalc class, add the following code segment:
Public Sub New()
InitializeComponent()
Trace.AutoFlush = True
End Sub
D. To the constructor of the TaxCalc class, ad the following code segment:
Public Sub New()
InitializeComponent()
Trace.Flush()
End Sub
E. View the page at http://Contoso1/WS/TaxCalc.asmx.
F. View the page at http://Contoso1/WS/Trace.axd.

Answer: B, F


B: You can enable tracing for an entire application in the web.config file in the
application's root directory. We
should set the trace attribute enabled to true:
&lt;trace enabled="true"...
F: Once you have enabled tracing for your application, when each page in the application
is requested, it will
execute any trace statements that it contains. You can view these statements and the
additional trace
information in the trace viewer. You can view the trace viewer by requesting trace.axd
from the root of
your application directory.
Reference: .NET Framework Developer's Guide, Enabling Application-Level Tracing
Incorrect Answers
A: If you want trace information to appear appended to the end of the page that it is
associated with, set the
pageOutput attribute in the tracing configuration section of the web.config file to true.
However, only you,
and not the users should view the tracing information.
C: Setting AutoFlush to true means that data will be flushed from the buffer to the
stream. This will not help on
providing trace information.
D: The Trace.Flush method flushes the output buffer, and causes buffered data to be
written to the Listeners.
E: This is the application file. We dont want it to show any trace information.

93.You are creating an XML Web service named TKStockService. The service contains
a Web method
named RetrieveStockInfo.
RetrieveStockInfo takes as input a stock symbol and returns a DataSet object that
contains information
about that stock. You want to capture all incoming SOAP messages in
RetrieveStockInfo and write the
messages to a file for future processing.
What should you do?
A. Enable sessions in RetrieveStockInfo.
B. Create a SOAP extension for RetrieveStockInfo.
C. Apply a SoapHeader attribute to RetrieveStockInfo.
D. Apply a SoapRpcMethod attribute to RetrieveStockInfo.

Answer: B

 The ASP.NET SOAP extension architecture revolves around an extension
that can inspect or
modify a message at specific stages in message processing on either the client or the
server. A SOAP extension
would allow the capture and processing of SOAP messages.
Reference: .NET Framework Class Library, SoapExtension Class
Incorrect Answers
A: Would not help.
C: SoapHeader is applied to an XML Web service method or an XML Web service client
to specify a SOAP
header the Web service method or XML Web service client can process.
D: Applying the SoapRpcMethodAttribute to a method specifies that SOAP messages
sent to and from the
method use RPC formatting. This would not help in capturing the SOAP messages
however.

94.You have a .NET Remoting object named Promotions. The Promotions class allows
remote client
applications to add new product promotions to an online catalog application. The
Promotions class is an
assembly file named Contoso.dll.
You have an Internet Information Services (IIS) virtual directory named
PromotionsObject. The
Contoso.dll file is in the PromotionsObject\bin directory. You want to host the
Promotions class in IIS.
What should you do?
A. Create a Web.config file that includes the following code segment:
&lt;appSettings&gt;<BR>
&lt;add key=activation value=wellknown/&gt;<BR>
&lt;/appSettings&gt;<BR>
&lt;httpHandlers&gt;<BR>
&lt;add verb=* path=Promotions.rem
type=Contoso, Promotions/&gt;<BR>
&lt;/httpHandlers&gt;<BR>
B. Create a Web.config file that includes the following code segment:
&lt;appSettings&gt;<BR>
&lt;add key=activation value=wellknown"/&gt;<BR>
&lt;add key=mode value=SingleCall/&gt;<BR>
&lt;/appSettings&gt;<BR>
&lt;httpHandlers&gt;<BR>
&lt;add verb=* path=Promotions.rem
type=Contoso, Promotions/&gt;<BR>
&lt;httpHandlers&gt;<BR>
C. Create a Web.config file that includes the following code segment:
&lt;configuration&gt;<BR>
&lt;system.runtime.remoting&gt;<BR>
&lt;application&gt;<BR>
&lt;service&gt;<BR>
&lt;wellknown&gt;<BR>
mode=SingleCall objectUri=Promotions.rem
type=Promotions,Contoso/&gt;<BR>
&lt;/service&gt;<BR>
&lt;channels&gt;<BR>
&lt;channel ref=http/&gt;<BR>
&lt;/channels&gt;<BR>
&lt;/application&gt;<BR>
&lt;/system.runtime.remoting&gt;<BR>
&lt;/configuration&gt;<BR>
D. Create a Web.config file that includes the following code segment:
&lt;configuration&gt;<BR>
&lt;system.runtime.remoting&gt;<BR>
&lt;application&gt;<BR>
&lt;service&gt;<BR>
&lt;wellknown
mode=SingleCall objectUri=Promotions.rem
type=Promotions,Contoso/&gt;<BR>
&lt;/service&gt;<BR>
&lt;channels&gt;<BR>
&lt;channel ref=tcp port=8080&gt;<BR>
&lt;serverProviders&gt;<BR>
&lt;formatter ref=soap/&gt;<BR>
&lt;/serverProviders&gt;<BR>
&lt;/channel&gt;<BR>
&lt;/channels&gt;<BR>
&lt;/application&gt;<BR>
&lt;/system.runtime.remoting&gt;<BR>
&lt;configuration&gt;<BR>

Answer: C

 The HTTP channel does not require a custom-written listener because IIS
provides the listening
functionality. Advantages of using IIS as the HTTP listener include: ease of
configuration, scalability, and
process recycling.
Reference: Visual Studio Samples: Fitch and Mather 7.0, .NET Remoting
Incorrect Answers
A, B: These are inadequate since we want to host the application on the IIS server. We
must, for example,
configure channels.
D: TCP channel would require development of an extra listener to process the request
that enters the TCP
channel.

95.You are creating an XML Web service named CustomerService. This service
receives an XML file of
customer information in the following format:
&lt;CustomerData&gt;<BR> &lt;Customers&gt;<BR> &lt;CustomerID&gt;<BR>1234&lt;/CustomerID&gt;<BR>
&lt;CompanyName&gt;<BR>Adventure Works&lt;/CompanyName&gt;<BR> &lt;/Customers&gt;<BR> &lt;Customers&gt;<BR>
&lt;CustomerID&gt;<BR>2345&lt;/CustomerID&gt;<BR> &lt;CompanyName&gt;<BR>Contoso Ltd&lt;/CompanyName&gt;<BR>
&lt;/Customers&gt;<BR> &lt;/CustomerData&gt;<BR>
You want to parse the XML file to build a flat file that will be used by another
application. The flat file
should be in the following format:
CustomerID=1234 CompanyName=Adventure Works CustomerID=2345
CompanyName=Coho Winery
You write the following code:
Dim myXML.Doc As New XmlDocument()
myXML.DOC.LOAD(C:\TableSchemaXML.xml)
Dim myRootNode As XmlNode = myXML.Doc.FirstChild
Dim customerOutput As String
Dim curNode As XmlNode
Dim i As Integer
You need to write the code that will parse the document and build the
customerOutput string that will be
used to write each row in the file.
Which code segment should you use?
A. Dim myNodeList As XmlNodeList =
_myRootNode.SelectNodes(/CustomerData/Customers)
For Each curNode In myNodeList
If curNode.HasChildNodes Then
customerOutput = 
For i = 0 To curNode.ChildNodes.Count  1
customerOutput = curNode.ChildNodes(i).Name &_ = +
curNode.ChildNodes(i).InnerText  Code to write the output files goes
here.
Next i
End If
Next
B. Dim myNodeList As XmlNodeList =
_myRootNode.SelectNodes(/CustomerData/Customers)
For Each curNode In myNodeList
If curNode.HasChildNodes Then
customerOutput = 
For i = 0 To curNode.ChildNodes.Count  1
customerOutput = curNode.ChildNodes(i).Name &_ = +
curNode.ChildNodes(i).Value
Code to write the output file goes here.
Next i
End If
Next
C. Dim myNodeList As XmlNodeList = myRootNode.SelectNodes(/Customers)
For Each curNode In myNodeList
If curNode.HasChildNodes Then
customerOutput = 
For i = 0 To curNode.ChildNodes.Count 1
customerOutput = curNode.ChildNodes(i).Name &_ = +
curNode.ChildNodes(i).InnerText
Code to Write the output file goes here.
Next i
End If
Next
D. Dim myNodeList As XmlNodeList = _myRootNode.SelectNodes(/Customers)
For Each curNode In myNodeList
If curNode.HasChildNodes Then
customerOutput = 
For i = 0 To curNode.ChildNodes.Count 1
customerOutput =_ curNode.ChildNodes(i).Attributes(0).value + =
&_curNode.ChildNodes(i).Attributes(1).Value
Code to write the output file goes here.
Next i
End If
Next

Answer: A

 The SelectNodes property selects a list of nodes matching the XPath
expression. We should use
the XPath expression /CustomerData/Customers to match the format in the XML file.
The InnerText property gets or sets the concatenated values of the node and all its
children.
Reference:
.NET Framework Class Library, XmlElement Members
.NET Framework Class Library, XmlNode.SelectNodes Method [Visual Basic]
Incorrect Answers
B: The Value property gets or sets the value of the current node only.
C: The XPath expression used, /Customers, does not match the XML file.
D: The XPath expression used, /Customers, does not match the XML file. Furthermore
we should use the
InnerText property, not the Value property.

96.You are creating an XML Web service named InventoryService for a nationwide
clothing retailer
Contoso Inc. The service provides near real-time inventory information to
individual store managers by
using a virtual private network (VPN).
InventoryService exposes a Web method named RetrieveInventory that returns
inventory information to
the caller. You configure Internet Information Services (IIS) and InventoryService
to use Integrated
Windows authentication.
You need to write code in InventoryService to ensure that only members of the
Manager group can
access RetrieveInventory.
What should you do?
A. To the &lt;authorization&gt;<BR> section of the Web.config file, add the following element:
&lt;allow roles=Manager /&gt;<BR>
B. To the &lt;authorization&gt;<BR> section of the Web.config file, add the following element:
&lt;allow users=Manager /&gt;<BR>
C. In RetrieveInventory, add the following code segment:
If User.Identity.Name.Equals(Manager) Then
 Code to retrieve inventory data goes here.
End If
D. In RetrieveInventory, add the following code segment:
If User.Identity.AuthenticationType.Equals(Manager)_
Then
 Code to retrieve inventory data goes here.
End If

Answer: A

 We should use the authorization element of the Web.config file to allow
the Manager group with
the &lt;allow roles=Manager /&gt;<BR> element.
Reference: .NET Framework General Reference, &lt;authorization&gt;<BR> Element
Incorrect Answers
B: This proposed solution would allow the user name Manager access, not the group.
C: The Name property gets the users Windows logon name. We cannot compare this to
a group name.
D: The proposed solution is incorrect. The AuthenticationType cannot be equal to
Manager.

97.You create a class named BankAccount that represents a customers bank account.
BankAccount
includes the following code segment:
Public Class BankAccount
Public ReadOnly
Property AccoundId() As String
Get
Return acctId
End Get
End Property
Public ReadOnly Property Balance() As Decimal
Get
Return bal
End Get
End Property
Sub New(ByVal AccoundId As String, ByVal balance As Decimal)
acctId=AccoundId bal = balance
End Sub
Private acctId As String
Private Bal As Decimal
End Class
You are now creating a .NET remoting object named Teller. The Teller Class
returns lists of
BankAccount objects.
You anticipate that large numbers of client applications will use the Teller object to
retrieve
BankAccount objects. You must ensure that network traffic is minimized.
What should you do?
A. Add the Serializable attribute to the BankAccount class.
B. Add the NonSerialized attribute to the BankAccount class.
C. Derive the BankAccount class from MarshalByRefObject.
D. Implement the ISerializable interface in the BankAccount class.

Answer: D

 The basic concept of object serialization is the ability to read and write
objects to streams. This
would, in this scenario, ensure that network traffic is minimized. The most effective
method to implement
serialization is to implement ISerializable interface and serialize only the required fields.
Reference: .NET Framework Developer's Guide, Serialization guidelines
.NET Framework Class Library, ISerializable Interface
Incorrect Answers
A: It is possible to serialize the entire class with the Serializable attribute. However, this
would not minimize
network traffic.
B: We want to serialize to minimize network traffic through use of streams.
C: The MarshalByRefObject enables access to objects across application domain
boundaries in applications
that support remoting. This is not called for in this scenario.

98.You are creating an XML Web service named DistributionService. This service
must be able to access
and manipulate data in a table named ContosoInventory in a Microsoft SQL Server
database.
Some functions within Distribution Service need the inventory data to be exposed as
XML data. Other
functions within DistributionService need the inventory data to be exposed as a
DataSet object.
You need to create the object that will provide this data access.
Which object should you use?
A. XmlDocument
B. XmlDocumentFragment
C. XPathDocument
D. XmlDataDocument

Answer: D

 XmlDataDocuments allows structured data to be stored, retrieved, and
manipulated through a
relational DataSet. XMLDataDocuments enables you to load either relational data or
XML data and manipulate
that data
Reference: .NET Framework Class Library, XmlDataDocument Class [Visual Basic]
Incorrect Answers
A: XmlDocument does not support relational data.
B: An XmlDocumentFragment object represents a lightweight object that is useful for
tree insert operations.
C: XPathDocument provides a fast and performant read-only cache for XML document
processing.

99.You develop an application that uses a Windows Form, a Microsoft SQL Server
database, and several
database components. You want to restrict users from writing their own
applications to access your
applications database components.
You need to configure your database component assemblies to accomplish this goal.
What should you do?
A. Apply the StrongNameIdentityPermission attribute, and specify
SecurityAction.LinkDemand.
Set the PublicKey property to the public key of the key file you use to sign your
applications
assemblies.
B. Apply the StrongNameIdentityPermission attribute, and specify
SecurityAction.RequestMinimum.
Set the PublicKey property to the public key of the key file you use to sign your
applications
assemblies.
C. Apply the PublisherIdentityPermission attribute, and specify SecurityAction.Deny.
D. Apply the PublisherIdentityPermission attribute, and specify
SecurityAction.RequestMinimum.

Answer: B

 The RequestMinimum security action is used to request for the minimum
permissions required
for code to run. We use the PublicKey property and the public key of our software
certificate to protect the
assembly.
Reference:
.NET Framework Class Library, SecurityAction Enumeration
Incorrect Answers
A: A link demand causes a security check during just-in-time compilation and only
checks the immediate caller
of your code.
C, D: The PublisherIdentityPermission represents the identity of a software publisher.
However, we have not
specified the specified the software publisher. A certificate must be used.

100.You create a class named ContosoUser that provides user information from a
variety of data sources.
Different instances of User connect to different data sources to load the data. User is
a read-only
representation of user information and does not support writing changes back to a
data source.
The User class includes the following code segment:
&lt;Serializable()&gt;<BR>
Public Class ContosoUser Public Sub New(String connectionString)
Me.connectionString = connectionString
 Additional construction code goes here.
End Sub
Friend ReadOnly Property ConnectionString() As String
Get
Return connectionString
End Get
End Property
Private connectionString As String
Other methods and properties go here.
End Class
Once a ContosoUser object has been populated, it no longer needs the
connectionString member
variable.
You have a .NET Remoting object named Project that returns User objects. You
want to prevent remote
client applications from being able to view the contents of the connectionString
member variable.
What should you do?
A. Make the ConnectionString property private.
B. Remove the connectionString parameter from the constructor.
C. Add the NonSerialized attribute to the connectionString property.
D. Add the NonSerialized attribute to the connectionString member variable.

Answer: D

 By making the connectionString member variable NonSerialized it will not
be included in
serialized data stream and client application from view the contents of it.
Note: A class often contains fields that should not be serialized. We can prevent member
variables from being
serialized by marking them with the NonSerialized attribute.
Reference: .NET Framework Developer's Guide, Selective Serialization
Incorrect Answers
A: The ConnectionString property would still be included in the serialized data stream.
B: The connectionString parameter must be included to establish a connection.
C: The NonSerialized attribute cannot be added to the connectionString property.

101.You are troubleshooting a Visual Studio .NET application that was developed by a
former colleague. The
application contains a NextToken function. This function reads product names from
a file. You find the
following code segment code within a large assembly:
Dim xwriter As New XmlTextWriter(productNames.xml,_
System.Text.Encoding.UTF8)
xwriter.WriteStartDocument(True)
xwriter.WriteStartElement(data, www.contoso.com)
Dim val As String = NextToken()
While val &lt;&gt;<BR> 
xwriter.WriteElementString(item,_
www.contoso.com, val)
val = NextToken()
xwriter.WriteEndElement()
xwriter.WriteEndDocument()
xwriter.Close()
You find that productsNames.xml contains only two entries: prod0 and prod1.
Which XML output is produced by this code segment?
A. &lt;?xml version=1.0?&gt;<BR> &lt;data xmlns=www.contoso.com&gt;<BR> &lt;item =
prod0/&gt;<BR> &lt;item = prod1/&gt;<BR> &lt;/data&gt;<BR>
B. &lt;?xml version=1.0 encoding=utf-9 standalone=yes=&gt;<BR> &lt;data&gt;<BR> &lt;item
xmlns=www.contoso.com&gt;<BR>prod0&lt;/item&gt;<BR> &lt;item
xmlns=www.contoso.com&gt;<BR>prod1&lt;/item&gt;<BR> &lt;/data&gt;<BR>
C. &lt;?xml version=1.0?&gt;<BR> &lt;data&gt;<BR> &lt;item&gt;<BR>prod0&lt;/item&gt;<BR> &lt;item&gt;<BR>prod1&lt;/item&gt;<BR>
&lt;/data&gt;<BR>
D. &lt;?xml version=1.0 encoding=utf-8 standalone=yes?&gt;<BR> &lt;data
xmlns=www.contoso.com&gt;<BR> &lt;item&gt;<BR>prod0&lt;/item&gt;<BR> &lt;item&gt;<BR>prod1&lt;/item&gt;<BR>
&lt;/data&gt;<BR>

Answer: D

 The XmlTextWriter.WriteStartElement writes the specified start tag. A
data element is specified.
The XmlWriter.WriteElementString Method write XMLElements such as
&lt;item&gt;<BR>prod0&lt;/item&gt;<BR>.
Reference: .NET Framework Class Library, XmlWriter.WriteElementString Method
(String, String, String)
[Visual Basic]
.NET Framework Class Library, XmlTextWriter.WriteStartElement Method [Visual
Basic]
Incorrect Answers
A: Two items with proper start and end tags is produced. There is no &lt;/item&gt;<BR> end tags
here.
B: The xmllnswww.contoso.com attribute is only used in the startelement, not in each
XML element.
C: The specified data element in the WriteStartElement statement is not present.

102.You create a .NET Remoting object named DocumentStore. DocumentStore is a
server-activated
Singleton object. It uses a TcpChannel to listen on port 9000. The object URI for
DocumentStore is
DocumentStore.
You need to write a client application to use DocumentStore from a computer
named ContosoSrv.
Which code segment should you use?
A. RemotingConfiguration.Configure( _
tcp//ContosoSrv:9000/DocumentStore)
Dim doc As New DocumentStore()
B. Dim t As Type
t = GetType(DocumentStore)
RemotingConfiguration.RegisterWellKnownClientType( _
t, TcpChannel,9000, ContosoSrv)
Dim doc As New DocumentStore()
C. Dim t As Type
Dim temp As Object
Dim doc As DocumentStore
t = GetType(DocumentStore)
temp = Activator.CreateInstance(t, _
tcp://ContosoSrv:9000/DocumentStore)
doc = CType(temp, DocumentStore)
D. Dim t As Type
Dim temp As Object
Dim doc As DocumentStore
ChannelServices.RegisterChannel(new TcpChannel(9000))
t = GetType(DocumentStore)
temp = Activator.CreateInstance(t, ContosoSrv)
doc = CType(temp, DocumentStore)

Answer: C(?)

 Server-activated objects are objects whose lifetimes are directly controlled
by the server. The
server application domain creates these objects only when the client makes a method call
on the object. There
are two activation modes (or WellKnownObjectMode values) for server-activated
objects, Singleton and
SingleCall. To create an instance of a server-activated type, clients either configure their
application
programmatically (or using a configuration file) and call new, or they pass the remote
object's configuration in a
call to Activator.GetObject().
Note: Any client that knows the URI of a registered well-known object can obtain a
proxy for the object by
registering the channel it prefers with ChannelServices, and activating the object by
calling new or
Activator.GetObject. To activate a well-known object with new, you must first register
the well-known object
type on the client using the RegisterWellKnownClientType method. Calling the
RegisterWellKnownClientType method gives the remoting infrastructure the location
of the remote object,
which allows the new keyword to create it. If, on the other hand, you use the
Activator.GetObject method to
activate the well-known object, you must supply it with the object's URL as an argument,
so no prior
registration on the client end is necessary.
Reference:
.NET Framework Developer's Guide, Server Activation [Visual Basic]
.NET Framework Class Library, Activator.CreateInstance Method [Visual Basic]
.NET Framework Class Library, RemotingConfiguration.RegisterWellKnownClientType
Method (Type,
String)
Incorrect Answers
A: The RemotingConfiguration.Configure method reads the configuration file and
configures the remoting
infrastructure. This solution is inadequate.
B: The Problem with answer B is that the second parameter of the
RegisterWellKnowClientType is
TCPChannel, 9000, ContosoSrv where as it is supposed to be a URL such as
tcp://ContosoSrv:9000/DocumentStore.
D: You need to use the Activator.GetObject method and NOT the Activator.GetInstance
Note: The Activator.CreateInstance method creates an instance of the specified type
using the constructor that
best matches the specified parameters.

103.You are creating an XML Web service that retrieves customer-order data.
Customer orders are
retrieved by specifying a customer ID or family name.
You write two overloaded Web methods to retrieve this data. The Web method
signatures are shown in
the following code segments:
 &lt;WebMethod()&gt;<BR>
Public Function Load(ByVal customerID As_Integer) As DataSet
 Code to retrieve and return order data goes here.
End Function
 &lt;WebMethod()&gt;<BR>
Public Function Load(ByVal familyName As_String) As DataSet
 Code to retrieve and return data goes here.
End Function
You need to ensure that the Web service engine can map requests to the appropriate
method.
What should you do?
A. Set the Description property of each WebMethod attribute to a unique description.
B. Set the MessageName property of each WebMethod attribute to a unique message
name.
C. Add the Overloads keyword to both signatures between the Public keyword and the
Function keyword.
D. Add the Overloads keyword to only the second signature between the Public keyword
and the Function
keyword.

Answer: C

 The Overloads keyword declares a property or method with the same name
as an existing
member, but with an argument list different from the original member. The argument list
in this declaration
must be different from the argument list of every overloaded procedure. The lists must
differ in the number of
arguments, their data types, or both. This allows the compiler to distinguish which
version to use. We must just
the Overloads keyword in both signatures.
Reference:
Visual Basic Language Reference, Overloads
Visual Basic Language Reference, Function Statement
.NET Framework Class Library, WebMethodAttribute.MessageName Property
Incorrect Answers
A: The WebMethodAttribut.Description property only contains a descriptive message
describing the XML
Web service method.
B: The MessageName property can be used to alias method or property names. The most
common use of the
MessageName property is to uniquely identify polymorphic methods. However, we dont
want to define
aliases. Furthermore, the overloads keyword would be needed anyway.
D: If you use Overloads in one of the declarations, you must use it in all of them.

104.You have a DataSet object named customersDataSet that contains a DataTable
object named
TestKCustomers. TestKCustomers retrieves information from a Microsoft SQL
Server database.
Customers contains a column named Region.
You want to create a DataView object named customersDataView that contains only
customers in which
the value in the Region column is France.
Which code segment should you use?
A. Dim customersDataView As
New_DataView(customersDataSet.Tables(TstKCustomers))
customersDataView.FindRows(Region = France)
B. Dim customersDataView As
New_DataView(customersDataSet.Tables(TestKCustomers))
customersDataView.FindRows(Region =France)
C. Dim customersDataView As
New_DataView(customersDataSet.Tables(TestKCustomers))
customersDataView.RowFilter = (Region = France)
D. Dim customersDataView As
New_DataView(customersDataSet.Tables(TestKCustomers))
customersDataView.RowFilter = (Region = France)

Answer: D

 We use the RowFilter property to set the filter of the DataView. We also
take care to use quotes
for the value France.
Note 1: The DataView. RowFilter gets or sets the expression used to filter which rows
are viewed in the
DataView.
Note 2: The DataView.FindRows method returns an array of DataRowView objects
whose columns match the
specified sort key value.
Reference: .NET Framework Class Library, DataView.RowFilter Property [C#]
Incorrect Answers
A: The DataRows method does not update the DataView it just produces a result.
Furthermore, the search
string is incorrect.
B: The DataRows method does not update the DataView it just produces a result.
C: The search string is incorrect. The value must be in quotes.

105.You are developing an application that retrieves a list of geographical regions from
a table in a Microsoft
SQL Server database. The list of regions is displayed in a drop-down list box on a
Windows Form.
You want to populate the list box with data from a DataSet object. You want to fill
the DataSet object by
using a SqlDataAdapter object.
You create a SqlConnection object named TKConnection and a SQL query string
named regionSQL.
You need to write the code to create the SqlDataAdapter object.
Which code segment should you use?
A. Dim myDataAdapter As New SqlDataAdapter()
myDataAdapter.SelectCommand.Connection = TKConnection
myDataAdapter.SelectCommand.CommandText = regionSQL
B. Dim myDataAdapter As New SqlDataAdapter(regionSQL, TKConnection)
C. Dim SqlCmd As New SqlCommand(regionSQL)
Dim myDataAdapter As New SqlDataAdapter()
myDataAdapter.SelectCommand.Connection = TKConnection
myDataAdapter.SelectCommand = SqlCmd
D. Dim SqlCmd As New SqlCommand()
Dim myDataAdapter As New SqlDataAdapter()
SqlCmd.CommandText = regionSQL
myDataAdapter.SelectCommand.Connection = TKConnection
myDataAdapter.SelectCommand = SqlCmd

Answer: B

 The SqlDataAdapter (String, SqlConnection) constructor inintializes a
new instance of the
SqlDataAdapter class with a SelectCommand and a SqlConnection object.
Note: A SQLDataAdapter represents a set of data commands and a database connection
that are used to fill the
DataSet and update a SQL Server database. SqlDataAdapter is used in conjunction with
SqlConnection and
SqlCommand to increase performance when connecting to a Microsoft SQL Server
database.
Reference: .NET Framework Class Library, SqlDataAdapter Members
.NET Framework Class Library, SqlDataAdapter Constructor (String, SqlConnection)
[Visual Basic]
Incorrect Answers
A: This is also a plausible solution. B) is more straightforward.
C, D: First we set the Adapter SelectCommand.Connection to TKConnection. But then
we reset this property
by setting the Adapter.SelectCommand to SqlCmd.

106.You are creating a serviced component named ItemInventory. An online catalog
application will use
ItemInventory to display the availability of products in inventory.
Additional serviced components written by other developers at Contoso will
continuously update the
inventory data as orders are placed.
The ItemInventory class includes the following code segment:
&lt;Transaction(TransactionOption.Required)&gt;<BR> _
Public Class ItemInventory
Inherits ServicedComponent
 Method code goes here.
End Class
ItemInventory is configured to require transactions. You want ItemInventory to
respond to requests as
quickly as possible, even if that means displaying inventory values that are not up to
date with the most
recent orders.
What should you do?
A. To the ItemInventory class, add the following attribute:
&lt;ObjectPooling(True)&gt;<BR>
B. To all methods of the ItemInventory class, add the following attribute:
&lt;AutoComplete(False)&gt;<BR>
C. Modify the Transaction attribute of the ItemInventory class to be the following
attribute:
&lt;Transaction(TransactionOption.Required, Timeout:=1)&gt;<BR>
D. Modify the Transaction attribute of the ItemInventory class to be the following
attribute:
&lt;Transaction(TransactionOption.Required, _
IsolationLevel:=
TransactionIsolationLevel.ReadUncommitted)&gt;<BR>

Answer: D

 The ReadUncommitted transaction isolation level makes a dirty read is
possible, meaning that no
shared locks are issued and no exclusive locks are honored. This will reduce the number
of locks, compared to
the default transaction isolation level of readcommitted. Reduced number of locks will
increase the
performance.
Reference: .NET Framework Class Library, IsolationLevel Enumeration
Incorrect Answers
A: Object pooling is a COM+ service that enables you to reduce the overhead of creating
each object from
scratch. However, object pooling is not much use in transactions.
B: Autocomplete does not apply here.
C: Timeout configuration would not address performance issue.

107.You develop an application that uses a Microsoft SQL Server database and a
SqlClient data provider.
Your application includes the following four code segments which are each called
once:
Dim TKConnection1 As New SqlConnection()
TKConnection1.ConnectionString = Data Source=_
& ProdServer;Initial Catalog=Billing;_
& Integrated Security=true
TKConnection1.Open()
Dim TKConnection2 As New SqlConnection()
TKConnection2.ConnectionString = DataSource=_
& ProdServer;Initial Catalog=Billing;_
& Integrated Security=true
TKConnection2.Open()
Dim TKConnection3 As New SqlConnection()
TKConnection3.ConnectionString = Data Source=_
& SearchServer;Initial Catalog=Search;_
& Integrated Security=true
TKConnection3.Open()
Dim TKConnection4 As New SqlConnection() TKConnection4.ConnectionString =
Data Source= _& ProdServer;Initial
Catalog=OrderEntry; _& Integrated Security=true TKConnection4.Open()
You verify that your application is the only application that is using SQL Server.
Your application runs
all code segments by using the same identity.
You run the application. Connection pooling is enabled, and the entire application
runs within the
connection timeout parameter.
How many connection pools are created?
A. One
B. Two
C. Three
D. Four

Answer: C

 TKConnection1 and TKConnection2 use exactly the same connection
string, while
TKConnection3 and TKConnection4 use separate connections strings. The three separate
connection strings
will create three connections pools-
Note: When a connection is opened, a connection pool is created based on an exact
matching algorithm that
associates the pool with the connection string in the connection. Each connection pool is
associated with a
distinct connection string. When a new connection is opened, if the connection string is
not an exact match to an
existing pool, a new pool is created.
Reference: .NET Framework Developer's Guide, Connection Pooling for the SQL Server
.NET Data Provider
Incorrect Answers
A, B; D: One connection pool will be created for each unique connection strings. Three
unique
connections strings are used, not 1, 2 or 4.

108.You have a strongly typed DataSet object named customersDataSet. This object
contains a single
DataTable object named TestKCustomers. TestKCustomers has an integer data
column named
CustomerID.
You want to access the CustomerID value by using the type-safe code conventions
provided by
customersDataSet. You want to assign the value to a string variable named
customerID.
Which code segment should you use?
A. customerID = customersDataSet.TestKCustomers(0).CustomerID.ToString()
B. customerID =
customersDataSet.TestKCustomers.Columns(CustomerID).ToString()
C. CustomerID =
customersDataSet.Tables(TestKCustomers).Columns(CustomerID).ToStr
ing()
D. customerID = customersDataSet.Tables(TestKCustomers).Rows(0)
(CustomersID).ToString()

Answer: A

 We are ensured type safety if access the columns only by index, and not by
name.
Note: Type-safe code is code that accesses types only in well-defined, allowable ways.
Reference:
Incorrect Answers
B, C, D: We must access the columns only by name.

109.You are creating an XML Web service that will consist of a class named Stock.
Stock will expose the
following public fields:
Symbol, CompanyName, and CurrentPrice.
When serialized by the XMLSerializer, stock will take the following form:
&lt;Stock symbol=&gt;<BR>
&lt;Company /&gt;<BR>
&lt;CurrentPrice /&gt;<BR>
&lt;/Stock&gt;<BR>
You need to construct the Stock class.
Which code segment should you use?
A. Public Class Stock
&lt;XmlElementAttribute(symbol)&gt;<BR>_
Public Symbol As String
&lt;XmlElementAttribute()&gt;<BR>_
Public Company Name As String
Public CurrentPrice As Double
End Class
B. Public Class Stock
Public Symbol As String
&lt;XmlElementAttribute(Company)&gt;<BR>_
Public CompanyName As String
Public CurrentPrice As Double
End Class
C. Public Class Stock
&lt;XmlAttributeAttribute(symbol)&gt;<BR>_
Public Symbol As String
&lt;XmlElementAttribute(Company)&gt;<BR>_
Public CompanyName As String
Public CurrentPrice As Double
End Class
D. Public Class Stock
&lt;XmlAttributeAttribute()&gt;<BR>_
Public Symbol As String
&lt;XmlElementAttribute()&gt;<BR>_
Public CompanyName As String
&lt;XmlElementAttribute()&gt;<BR>_
Public CurrentPrice As Double
End Class

Answer: C

 XmlAttributeAttribute(symbol) specifies that symbol will be
serialized as an XML attribute.
Then we defined a XML element with the XmlElementAttribute(company)
Note: XML serialization is the process of converting an object's public properties and
fields to a serial format,
XML for example, for storage or transport.
Reference: .NET Framework Developer's Guide, Attributes that Control XML
Serialization
Incorrect Answers
A: We should use the XmlAttributeAttribute for symbol.
B: We should use the XmlAttributeAttribute for symbol.
D: Company, not CompanyName, should be defined as an XML element.

109.You are creating a data access component for an XML Web service. You need to
populate and process a
DataSet object with data from a table named Customers in a Microsoft SQL Server
database named
ContosoA.
You write the following code segment:
Dim myConnection As New:
SqlConnection(myConnectionString)
Dim myDataAdapter As New SqlDataAdapter_
(SELECT * FROM Customers, myConnection)
Dim myDataSet As New DataSet()
Dim CustomerName as String
You want to capture all SQL Server errors and general exceptions that occur. You
want to process SQL
Server errors separate from general exceptions.
Which code segment should you use?
A. Try myDataAdapter.Fill(myDataSet, Customers) customerName =
myDataSet.Tables(0)._Rows(0).Item(CustomerName)
Catch mySqlException As SqlException
Throw New SqlException(Sql exception occurred)
Catch myException As Exception
 Code to process general exceptions goes here.
End Try
B. Try myDataAdapter.Fill(myDataSet, Customers)
customerName =myDataSet.Tables(0)._Rows(0).Item(CustomerName)
Catch mySqlException As SqlException
For Each mySqlException In mySqlException.Errors
 Code to process SQL Server errors goes here.
Next
Catch myException As Exception  Code to process general exceptions
goes here.
End Try
C. Try myDataAdapter.Fill(myDataSet, Customers)
customerName = myDataSet.Tables(0)._Rows(0).Item(CustomerName)
Catch mySqlException As SqlException
Dim mySqlError As SqlError
For Each mySqlError In mySqlException.Errors
Code to process SQL Server errors goes here.
Next
Catch myException As Exception
 Code to process general exceptions goes here.
End Try
D. Try myDataAdapter.Fill(myDataSet, Customers) customerName =
myDataSet.Tables(0)._Rows(0).Item(CustomerName)
Catch myException As Exception
Throw New Exception(General exception occurred)
Catch mySqlException As SqlException
Dim mySqlError As SqlError
For Each mySqlError In mySqlExaption.Erros
Code to process SQL Server errors goes here.
Next
End Try

Answer: C

 First we most catch the most specific errors, the SQL Errors. We then use a
general catching of
exceptions.
Note: An SQLException is an exception that is thrown when SQL Server returns a
warning or error.
Reference: .NET Framework Class Library, SqlException Class [Visual Basic]
Incorrect Answers
A: The scenario requires that each SQLServer error must be processed, not just that an
SQLException
occurred.
B: The following statement is incorrect:
For Each mySqlException In mySqlException.Errors
The mySQLException variable should be of SQLSerror type, not SQLException type.
We are processing
SQLErrors, not SQLExceptions.
D: We must catch the SQL errors first.

110.You are developing an application that queries a Microsoft SQL Server database.
The application will
package the results of the query as XML data. The XML data will be retrieved
directly from the
database and transmitted electronically to a business partner.
The query must retrieve all rows and all columns from a database table named
ContosoCustomers.
Which query should you use?
A. SELECT * FROM ContosoCustomers FOR XML AUTO
B. SELECT * FROM XML FROM ContosoCustomers
C. SELECT * FROM ContosoCustomers as XMLDATA
D. SELECT * FROM OPENXML(&lt;ContosoCustomers./Root/Customer, 1) with
(CustomerID
varchar(10))

Answer: A

 You can execute SQL queries against existing SQL Server relational
databases to return results as
XML documents rather than as standard rowsets. To retrieve results directly, use the FOR
XML clause of the
SELECT statement like in this scenario.
Reference: SQL Server 2000 Books Online, Retrieving XML Documents Using FOR
XML
Incorrect Answers
B, C: Incorrect syntax.
D: We should produce XML, not read from a XML data source.

112.You are creating an XML Web service named HousingService that exposed two
Web methods name
SearchHouse and BuyHouses. Prior to deploying the service, you want to customize
the default template
that is displayed when a customer makes a request through the browser.
You create a Web Form named HousingServiceDescription.aspx that is a
customized version of the
default template. You place the Web Form in the bin directory of the
HousingService project.
The Web Form needs to override the default template when a request is made. You
need to ensure that
customers who request HousingService though a browser view
HousingServiceDescription.aspx.
What should you do?
A. Create a SOAP extension to redirect the user to HousingServiceDescription.aspx.
B. Set the Namespace property of the WebService attribute to the location of
HousingServiceDescription.aspx.
C. In the Web.config file, enable tracing and the set TraceMode node to
bin\HousingServiceDescription.aspx.
D. In the Web.config file, set the HRef property of the wsdlHelpGenerator node to
bin\HousingServiceDescription.aspx.

Answer: D

 The wsdlHelpGenerator element specifies the XML Web service Help
page (an .aspx file) that is
displayed to a browser when the browser navigates directly to an ASMX XML Web
services page
Reference: .NET Framework General Reference, &lt;wsdlHelpGenerator&gt;<BR> Element
Incorrect Answers
A: Soap extensions are used to inspect or modify a message at specific stages in message
processing on either
the client or the server. It is not useful here.
B: We are not interested in defining a name space.
C: We are not interested in enabling tracing.

113.You have a SqlDataReader object named productsDataReader. The
productsDataReader object contains
three columns in the following order:
 ProductID as Integer
 ProductName as nvarchar(40)
 UnitsInStock as Integer
You want to use productsDataReader to create an inventory management report.
You define the
following three variables:
 TKProductID as Integer
 TKProductName as String
 TKUnits as Integer
You need to ensure that the report runs as quickly as possible.
Which code segment should you use?
A. TKProductID = productsDataReader.Item(1)
TKProductName = productsDataReader.Item(2)
TKUnits = productsDataReader.Item(3)
B. TKProductID = productsDataReader.Item(0)
TKProductName = productsDataReader.Item(1)
TKUnits = productsDataReader.Item(2)
C. TKProductID = productsDataReader.Item(ProductID)
TKProductName = productsDataReader.Item(ProductName)
TKUnits = productsDataReader.Item(UnitsInStock)
D. TKProductID = productsDataReader.GetName(ProductID)
TKProductName = productsDataReader.GetName(ProductName)
TKUnits = productsDataReader.GetName(UnitsInStock)

Answer: B

 We should use ordinal-based lookups since they are more efficient than
named lookups. Column
ordinals are zero-based: TKProductId has ordinal number 0, TKProductName has ordinal
number 1, and
TKUnits has ordinal number 2.
Reference: .NET Framework Class Library, SqlDataReader.GetOrdinal Method [Visual
Basic]
Incorrect Answers
A: Column ordinals are zero-based, not one-based.
C: Ordinal-based lookups are more efficient than named lookups.
D: The DataReader.GetOrdinal method gets the column ordinal, given the name of the
column. We are not
interested in the Ordinal numbers. They should only be used to speed up the process.

114.You are developing an application that receives product information from external
vendors in the form
of XML documents. The information will be stored in a Microsoft SQL Server
database ContosoSrv.
The application must validate all incoming XML data. It uses an
XmlValidatingReader object to read
each XML document. If any invalid sections of XML are encountered, the
inconsistencies are listed in a
single document.
You must ensure that the validation process runs as quickly as possible.
What should you do?
A. Set the ValidationType property of the XmlValidatingReader object to Schema.
B. Set the CanResolveEntity property of the XmlValidatingReader object to True.
C. Create and register a ValidationEventHandler method.
D. Use a try/catch block to catch validation exceptions.

Answer: C

 There are two exception events that can occur during schema validation:
warnings and errors. To
handle errors and warnings, the Schema Object Model (SOM) supports the use of a
ValidationEventHandler
delegate, which is a callback that you design. This callback is called when an error or
warning occurs during
validation.
Reference: .NET Framework Developer's Guide, Validation and the Schema Object
Model [Visual Basic]
Incorrect Answers
A: The ValidationType Schema validates according to XSD schemas. However, there is
no schema in this
scenario. Furthermore, we must provide a mechanism that handles the errors.
B: The XmlReader.CanResolveEntity Property is read-only.
Note: CanResolveEntity Property gets a value indicating whether this reader can parse
and resolve entities.
D: It would be very awkward to use try/catch blocks. It would be less effective as well.

115.You are creating a serviced component named TravelItinerary. TravelItinerary
included the following
code segment:
&lt;Transaction(TransactionOption.Required)&gt;<BR>
Public Class TravelItinerary
Inherits ServicedComponent
&lt;AutoComplete()&gt;<BR>_
Public Function SaveIntinerary(ByVal travelData_As DataSet) As DataSet
Dim airline As New AirlineServer.AirlineService()
Dim hotel As New HotelServer.HotelService()
airline.ReserveFlight(travelData)
Code to record reservation in database goes here.
hotel.ReserveHotel(travelData)
Code to record reservation in database goes here.
Return travelData
End Function
End Class
The TransactionOption property of both ReserveFlight and ReserveHotel is set to
TransactionOption.Required.
You create an application to test TravelItinerary. When the test application is run,
an exception is
thrown in HotelService.
How are transactions in TravelItinerary and in each Web service affected by this
exception?
A. All transactions are rolled back.
B. Transactions in only HotelService are rolled back.
Transactions in only TravelItinerary and AirlineService remain committed.
C. Transactions in only HotelService and TravelItinerary are rolled back.
Transactions in only AirlineService remain committed.
D. Transactions in only AirlineService and TravelItinerary are rolled back.
Transactions in only HotelService remain committed.

Answer: B

 Each XML Web service method participates in their own transaction, only
the HotelService
transaction is rolled backed.
Note: If an XML Web service method, with a TransactionOption property of Required or
RequiresNew invokes
another XML Web service method with a TransactionOption property of Required or
RequiresNew, each XML
Web service method participates in their own transaction, because an XML Web service
method can only act as
the root object in a transaction.
Reference: .NET Framework Class Library, WebMethodAttribute.TransactionOption
Property
Incorrect Answers
A, C; D: Only the HotelService transaction is rolled backed.

116.You are developing an application that loads two DataReader objects from a
Microsoft SQL Server
database ContosoSales. The DataReader objects are named customersDataReader
and
productsDataReader.
The customersDataReader object is loaded from the Customers table. The
productsDataReader object is
loaded from the Products table.
You create a SqlCommand object named myCommand and a SqlConnection object
named
myConnection. You write the following code segment. (Line numbers are included
for reference only.)
01 myCommand.Connection = myConnection
02 Dim CustomersDataReader As SqlDataReader
03 Dim productsDataReader As SqlDataReader
04 myCommand.CommandText = SELECT * FROM Customers
05 myConnection.Open()
06 customersDataReader = myCommand.ExecuteReader
07  Code to process the data reader goes here
08  Insert new code.
09 myCommand.CommandText = SELECT * FROM Products
10 productsDataReader = myCommand.ExecuteReader
11  Code to process the data reader goes here.
You run the application and an exception is thrown on line 10. To correct the
problem, you need to insert
additional code on line 08.
Which code segment should you use?
A. myCommand.ResetCommandTimeout()
B. myCommand.Dispose()
C. customersDataReader.NextResult()
D. customersDataReader.Close()

Answer: D

 You should always call the Close method when you have finished using
the DataReader object.
While a DataReader is open, the Connection is in use exclusively by that DataReader.
You will not be able to
execute any commands for the Connection, including creating another DataReader, until
the original
DataReader is closed.
Reference: .NET Framework Developer's Guide, Retrieving Data Using the DataReader
[Visual Basic]
Incorrect Answers
A: Resetting the CommandTimouot to it is default value will not change anything. It has
already the default
value.
B: The SqlConnection.Dispose method releases the unmanaged resources used by the
SqlConnection and
optionally releases the managed resources.
C: The SQLCommand.Nextresult method advances the data reader to the next result,
when reading the results
of batch Transact-SQL statements.

117.You are creating an XML Web service named TKHealthInfo. TKHealthInfo
exposed patient health
records for your client customers. To the beginning of each TKHealthInfo method,
you add the following
code segment:
Dim uiPerm As New UIPermission(_
UIPermissionWindow.AllWindows,_
UIPermissionClipboard.AllClipboard)
Dim filePerm As New FileIOPermission(_
PermissionState.None)
filePerm.AllFiles = FileIOPermissionAccess.AllAccess
As one part of making HealthInfo as secure as possible, you must ensure that the
HealthInfo Web
methods do not perform any file I/O or access the user interface.
Which code segment should you use?
A. uiPerm.Deny() filePerm.Deny()
B. uiPerm.Deny() uiPerm.RevertAssert() filePerm.Deny()
C. uiPerm.Deny() uiPerm.RevertDeny() filePerm.Deny()
D. Dim permSet As New PermissionSet(_PermissionState.None)
permSet.AddPermission(uiPerm) permSet.AddPermission(filePerm)
permSet.Deny()

Answer: D

 We should add permission for uiPerm. We allow access to Windows
windows and user input
events and permit use of the Clipboard: permSet.AddPermission(uiPerm)
Then we deny filepermission: permSet.AddPermission(filePerm)
Note: AllWindows allows users to use all windows and user input events without
restriction.
AllClipBoard allows clipboard to be used without restriction.
Reference: .NET Framework Class Library, UIPermissionWindow Enumeration [Visual
Basic]
.NET Framework Class Library, UIPermissionClipboard Enumeration [Visual Basic]
Incorrect Answers
A, B; C: We should not deny access to Windows and user input or to the clipboard. The
code uiPerm.Deny()
should not be used.

118.You create an XML Web service project named LocalizationService.
LocalizationService consists of two
XML Web services named ContentService and UserService. Each service contains a
Web method named
Save.
The Web method signatures are shown in the following code segments:
 &lt;WebMethod ()&gt;<BR> Public Function Save(ByVal contentInfo As DataSet)As
DataSet
 &lt;WebMethod()&gt;<BR> Public Function Save(ByVal userInfo As DataSet) As
DataSet
You are developing an ASP.NET application that will consume LocalizationService.
You add a Web
reference to the services. You discover that UserService is missing from the
resulting proxy class that is
generated by Visual Studio .NET. You need to correct the problem in
LocalizationService.
What should you do?
A. Set the Name property of the WebService attribute on ContentService and
UserService to a unique
name.
B. Set the NameSpace property of the WebService attribute on ContentService and
UserService to a unique
URI.
C. Set the Description property of the WebMethod attribute on ContentService and
UserService to a unique
description.
D. Set the MessageName property of the WebMethod attribute on ContentService and
UserService to a
unique message name.

Answer: B

 Because the TargetNamespace is supposed to be a unique identifier for a
particular XML
document, which in this case is the XML schema, Wsdl.exe assumes that the two XML
schemas are identical.
In doing so, Wsdl.exe builds a class for just one of the schemas. If this is not the intended
result, the
TargetNamespace for each XML schema must be changed to a unique URI.
Reference: .NET Framework Developer's Guide, Creating an XML Web Service Proxy
Incorrect Answers
A: Unique names are not required. Furthermore, this would change the functionality.
C: Changing the Description property would not achieve much.
D: The MessageName property can be used to alias method or property names. However,
the present problem
is that only one proxy class is generated.

119.You create an XML Web service named ReportService for an application on
Contosos intranet. You
configure Internet Information Services (IIS) and ReportService to use Integrated
Windows
authentication.
You configure the Access Control List (ACL) for ReportService to allow access to
only members of a
Windows group named FieldAgents. You test and confirm that only members of the
FieldAgents group
can use ReportService.
ReportService includes a method named SubmitSurveillance that calls a serviced
component named
ReportData. ReportData uses COM+ role-bases security to restrict component
access to members of the
COM+ Agents role. The COM+ Agents role is configured to include the FieldAgents
group.
You call SubmitSurveillance. However, when the call to ReportData is attempted,
an exception is thrown
indicating that access is denied. You need to correct this problem.
What should you do?
A. In IIS, enable Anonymous access.
B. In the &lt;system.web&gt;<BR> section of the Web.config file, add the following line of code:
&lt;identity impersonate=true/&gt;<BR>
C. In the &lt;system.web&gt;<BR> section of the Web.config file, add the following line of code:
&lt;identity impersonate=false/&gt;<BR>
D. In the &lt;system.web&gt;<BR> section of the Web.config file, add the following line of code:
&lt;authentication mode=None/&gt;<BR>

Answer: B

 We must allow impersonation to allow the COM+ Agents role to be used,
if they the FieldAgent
group is running the ReportService.
Note: Impersonation is when ASP.NET executes code in the context of an authenticated
and authorized client.
Reference: .NET Framework General Reference, &lt;identity&gt;<BR> Element
Incorrect Answers
A: Anonymous access would be a security risk.
C: We should allow, not deny, impersonation.
D: Authentication mode none, specifies that no authentication. Only anonymous users are
expected.

120.You have a SqlDataReader object named ordersDataReader. This object contains a
column named
OrderQuantity as an integer value. This object also contains one row for each order
received during the
previous week.
You need to write code that will process each row in ordersDataReader and pass
OrderQuantity to a
function named TKFunction.
Which code segment should you use?
A. While ordersDataReader.Read Call
TKFunction(ordersDataReader(OrderQuantity)) End While
B. While ordersDataReader.NextResult Call
TKFunction(ordersDataReader(OrderQuantity)) End While
C. Dim orderCount as Integer While orderCount &lt;
ordersDataReader.FieldCount Call
TKFunction(ordersDataReader(OrderQuantity)) orderCount += 1
ordersDataReader.Read End While
D. Dim orderCount as Integer While orderCount &lt;
ordersDataReader.FieldCount Call
TKFunction(ordersDataReader(OrderQuantity)) orderCount += 1
ordersDataReader.NextResult End While

Answer: A

 The SqlDataReader.Read method advances the SqlDataReader to the next
record. The return
value is true if there are more rows; otherwise, false. We can therefore use it as the
condition in the while loop.
Reference: .NET Framework Class Library, SqlDataReader.Read Method [Visual Basic]
Incorrect Answers
B: SqlDataReader.NextResult method advances the data reader to the next result, when
reading the results of
batch Transact-SQL statements. There is not a batch of Transact SQL statements in this
scenario however.
C, D: The SqlDataReader.FieldCount property gets the number of columns in the current
row. It would be
incorrect to use this value in the condition expression for the while loop.

121.Your Microsoft SQL Server database contains a table named ContosoCustomers.
ContosoCustomers
contains three columns named FamilyName, PersonalName, and Address.
You instantiate a SqlCommand object named myCommand that you will use to
populate a DataReader
object named customersDataReader. You need to initialize myCommand to load
customersDataReader
to include FamilyName and PersonalName for all rows in ContosoCustomers.
Which code segment should you use?
A. myCommand.CommandText = SELECT FamilyName, & PersonalName FROM
ContosoCustomers
B. myCommand.CommandType = SELECT FamilyName, & PersonalName FROM
ContosoCustomers)
C. myCommand.Parameters.Add(SELECT FamilyName, & PersonalName FROM
ContosoCustomers)
D. myCommand.ExecuteNonQuery()

Answer: A

 The CommandText property gets or sets the Transact-SQL statement or
stored procedure to
execute at the data source. We should use it to set the SQL command we want to be
executed.
Reference: .NET Framework Class Library, SqlCommand Members
Incorrect Answers
B: The CommandType property gets or sets a value indicating how the CommandText
property is to be
interpreted.
C: The parameters should include the SQL code.
D: We must the SQL Statements before we execute them.

122.You are creating an XML Web service named TKFlightService that provides flight
information to its
users. To retrieve flight information, a user first must be authenticated by
FlightService. Once
authenticated, a key that identifies that user is returned to the caller. This key then
will be presented in
the SOAP header on all subsequent flight information requests to validate that user.
You need to construct TKFlightService so that it can receive the key in a SOAP
header. First, you add a
class to TKFlightService by writing the following code segment:
Public Class UserKeyHeader
Inherits SoapHeader
Public key As String
End Class
Next, you add a Web method to TKFlightService by writing the following code
segment:
Public keyHeader As UserKeyHeader
&lt;WebMethod(), SoapHeader()&gt;<BR>_
Public Function RetrieveFlightInformation() As DataSet
Code to check SOAP header goes here.
Code to retrieve flight information goes here.
End Function
You attempt to build TKFlightService, and discover that it does not compile. You
need TKFlightService
to compile.
What should you do?
A. Change the declaration of the keyHeader variable from public to private.
B. Set the memberName parameter of the SoapHeader attribute to keyHeader.
C. Set the Direction property of the SoapHeader attribute to SoapHeaderDirection.In.
D. Set the Direction property of the SoapHeader attribute to SoapHeaderDirection.Out.

Answer: B

 In order for the XML Web service method to receive the contents of the
SOAP header, a member
is added to the XML Web service class of a type derived from SoapHeader. The
SoapHeaderAttribute.MemberName contains the member of the XML Web service class
representing the
SOAP header contents.
Reference: .NET Framework Class Library, SoapHeaderAttribute.MemberName
Property
Incorrect Answers
A: Changing the declaration of keyHeader variable does not achieve much.
C, D: TheSoapHeaderAttribute.Direction property gets or sets whether the SOAP header
is intended for the
XML Web service or the XML Web service client or both. This attribute is not the reason
of the compile
error.

123.You Microsoft SQL Server database named ContosoBackOrders that contains a
table that consists of
more than 1 million rows. You need to develop an application that reads each row in
the table and writes
the data to a flat file. The application will run only once each day. You want the
application to process
the data as quickly as possible.
Which class should you use to retrieve the data?
A. DataSet
B. DataTable
C. DataReader
D. DataAdapter

Answer: C

 The ADO.NET DataReader is used to retrieve a read-only, forward-only
stream of data from a
database. Using the DataReader can increase application performance and reduce system
overhead because only
one row at a time is ever in memory. DataReader would meet the requirements of this
scenario.
Reference: .NET Framework Developer's Guide, Retrieving Data Using the DataReader
[Visual Basic]
Incorrect Answers
A: Datasets is used when you want to work with a set of tables and rows while
disconnected from the data
source. It would not be optimal when accessing the amount of data in this scenario.
Furthermore, only readforward
access is required.
B: A Data table represents one table of in-memory data.
D: The DataAdapter serves as a bridge between a DataSet and a data source for retrieving
and saving data.

124.Your Microsoft SQL Server database has a stored procedure that sums the total
number of orders
received each day. The stored procedure returns a result that is a single data value
of type integer.
You need to write code that will execute the stored procedure and return the result
as an integer value.
You instantiate a SqlCommand object named TestKCommand and initialize all
appropriate parameters.
Which TestKCommand method should you use?
A. ExecuteReader
B. ExecuteNonQuery
C. ExecuteScalar
D. ExecuteXMLReader

Answer: C

125.Your Microsoft SQL Server database contains a table named Regions. Regions
contains all the sales
regions of a sales-tracking application.
You create a DataSet object named regions DataSet by using a SqlDataAdapter
object named
TKDataAdapter. This object uses a single SQL SELECT statement to populate the
regionsDataSet. You
bind regionsDataSet to a DataGrid object named regionsDataGrid to display the
contents of Regions.
You now want to use the same regionsDataSet, TKDataAdapter, and
regionsDataGrid to insert, update,
and delete data in Regions.
You want to accomplish this task by writing the minimum amount of code.
What should you do?
A. Instantiate a SqlCommandBuilder object that has TKDataAdapter as a constructor
argument.
Add an Update button to the form and add code to the Click event to update
regionsDataSet by using
TKDataAdapter.
B. Instantiate a SqlCommandBuilder object that has TKDataAdapter as a constructor
argument.
Create one stored procedure for each of the insert, update, and delete functions and
associate the stored
procedures with the InsertCommand, UpdateCommand, and DeleteCommand properties
of
TKDataAdapter.
Add an Update button to the form and add code to the Click event to update
regionsDataSet by using
TKDataAdapter.
C. Create one stored procedure for each of the insert, update, and delete functions and
associate the stored
procedures with the InsertCommand, UpdateCommand, and DeleteCommand properties
of
TKDataAdapter.
Add an Update button to the form and add code to the Click event to update
regionsDataSet by using
TKDataAdapter.
D. Create one SQL string for each of the insert, update, and delete functions and associate
the SQL strings
with the InsertCommand, UpdateCommand, and DeleteCommand properties of
TKDataAdapter.
Add an Update button to the form and add code to the Click event to update
regionsDataSet by using
TKDataAdapter.

Answer: A

126.You have a DataSet object named ordersDataSet. This object contains two
DataTable objects named
Orders and OrderDetails. Both Orders and OrderDetails contain a column named
OrderID.
You create a DataRelation object named orderRelation between Orders and
OrderDetails on OrderID.
Order is the parent table. OrderDetails is the child table.
You add orderRelation to the ordersDataSet relation collection by using the
following line of code:
ordersDataSet.Relations.Add(orderRelation;
You verify that prior to adding orderRelation, there were no constraints on either
table. You then run
the line of code.
How many constraints does each table have now?
A. One on Orders; none on OrderDetails.
B. None on Orders; one on OrderDetails.
C. None on Orders; none on OrderDetails.
D. One on Orders; one on OrderDetails.

Answer: D

127.You create a collection of serviced components that performs bank transfers. All the
components are
marked with the Transaction(TransactionOption.Required) attribute. All the
methods in the components
are marked with the AutoComplete() attribute.
You discover that incorrect balance amounts are being transferred. You decide to
debug the components.
During debugging, a System.Runtime.InteropServices.COMException is thrown.
The HRESULT for the
exception is 0x8004E002. The exception includes the following message: The root
transaction wanted to
commit but transaction aborted.
You find that this exception occurs only during the debugging session, and not when
the components run
outside of the debugger. This exception is preventing you from continuing to debug
the components. You
need to resolve this problem.
What should you do?
A. Remove the AutoComplete attribute from each method.
Within each method implementation, add calls to the ContextUtil.SetComplete() and
ContextUtil.SetAbort() methods.
B. Remove the AutoComplete attribute from each method.
Within each method implementation, add calls to the ContextUtil.MyTransactionVote
and
ContextUtil.DeactivateOnReturn properties.
C. Increase the transaction timeout in the Component Services tool by using the
Properties dialog box for
My Computer.
D. Replace each method implementation with the following segment:
try { // Existing method body goes here. }
Finally { ContextUtil.SetComplete() }

Answer: C

128.You create a strongly named serviced component. The component uses a third-party
.NET assembly
named Contoso.Encryptor.dll to perform encryption and decryption.
Contoso.Encryptor.dll is
registered in the global assembly cache. You deploy the services component and
Contoso.Encryptor.dll
to a production computer.
A new version of Contoso.Encryptor.dll becomes available. You remove the original
version and install
the new version on the production computer. The services component throws a
System.TypeLoadException when it attempts to use Contoso.Encryptor.dll.
You need to correct this problem.
What should you do?
A. Unregister and re-register the services component in the global assembly cache.
B. Use the Strong Name tool (Sn.exe) to create a new key file for the services
component.
C. Create a configuration file named Dllhosts.exe config to redirect the services
component to the new
version of Contoso.Encryptor.dll.
D. Create a publisher policy assembly for Contoso.Encryptor.dll and register the
assembly in the global
assembly cache.

Answer: D

 Vendors of assemblies can state that applications should use a newer
version of an assembly by
including a publisher policy file with the upgraded assembly. The publisher policy file
specifies assembly
redirection and code base settings, and uses the same format as an application
configuration file. The publisher
policy file is compiled into an assembly and placed in the global assembly cache.
There are three steps involved in creating a publisher policy:
1. Create a publisher policy file.
2. Create a publisher policy assembly.
3. Add the publisher policy assembly to the global assembly cache.
Reference: .NET Framework Developer's Guide, Creating a Publisher Policy File

129.You create an assembly that contains a collection of serviced components. You want
to secure these
components by using a collection of COM+ roles. Different groups of roles will
secure different
components.
You need to ensure that role-based security is enforced in the assembly. You want to
accomplish this goal
by adding an attribute to the project source code.
Which attribute should you use?
A. [assembly: SecurityRole(Assembly, true)]
B. [assembly:
SecurityPermission(SecurityAction.RequestOptional)]
C. [assembly:
ApplicationActivation(ActivationOption.Server)]
D. [assembly: ApplicationAccessControl(AccessChecksLevel =
AccessChecksLevelOption.ApplicationComponent)]

Answer: D

 ApplicationComponent enables access checks at every level on calls into
the application.
Reference: .NET Framework Developer's Guide, Registering Serviced Components
Incorrect Answers
A: This allows a role named assembly access. It also allows everyone access. This does
not make much sense.
B: We dont want to configure permission for additional functionality.
C: Server specifies that serviced components in the marked application are activated in a
system-provided
process.

130.You create a services component named OrderStatus that is in an assembly named
ContosoOrders.
OrderStatus is in its own COM+ application named ContosoApp.
OrderStatus is used by multiple client applications to look up the status of orders.
Because you anticipate
that client applications will frequently access OrderStatus, you need to ensure that
the method calls are
processed as quickly as possible.
What should you do?
A. Configure OrderStatus to require a transaction.
B. Configure ContosoApp to be a library application.
C. Add the AutoComplete attribute to all methods in OrderStatus.
D. Configure ContosoOrders to be a shared assembly, and install it in the global assembly
cache.

Answer: B

131.You have a .NET Remoting object named TKScheduler. The TKScheduler class is
in an assembly file
named TaskScheduler.dll. The TKScheduler class is hosted by an application
named
SchedulerServer.exe. This application is configured by using a file named
SchedulerServer.exe config.
This file configures the TKScheduler class to be a client-activated object by using a
TcpChannel and a
BinaryFormatter.
You want to deploy the TKScheduler object to a computer named Contoso1 so that
client applications
can begin to use it.
You copy TKTaskScheduler.dll, SchedulerServer.exe, and
SchedulerServer.exe.config to a directory on
Contoso1.
What should you do next?
A. Install TKTaskScheduler.dll in the global assembly cache.
B. Use the Assembly Registration tool (Regasm.exe) on Contoso1 to register
SchedulerServer.exe.
C. Use the Assembly Registration tool (Regasm.exe) on Contoso1 to register
TKTaskScheduler.dll.
D. Configure Contoso1 to execute SchedulerServer.exe each time Contoso1 is restarted.
Then manually execute SchedulerServer.exe on Contoso1.

Answer: D

132.You are creating an XML Web service named WeatherService that provides the
current weather
conditions for cities around the world. Your development cycle includes three
stages: development,
testing, and production. In each stage, WeatherService will be deployed on a
different server.
For testing, you create an ASP.NET application named WeatherTest. To
WeatherTest, you add a Web
reference to WeatherService. You then build a user interface and add the necessary
code to test the
service.
The WeatherService interface will not change between testing and deployment. You
want to ensure that
you do not have to recompile WeatherTest every time WeatherService is moved
from one server to
another.
What should you do?
A. Each time WeatherService is moved, set the URL property of the generated proxy
class to the new
location.
B. Each time WeatherService is moved, set the Web Reference URL property of the
generated proxy class
to the new location.
C. Set the URLBehavior property of the generated proxy class to dynamic.
Each time WeatherService is moved, update the appropriate key in the Web.config file to
indicate the
new location.
D. Take the location of WeatherService as input to WeatherTest, and set the Proxy
property of all proxy
class instances to that location.

Answer: C

133.You create an XML Web service named WeatherService. This service contains a
Web method named
RetrieveWeather. RetrieveWeather takes as input a city named and returns the
current weather
conditions for that city.
You need to provide callers of this service with the URL they need to issue an
HTTP-GET against
WeatherService.
Which URL should you use?
A. http://ContosoSrv/AppPath/WeatherService.asmx/cityname=somecity
B.
http://ContosoSrv/AppPath/WeatherService.asmx/RetrieveWeather?cityname=somecity
C.
http://ContosoSrv/AppPath/WeatherService/RetreieveWeather.asmx?cityname=somecity
D. http://ContosoSrv/AppPath/WeatherService/RetrieveWeather?cityname=somecity

Answer: B

134.You work as a Software developer at Contoso Inc. You are creating a Visual Studio
.NET assembly,
which will run as a shared assembly with other applications. The assembly will be
installed in the global
assembly cache. You will distribute the assembly to many customers outside
Contoso.
You must ensure that each customer receives your assembly without alteration, in a
way that reliably
specifies the origin of the code.
What should you do?
A. Sign the assembly by using a string name.
Do nothing further.
B. Sign the assembly by using File Signing tool (Signcode.exe).
Do nothing further.
C. First sign the assembly by using a strong name.
Then sign the assembly by using File Signing tool (Signcoe.exe).
D. First sigh the assembly by using File Signing tool (Signcode.exe).
Then sign the assembly by using a strong name.

Answer: C