Errata

MCTS Self-Paced Training Kit (Exam 70-536): Microsoft® .NET Framework 2.0—Application Development Foundation

Errata for MCTS Self-Paced Training Kit (Exam 70-536): Microsoft® .NET Framework 2.0—Application Development Foundation

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Printed
Page CD-ROM

Assessment answer should include ICollection and not IDictionaryEnumerator
In the Readiness Review assessment on the CDROM one of the questions reads:



"You are creating a new collection type that must be iterated using for-each loop. Which of the following interfaces should you implement? (Choose all that apply)

ICollection

IDictionaryEnumerator

IDictionary

IEnumerable

IEqualityCOmparer"



The assessment states that the answers are IDictionaryEnumerator and IEnumerator.



The correct answers are:



ICollection and IEnumerator.

Microsoft Press  Jul 13, 2010 
Printed
Page CD-ROM

lesson3-exercise1-Person-partial code samples are missing from Chapter01 folder
The Visual Basic and C# code samples "lesson3-exercise1-Person-partial" are missing from the CodeChapter01 folder. The folders and files are available for download from the Microsoft Download Center:



lesson3.exe (http://download.microsoft.com/download/c/d/a/cda2e6ee-9334-4dd9-901f-92be283d13b2/lesson3.exe)

Microsoft Press  Jul 13, 2010 
Printed

Page 100, Incorrect basic functionality description of StreamWriter class
On page 100, the first sentence of the first paragraph reads:



"The StreamWriter class provides the basic functionality to read data from a Stream derived class."



It should read:



"The StreamWriter class provides the basic functionality to write data from a Stream derived class."

Microsoft Press  Jul 13, 2010 
Printed
Page 3

System.Value referenced rather than System.ValueType
On page 3, the first sentence after the first bulleted list reads:



"Each of these types is derived from the System.Value base type."



It should read:



"Each of these types is derived from the System.ValueType base type."

Microsoft Press  Jul 13, 2010 
Printed
Page 5

4 should be 1
On page 5, the Bytes column of the second row of Table 1-2 is incorrect.



Change:

"4"



To:

"1"

Microsoft Press  Jul 13, 2010 
Printed
Page 12

Term "defines" used in place of "initializes" in step 4
On page 12, the first sentence of step 4 reads:"Create a constructor that defines all three member variables, as the following

code demonstrates:"It should read:"Create a constructor that initializes all three member variables, as the following

code demonstrates:"

Microsoft Press  Jul 13, 2010 
Printed
Page 18

The word "variable" is missing from the final sentence
On page 18, the last sentence on the page reads:



"When you modify a reference type, you modify all copies of that reference type."



It should read:



"When you modify a reference type variable, you modify all copies of that reference type variable."

Microsoft Press  Jul 13, 2010 
Printed
Page 25

Incorrect code in C# example
On page 25, the first three lines of the VB code sample read:



Dim sr As StreamReader = New StreamReader("text.txt")

Try

Console.WriteLine(sr.ReadToEnd)They should read:



Dim sr As StreamReader

Try

sr = New StreamReader("text.txt")

Console.WriteLine(sr.ReadToEnd)"



The first three lines of the C# code sample read:"StreamReader sr = new StreamReader("text.txt");

try

{

Console.WriteLine(sr.ReadToEnd());"







They should read:



"StreamReader sr;

try

{

sr = new StreamReader("text.txt");

Console.WriteLine(sr.ReadToEnd());

Microsoft Press  Jul 13, 2010 
Printed
Page 47

"Guide" used in place of "Guid"
On page 47, the first sentence of the second paragraph from the bottom contains an incorrect attribute.



Change:



"Visual Studio automatically creates some standard attributes for your assembly when you create a project, including a title, description, company, guide, and version."



To:



"Visual Studio automatically creates some standard attributes for your assembly when you create a project, including a title, description, company, guid, and version."

Microsoft Press  Jul 13, 2010 
Printed
Page 49

VB code sample missing Person class
On page 49, the second VB code sample near the bottom of the page is missing "Inherits Person".



Change:

' VB

Class Manager

End ClassTo:

' VB

Class Manager : Inherits Person

End Class

Microsoft Press  Jul 13, 2010 
Printed
Page 52

"progressBar" used in place of "progressBar1" in code sample
On page 52, a 1 needs to be added to "progressBar" in the first C# code sample at the top of the page.



Change:



// C#

void t_Tick(object sender, EventArgs e)

{

progressBar.Value += 10;

if (progressBar.Value >= 100)

t.Stop();

}To:



// C#

void t_Tick(object sender, EventArgs e)

{

progressBar1.Value += 10;

if (progressBar1.Value >= 100)

t.Stop();

}

Microsoft Press  Jul 13, 2010 
Printed
Page 58

Incorrect index used in the second code sample
On page 58, the last line of the second VB code sample reads:



Console.WriteLine("a = {0}, i = {0}", a.ToString, i.ToString)It should read:



Console.WriteLine("a = {0}, i = {1}", a.ToString, i.ToString)The last line of the C# code sample reads:



Console.WriteLine("a = {0}, i = {0}", a.ToString(), i.ToString());It should read:



Console.WriteLine("a = {0}, i = {1}", a.ToString(), i.ToString());

Microsoft Press  Jul 13, 2010 
Printed
Page 63

"narrowing" used in place of "widening"
On page 63, the third sentence of the first paragraph reads:



"C# allows implicit conversion for only narrowing conversions, where no information could be lost."



It should read:



"C# allows implicit conversion for only widening conversions, where no information could be lost."

Microsoft Press  Jul 13, 2010 
Printed
Page 73

string should be DirectoryInfo object
On page 73, the Description of Root in Table 2-5 is incorrect.



Change:

"Gets the root part of the directory’s path as a string"



To:

"Gets the root part of the directory’s path as a DirectoryInfo object"

Microsoft Press  Jul 13, 2010 
Printed
Page 76

Unknown member description is missing the word "type"
On page 76, the description of the Unknown member in Table 2-9 reads:



"The drive could not be determined."



It should read:



"The drive type could not be determined."

Microsoft Press  Jul 13, 2010 
Printed
Page 81

The term "Added" is used in place of "Created, Deleted"
On page 81, the first sentence of the second paragraph reads:



"In addition to using the Added and Changed events, you can monitor the system for renamed files."



It should read:



"In addition to using the Created, Deleted and Changed events, you can monitor the system for renamed files."

Microsoft Press  Jul 13, 2010 
Printed
Page 83

The term "include" used in place of "using" in Step 2
On page 83, step 2 reads:"Add an Import (or an include in C#) for the System.IO namespace into the new project."



It should read:



"Add an Import (or aa using statement in C#) for the System.IO namespace into the new project."

Microsoft Press  Jul 13, 2010 
Printed
Page 85

EnableRaisingEvents property referred to as EnablingRaisingEvents
On page 85, step 7 reads:



"Set the EnablingRaisingEvents property to true to tell the watcher object to start throwing events."



It should read:



"Set the EnableRaisingEvents property to true to tell the watcher object to start throwing events."

Microsoft Press  Jul 13, 2010 
Printed
Page 91

Suggestion that files can be created when read
On page 91, the first bullet point reads:



"Operations to create or open files for reading"



It should read:



"Operations to open files for reading"

Microsoft Press  Jul 13, 2010 
Printed
Page 92

Description of OpenWrite method is incorrect
On page 92, the Description for the OpenWrite method reads:



"Opens an existing file for writing and returns a StreamWriter object."



It should read:



"Opens an existing file for writing and returns a FileStream object."

Microsoft Press  Jul 13, 2010 
Printed
Page 111

The term "include" used in place of "using" in Step 2
On page 111, step 2 reads:"Add an Import (or an include in C#) for the System.IO namespace into the new project."



It should read:



"Add an Import (or aa using statement in C#) for the System.IO namespace into the new project."

Microsoft Press  Jul 13, 2010 
Printed
Page 112

Class referred to in place of object
On page 112, step 2 of Exercise 2 reads:



"In the Main method after the StreamWriter class is closed, open the file using the OpenText method of the File class to create a new StreamReader object."



It should read:



"In the Main method after the StreamWriter object is closed, open the file using the OpenText method of the File class to create a new StreamReader object."

Microsoft Press  Jul 13, 2010 
Printed
Page 120

CompressionMode.Compress used in place of CompressionMode.Decompress
On page 120, the first full code sample read:



' VB

Dim compStream As _

New GZipStream(sourceFile, CompressionMode.Compress)



// C#

GZipStream compStream =

new GZipStream(sourceFile, CompressionMode.Compress);It should read:



' VB

Dim compStream As _

New GZipStream(sourceFile, CompressionMode.Decompress)



// C#

GZipStream compStream =

new GZipStream(sourceFile, CompressionMode.Decompress);

Microsoft Press  Jul 13, 2010 
Printed
Page 121 & 122

Code samples are incorrect for Step 7
On pages 121 & 122, Exercise 1, Step 7, the VB and C# code samples are incorrect. When used in the exercise, they do not create a smaller compressed file.



Change:



' VB

Dim theByte As Integer = sourceFile.ReadByte()

While theByte <> -1

compStream.WriteByte(CType(theByte, Byte))

theByte = sourceFile.ReadByte()

End While



// C#

int theByte = sourceFile.ReadByte();

while (theByte != -1)

{

compStream.WriteByte((byte)theByte);

theByte = sourceFile.ReadByte();

}To:



' VB

Dim buffer(sourceFile.Length) As Byte

sourceFile.Read(buffer, 0, buffer.Length)

compStream.Write(buffer, 0, buffer.Length)



// C#

const int buf_size = 4096;

byte[] buffer = new byte[buf_size];

int bytes_read = 0;

do

{

bytes_read = sourceFile.Read(buffer,0,buf_size);

compStream.Write(buffer,0,bytes_read);

} while (bytes_read != 0);

Microsoft Press  Jul 13, 2010 
Printed
Page 127

Term "file" used in place of "directory"
On page 127, the description of GetDirectoryNames in Table 2-36 reads:



"Gets a list of directory names within the store that match a file mask"



It should read:



"Gets a list of directory names within the store that match a directory mask"

Microsoft Press  Jul 13, 2010 
Printed
Page 133

Files referenced in place of directories
On page 133, the paragraph before the final code sample reads:



"Directories are treated much like files in that to test for their existence, you must use a method that returns an array of strings that match a file mask. The GetDirectoryNames method of the IsolatedStorageFile class allows you to find an existing file before you try to create it:"



It should read:



"Directories are treated much like files in that to test for their existence, you must use a method that returns an array of strings that match a mask. The GetDirectoryNames method of the IsolatedStorageFile class allows you to find an existing directory before you try to create it:"

Microsoft Press  Jul 13, 2010 
Printed
Page 135

Object referenced in place of class
On page 135, the first sentence of step 3 in Exercise 1 reads:



"In the Main method of the new project, create a new instance of the IsolatedStorageFile object named userStore that is scoped to the current user and assembly."



It should read:



"In the Main method of the new project, create a new instance of the IsolatedStorageFile class named userStore that is scoped to the current user and assembly."

Microsoft Press  Jul 13, 2010 
Printed
Page 136

Incorrect Visual Basic code in steps 4 and 5
On page 136, the Visual Basic code in step 4 reads:



' VB

IsolatedStorageFileStream userStream = new _

IsolatedStorageFileStream("UserSettings.set", _

FileMode.Create, _

userStore)



It should read:



' VB

Dim userStream as IsolatedStorageFileStream = new _

IsolatedStorageFileStream("UserSettings.set", _

FileMode.Create, _

userStore)The code in step 5 reads:



' VB

StreamWriter userWriter = new StreamWriter(userStream)

userWriter.WriteLine("User Prefs")

userWriter.Close()



It should read:



' VB

Dim userWriter as new StreamWriter(userStream)

userWriter.WriteLine("User Prefs")

userWriter.Close()

Microsoft Press  Jul 13, 2010 
Printed
Page 139

Clarification of data in 4th bullet down under Chapter Summary
On page 139, fourth bullet down under Chapter Summary it reads:



"The StreamReader and StreamWriter classes are instrumental in dealing with moving data into and out of streams, including FileStreams, MemoryStreams, and IsolatedStorageFileStreams."



It should read:



"The StreamReader and StreamWriter classes are instrumental in dealing with moving textoriented data into and out of streams, including FileStreams, MemoryStreams, and IsolatedStorageFileStreams."

Microsoft Press  Jul 13, 2010 
Printed
Page 141

Machine-level data referred to as assembly data
On page 141, the Create a Simple Configuration Storage section reads:



"For this task, you should complete at least Practices 1 and 2. To understand how user and assembly data differ in isolated storage, complete Practice 3 as well.



- Practice 1 Create a Windows Forms application that allows users to save data and store it in isolated storage.

- Practice 2 Test the Windows Forms application by running it under different user accounts.

- Practice 3 Modify the application to store some assembly-level data to see whether that data is the same for all users."



It should read:



"For this task, you should complete at least Practices 1 and 2. To understand how user and machine-level data differ in isolated storage, complete Practice 3 as well.



- Practice 1 Create a Windows Forms application that allows users to save data and store it in isolated storage.

- Practice 2 Test the Windows Forms application by running it under different user accounts.

- Practice 3 Modify the application to store some machine-level data to see whether that data is the same for all users."

Microsoft Press  Jul 13, 2010 
Printed
Page 146

TestRegExp command arguments partially incorrect
On page 146, the two command line and expected output samples under the 1st paragraph are partially incorrect.



Change:

C:>TestRegExp ^d{5}$ 1234

Input DOES NOT match regular expression.



C:>TestRegExp ^d{5}$ 12345

Input matches regular expression.



To:

C:TestRegExp 1234 ^^d{5}$

Input DOES NOT match regular expression.

(Note: You need to add another ^ because the command line interprets ^ as an escape character. The second ^ is not necessary when adding command line arguments directly through the Visual Studio Command Line Project Properties - Debug - Command Line arguments.)



C:TestRegExp 12345 ^^d{5}$

Input matches regular expression.

Microsoft Press  Jul 13, 2010 
Printed
Page 170

"E." should be removed from answer E
On page 170, Question 4, Answer E reads:



"E. amomomottohez"



It should read:



"amomomottohez"

Microsoft Press  Jul 13, 2010 
Printed
Page 188

Class referenced in place of collection
On page 188, the second sentence of the Adding and Removing Items section reads:



"Adding items to and removing items from the class is very straightforward."



It should read:



"Adding items to and removing items from the collection is very straightforward."

Microsoft Press  Jul 13, 2010 
Printed
Page 192

"++x" should be "x++"
On page 192, the second line of the first code sample on the page is incorrect.



Change:

for (int x = 0; x To:

for (int x = 0; x

Microsoft Press is committed to providing informative and accurate

books. All comments and corrections listed above are ready for

inclusion in future printings of this book. If you have a later printing

of this book, it may already contain most or all of the above corrections.

Microsoft Press  Jul 13, 2010 
Printed
Page 204

Description of code sample is incorrect
On page 204, the last sentence before the first code sample reads:



"Once you have an instance of the class, you use the Push method to add items to the queue and the Dequeue method to remove items from the list, as shown in this short example:"



It should read:



"Once you have an instance of the class, you use the Push method to add items to the stack and the Pop method to remove items from the stack, as shown in this short example:"

Microsoft Press  Jul 13, 2010 
Printed
Page 210

Brackets used incorrectly in VB code example
On page 210, the VB code example under the second paragraph reads:



' VB

Console.WriteLine(emailLookup["sbishop@contoso.com"])It should read:



' VB

Console.WriteLine(emailLookup("sbishop@contoso.com"))

Microsoft Press  Jul 13, 2010 
Printed
Page 213

Values property referred to as the Value property
On page 213, the last sentence reads:



"You also could iterate over those values by iterating through the Value property instead, as seen in this example:"



It should read:



"You also could iterate over those values by iterating through the Values property instead, as seen in this example:"

Microsoft Press  Jul 13, 2010 
Printed
Page 215

Code example contains a syntax error
On page 215, Line 2 of the second VB code example contains a syntax error.



Change:

Dim otherFish as Fish = obj As FishTo:

Dim otherFish as Fish = TryCast(obj, Fish)

Microsoft Press  Jul 13, 2010 
Printed
Page 216

Interfaces referred to as classes
On page 216, the first two sentences of the second paragraph read:



"The Hashtable class supports a constructor that can accept an instance of the IEqualityComparer class as an argument. Much like the IComparer class shown in Lesson 1 that allowed you to sort collections, the IEqualityComparer interface supports two methods: GetHashCode and Equals."



They should read:



"The Hashtable class supports a constructor that can accept an instance of the IEqualityComparer interface as an argument. Much like the IComparer interface shown in Lesson 1 that allowed you to sort collections, the IEqualityComparer interface supports two methods: GetHashCode and Equals."

Microsoft Press  Jul 13, 2010 
Printed
Page 228

Incorrect C# code used in BitArray example
On page 228: the C# code sample at the top of the page reads:



Dim moreBits = New BitArray(3)

bits[0] = True

bits[1] = True

bits[2] = FalseIt should read:



Dim moreBits = New BitArray(3)

moreBits[0] = True

moreBits[1] = True

moreBits[2] = False

Microsoft Press  Jul 13, 2010 
Printed
Page 230

Bits referred to as bytes
On page 230, the eighth sentence of the second paragraph in the Understanding Binary Math section reads:



"So if an unsigned byte has all 8 bytes filled in, it can be represented by this equation: 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 = 255."



It should read:



"So if an unsigned byte has all 8 bits filled in, it can be represented by this equation: 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 = 255."

Microsoft Press  Jul 13, 2010 
Printed
Page 232

98314 should be 196634 and 00000000000000011000000000001010 should be 00000000000000110000000000011010
On page 232, the value of the BitVector32 variable is incorrect.



Change:

"' VB

Console.WriteLine(packedBits.Data)

' 98314

Console.WriteLine(packedBits)

' BitVector32{00000000000000011000000000001010}

// C#

Console.WriteLine(packedBits.Data);

// 98314

Console.WriteLine(packedBits);

// BitVector32{00000000000000011000000000001010}

You could do the math to figure out that the number 98314 can store 10, 1, and 192,

but the BitVector32 can do it for you with much less work."



To:

"' VB

Console.WriteLine(packedBits.Data)

' 196634



Console.WriteLine(packedBits)

' BitVector32{00000000000000110000000000011010}



// C#

Console.WriteLine(packedBits.Data);

// 196634



Console.WriteLine(packedBits);

// BitVector32{00000000000000110000000000011010}You could do the math to figure out that the number 196634 can store 10, 1, and 192,

but the BitVector32 can do it for you with much less work."

Microsoft Press  Jul 13, 2010 
Printed
Page 235

CollectionsUtil referred to as CollectionUtil
On page 235, the sixth sentence of the second paragraph reads:



"Unlike case-insensitive collections, CollectionUtil methods cannot be used to create your collections."



It should read:



"Unlike case-insensitive collections, CollectionsUtil methods cannot be used to create your collections."

Microsoft Press  Jul 13, 2010 
Printed
Page 237

"++x" should be "x++"
On page 237, the fifth line of the last C# code sample is incorrect.



Change:

for (int x = 0; x To:for (int x = 0; x

Microsoft Press  Jul 13, 2010 
Printed
Page 239

CollectionsUtil referred to as CollectionUtil
On page 239, the third bullet point reads:



"You can create case-insensitive versions of Hashtable and SortedList objects using the CollectionUtil class."



It should read:



"You can create case-insensitive versions of Hashtable and SortedList objects using the CollectionsUtil class."

Microsoft Press  Jul 13, 2010 
Printed
Page 249

Class referred to as object
On page 249, the sentence after the first code sample reads:



"This approach is a lot easier than writing a whole Comparison object for seldom-used comparisons."



It should read:



"This approach is a lot easier than writing a whole Comparison class for seldom-used comparisons."

Microsoft Press  Jul 13, 2010 
Printed
Page 250

Dictionary referred to as a Queue
On page 250, the fourth sentence of the Generic Dictionary Class section reads:



"To use a generic Queue type, you can follow these steps:"



It should read:



"To use a generic Dictionary type, you can follow these steps:"

Microsoft Press  Jul 13, 2010 
Printed
Page 254

KeyValuePair referred to as NameValuePair
On page 254, the second sentence of the paragraph following Table 4-23 reads:



"This behavior is unlike the generic Dictionary type, where the enumerator returns a generic NameValuePair object."



It should read:



"This behavior is unlike the generic Dictionary type, where the enumerator returns a generic KeyValuePair object."

Microsoft Press  Jul 13, 2010 
Printed
Page 259

The term "state abbreviations" used in place of "calling codes"
On page 259, the first sentence in Exercise 1 reads:



"In this exercise, you create a generic Dictionary to hold state abbreviations with their full names."



It should read:



"In this exercise, you create a generic Dictionary to hold calling codes with their full names."

Microsoft Press  Jul 13, 2010 
Printed
Page 286

SoapFormatter missing
On page 286, answer A to Question 1 omits a reference to SoapFormatter.



Change:

"A. An instance of BinaryFormatter"



To:

"A. An instance of BinaryFormatter or SoapFormatter"

Microsoft Press  Jul 13, 2010 
Printed
Page 292

Missing quantity line in sample code
On page 292, the sample code for serializing a class in the middle of the page reads:







100

10.25

20.50

It should read:







100

10.25

20.50

2

Microsoft Press  Jul 13, 2010 
Printed
Page 305

OnDeserialized should be OnDeserializing
On page 305, the last sentence references OnDeserialized instead of OnDeserializing.



Change:

"Apply the OnDeserialized attribute to the method that should run during this event."



To:

"Apply the OnDeserializing attribute to the method that should run during this event."

Microsoft Press  Jul 13, 2010 
Printed
Page 343

Image.FromFile shoudl be New Bitmap
On page 343, the second VB code sample uses Image.FromFile rather than New Bitmap.



Change:

"Dim B As Bitmap = Image.FromFile("C:windowsgone fishing.bmp")"



To:"Dim B As Bitmap = New Bitmap("C:windowsgone fishing.bmp")"

Microsoft Press  Jul 13, 2010 
Printed
Page 373

Thread referenced in place of value


On page 373, the last sentence of the first paragraph reads:



"Later on, we will use this thread to see what work is being done on which thread."



It should read:



"Later on, we will use this value to see what work is being done on which thread."

Microsoft Press  Jul 13, 2010 
Printed
Page 377

ThreadStart delegate referenced as StartThread


On page 377, the first three sentences of the Passing Data to Threads section read:



"In each of the earlier examples, we were using the StartThread delegate, which takes no parameters. In most real-world use of threading, you will need to pass information to individual threads. To do this, you need to use a new delegate called ParameterizedStartThread."



They should read:



"In each of the earlier examples, we were using the ThreadStart delegate, which takes no parameters. In most real-world use of threading, you will need to pass information to individual threads. To do this, you need to use a new delegate called ParameterizedThreadStart."

Microsoft Press  Jul 13, 2010 
Printed
Page 378

Incorrect code in C# code sample statement
On page 378, the C# code sample reads:



string info = o as string;

if (info == null)

{

throw InvalidProgramException("Parameter for thread must be a string");

}It should read:



string info = o as string;

if (info == null)

{

throw new InvalidProgramException("Parameter for thread must be a string");

}

Microsoft Press  Jul 13, 2010 
Printed
Page 383

Include statement referenced in place of using statement


On page 383, step 3 reads:



"In the new class, add an include statement (or the Imports statement for Visual Basic) to the System.Threading namespace."



It should read:



"In the new class, add a using statement (or the Imports statement for Visual Basic) to the System.Threading namespace."

Microsoft Press  Jul 13, 2010 
Printed
Page 387

Interlock class referenced in place of Interlocked class


On page 387, the first bullet point reads:



"Use the Interlock class to perform atomic operations."



It should read:



"Use the Interlocked class to perform atomic operations."

Microsoft Press  Jul 13, 2010 
Printed
Page 390

AddCount method referenced in place of UpdateCount method


On page 390, the first sentence after Table 7-7 reads:



"We can change our AddCount method to use the Interlocked class to solve the threading issue like so:"



It should read:



"We can change our UpdateCount method to use the Interlocked class to solve the threading issue like so:"

Microsoft Press  Jul 13, 2010 
Printed
Page 396

Thread.Sleep method required in code example
On page 396, the C# code example is missing the Thread.Sleep method.



Change:

class Deadlocker

{

object ResourceA = new Object();

object ResourceB = new Object();

public void First()

{

lock (ResourceA)

{

lock (ResourceB)

{

Console.WriteLine("First");

}

}

}

public void Second()

{

lock (ResourceB)

{

lock (ResourceA)

{

Console.WriteLine("Second");

}

}

}

}To:

class Deadlocker

{

object ResourceA = new Object();

object ResourceB = new Object();

public void First()

{

lock (ResourceA)

{

//Added sleep to give enough time for B to launch before A finished. So deadlock works.

Thread.Sleep(10);

lock (ResourceB)

{

Console.WriteLine("First");

}

}

}

public void Second()

{

lock (ResourceB)

{

//Added sleep to give enough time for A to launch before B finished. So deadlock works.

Thread.Sleep(10);

lock (ResourceA)

{

Console.WriteLine("Second");

}

}

}

}

Microsoft Press  Jul 13, 2010 
Printed
Page 407

EventWaitHandles referenced in place of EventWaitHandle


On page 407, the third sentence of the final paragraph reads:



"When creating or opening a named event, you will need to deal with EventWaitHandles instead of the AutoResetEvent and ManualResetEvent classes."



It should read:



"When creating or opening a named event, you will need to deal with EventWaitHandle instead of the AutoResetEvent and ManualResetEvent classes."

Microsoft Press  Jul 13, 2010 
Printed
Page 414

Bytes written referenced in place of bytes read


On page 414, the first sentence of the first paragraph reads:



"The differences include that it returns an IAsyncResult instead of the number of bytes written and that two parameters are added to the method signature to support APM."



It should read:



"The differences include that it returns an IAsyncResult instead of the number of bytes read and that two parameters are added to the method signature to support APM."



The first sentence following the second code sample reads:



"At the end of the operation, you will call the EndRead with the IAsyncResult object and it will return the bytes written."



It should read:



"At the end of the operation, you will call the EndRead with the IAsyncResult object and it will return the bytes read."

Microsoft Press  Jul 13, 2010 
Printed
Page 417

AddressOf missing from code sample


On page 417, the 10th line in the VB code example is missing AddressOf.



Change:

New AsyncCallBack(CompleteRead), strm)To:

New AsyncCallBack(AddressOf CompleteRead), strm)

Microsoft Press  Jul 13, 2010 
Printed
Page 421

QueueWorkItem referenced in place of QueueUserWorkItem


On page 421, the first sentence on the page reads:



"Instead of creating a new thread and controlling it, we can use the ThreadPool to do this work by using its QueueWorkItem method:"



It should read:



"Instead of creating a new thread and controlling it, we can use the ThreadPool to do this work by using its QueueUserWorkItem method:"

Microsoft Press  Jul 13, 2010 
Printed
Page 424

RegisterWaitHandle referenced in place of RegisterWaitForSingleObject


On page 424, the third sentence of the ThreadPool and WaitHandle section reads:



"This is done by calling the ThreadPool.RegisterWaitHandle, as shown in the following example:"



It should read:



"This is done by calling the ThreadPool.RegisterWaitForSingleObject, as shown in the following example:"

Microsoft Press  Jul 13, 2010 
Printed
Page 432

Case scenario topics misrepresented


On page 432, the first sentence of the Case Scenario section reads:



"In the following case scenarios, you will apply what you’ve learned about how to use

application domains and services."



It should read:



"In the following case scenarios, you will apply what you’ve learned about the topics of this chapter."

Microsoft Press  Jul 13, 2010 
Printed
Page 454

VB and C# code samples contain an unnecessary line of code
On page 454, in Step 3 the 2nd line of the VB and C# code is redundant and should be removed.



Remove from VB code:

Dim safeZone As Zone = New Zone(SecurityZone.Internet)Remove from C# code:

Zone safeZone = new Zone(SecurityZone.Internet);

Microsoft Press  Jul 13, 2010 
Printed
Page 481-482

Incorrect title on Table
On pages 481 and 482 the title of Table 9-1 reads:



"ConfigurationManager Properties and Methods"



It should read:



"Configuration Properties and Methods"

Microsoft Press  Jul 13, 2010 
Printed
Page 490

Incorrect code sample
On page 490, thecode samples are incorrect.



Change:

'VB

Dim AllAppSettings As NameValueCollection = _

ConfigurationManager.AppSettings

Dim SettingsEnumerator As IEnumerator = AllAppSettings.Keys.GetEnumerator

Dim Counter As Int32 = 0

While SettingsEnumerator.MoveNext

Console.WriteLine("Item: {0} Value: {1}", _

AllAppSettings.Keys(Counter), AllAppSettings(Counter))

End While



// C#

NameValueCollection AllAppSettings =

ConfigurationManager.AppSettings;

Int32 Counter = 0;

IEnumerator SettingsEnumerator = AllAppSettings.Keys.GetEnumerator();

while (SettingsEnumerator.MoveNext())

{

Console.WriteLine("Item: {0} Value: {1}", AllAppSettings.Keys[Counter],

AllAppSettings[Counter]);

}To:

'VB

Dim AllAppSettings As NameValueCollection = _

ConfigurationManager.AppSettings

Dim SettingsEnumerator As IEnumerator = AllAppSettings.Keys.GetEnumerator

Dim Counter As Int32 = 0

While SettingsEnumerator.MoveNext

Console.WriteLine("Item: {0} Value: {1}", _

SettingsEnumerator.Current, AllAppSettings(SettingsEnumerator.Current))

End While



// C#

NameValueCollection AllAppSettings =

ConfigurationManager.AppSettings;

IEnumerator SettingsEnumerator = AllAppSettings.Keys.GetEnumerator();

while (SettingsEnumerator.MoveNext())

{

Console.WriteLine("Item: {0} Value: {1}", SettingsEnumerator.Current,

AllAppSettings[(string)SettingsEnumerator.Current]);

}

Microsoft Press is committed to providing informative and accurate

books. All comments and corrections listed above are ready for

inclusion in future printings of this book. If you have a later printing

of this book, it may already contain most or all of the above corrections.

Microsoft Press  Jul 13, 2010 
Printed
Page 529

Incomplete information in step 2 of Lab
On page 529, Step 2 of the Lab reads:



"Select the Runtime Security Policy node"



It should read:



"Select the Runtime Security Policy node, and select the Increase Assembly Trust option."

Microsoft Press  Jul 13, 2010 
Printed
Page 546

Configuration class referenced in place of ConfigurationManager class
On page 546, the first Lesson Review questions reads:



"Which methods of the Configuration class are valid ways to open a configuration file? (Choose all that apply.)"



It should read:



"Which methods of the ConfigurationManager class are valid ways to open a configuration file? (Choose all that apply.)"

Microsoft Press  Jul 13, 2010 
Printed
Page 556

Application referenced in place of "event log" in Figure 10-2 caption
On page 556, the caption to Figure 10-2 reads:



"The Windows Event Viewer after the Chap10Demo application has been created and written to"



It should read:



"The Windows Event Viewer after the Chap10Demo event log has been created and written to"

Microsoft Press  Jul 13, 2010 
Printed
Page 567

Incorrect description of the Write method of the Debug class
On page 567, the description of the Write method in Table 10-2 reads:



"Writes information about attached Debug or Trace class listener objects in the Listeners collection."



It should read:



"Writes information to attached Debug or Trace class listener objects in the Listeners collection."

Microsoft Press  Jul 13, 2010 
Printed
Page 579

Incorrect reference to the previous version of the .NET Framework
On page 579, the fourth sentence of the DebuggerStepThroughAttribute section reads:



"In previous versions of the .NET Framework, every time you created a Winform for instance, this attribute was added to the InitializeComponent method."



It should read:



"In Visual Basic .NET and Visual Basic 2005, every time you created a Winform for instance, this attribute is applied to the InitializeComponent method."

Microsoft Press  Jul 13, 2010 
Printed
Page 584

Incorrect configuration file code
On page 584, the fourth line of the first code sample reads:



It should read:



Microsoft Press  Jul 13, 2010 
Printed
Page 600

The image in Figure 10-13 is incorrect
On page 600, the image in Figure 10-13 should be replaced with the image from Figure 10-14 on page 601.

Microsoft Press  Jul 13, 2010 
Printed
Page 606

this used in place of Me in code sample
On page 606, the third line of the first code sample reads:



Info.FileName = this.tbProcessName.TextIt should read:



Info.FileName = Me.tbProcessName.Text

Microsoft Press  Jul 13, 2010 
Printed
Page 606

tbFileName not used in Process.Start statement in the third code sample
On page 606, the third code sample reads:



' VB

Dim SecurePassword As New SecureString

For i As Int32 = 0 To Me.tbPassword.Text.Length - 1

SecurePassword.AppendChar(Convert.ToChar(Me.tbPassword.Text(i)))

Next

Process.Start(Me.tbUserName.Text, Me.tbUserName.Text, SecurePassword, Me.tbDomain.Text)



// C#

SecureString SecurePassword = new SecureString();

for (Int32 i = 0; i < this.tbPassword.Text.Length; i++)

{

SecurePassword.AppendChar(Convert.ToChar(this.tbPassword.Text[i]));

}

Process.Start(this.tbUserName.Text, this.tbPassword.Text, SecurePassword , this.tbDomain.Text);It should read:



' VB

Dim SecurePassword As New SecureString

For i As Int32 = 0 To Me.tbPassword.Text.Length - 1

SecurePassword.AppendChar(Convert.ToChar(Me.tbPassword.Text(i)))

Next

Process.Start(Me.tbFileName.Text, Me.tbUserName.Text, SecurePassword, Me.tbDomain.Text)



// C#

SecureString SecurePassword = new SecureString();

for (Int32 i = 0; i < this.tbPassword.Text.Length; i++)

{

SecurePassword.AppendChar(Convert.ToChar(this.tbPassword.Text[i]));

}

Process.Start(this.tbFileName.Text, this.tbUserName.Text, SecurePassword,

this.tbDomain.Text);

Microsoft Press  Jul 13, 2010 
Printed
Page 608

tbUsername used in place of tbUserName


On page 608, the eighth line of the C# code sample reads:



if (this.tbUsername.Text != String.Empty)It should read:



if (this.tbUserName.Text != String.Empty)

Microsoft Press  Jul 13, 2010 
Printed
Page 616

"DirectoryObjectSearcher" used in place of "ManagementObjectSearcher"


On page 616, there are several instances where "DirectoryObjectSearcher" is used in place of "ManagementObjectSearcher", the first sentence of the paragraph under the Enumerating Management Objects reads:



"At the core of the System.Management namespace is the DirectoryObjectSearcher object, which ccan programmatically access resources through WMI."



It should read:



"At the core of the System.Management namespace is the ManagementObjectSearcher object, which ccan programmatically access resources through WMI."



The last sentence of the same paragraph reads:



"To execute a query using the DirectoryObjectSearcher, the following steps need to be performed:"



It should read:



"To execute a query using the ManagementObjectSearcher, the following steps need to be performed:"



Step #2 reads:



"Declare an instance of the DirectoryObjectSearcher class."



It should read:



"Declare an instance of the ManagementObjectSearcher class."



Step #5 reads:



"Create a ManagementObjectCollection, and set it to the return value from the DirectoryObjectSearcher's Get method."



It should read:



"Create a ManagementObjectCollection, and set it to the return value from the ManagementObjectSearcher's Get method."

Microsoft Press  Jul 13, 2010 
Printed
Page 621

Incorrect using directives in step 5
On page 621, the C# code sample in step 5 reads:



Using System.Diagnostics;

Imports System.Management;It should read:



using System.Diagnostics;

using System.Management;

Microsoft Press is committed to providing informative and accurate

books. All comments and corrections listed above are ready for

inclusion in future printings of this book. If you have a later printing

of this book, it may already contain most or all of the above corrections.

Microsoft Press  Jul 13, 2010 
Printed
Page 740

Data.data file referenced in place of Data.dat
On page 740, the code sample reads:



' VB

File.Create("C:GuestData.Data")



// C#

File.Create(@"C:GuestData.Data");It should read:



' VB

File.Create("C:GuestData.Dat")



// C#

File.Create(@"C:GuestData.Dat");

Microsoft Press  Jul 13, 2010 
Printed
Page 794

Square brackets used in place of angle brackets
On page 794, the third line of the code sample reads:



[assembly: RuntimeCompatibility(WrapNonExceptionThrows=false)]It should read:



Microsoft Press  Jul 13, 2010 
Printed
Page 815

"Layout.Sequential" used in place of "LayoutKind.Sequential"
On page 815, the bold section header near the middle of the page reads:



"Layout.Sequential"



It should read:



"LayoutKind.Sequential"



The first sentence under the Layout.Sequential section heading reads:



"The first method to use is the Layout.Sequential option."



It should read:



"The first method to use is the LayoutKind.Sequential option."

Microsoft Press  Jul 13, 2010 
Printed
Page 831

Models referenced in place of modules


On page 831, the third sentence reads:



"From assemblies and models all the way down to the individual statements that are part of a line of code, reflection allows you to both interrogate and generate code in .NET."



It should read:



"From assemblies and modules all the way down to the individual statements that are part of a line of code, reflection allows you to both interrogate and generate code in .NET."

Microsoft Press  Jul 13, 2010 
Printed
Page 838

Include statement referenced in place of using statement


On page 838, step 2 reads:



"Add an include statement (or the Imports statement for Visual Basic) to the System.Reflection namespace to the main code file."



It should read:



"Add a using statement (or the Imports statement for Visual Basic) to the System.Reflection namespace to the main code file."

Microsoft Press  Jul 13, 2010 
Printed
Page 847

GetCustomAttribute referenced in place of GetCustomAttributes


On page 847, the sixth sentence of the Getting Assembly Attributes section reads:



"Because of this, the GetCustomAttribute allows for a Boolean value to indicate whether to get inherited attributes."



It should read:



"Because of this, the GetCustomAttributes allows for a Boolean value to indicate whether to get inherited attributes."

Microsoft Press  Jul 13, 2010 
Printed
Page 855-856

InterfaceInfo referenced in place of Type


On page 855, the description for GetInterface in Table 14-8 reads:



"Retrieves a specific InterfaceInfo object that is associated with this Type"



It should read:



"Retrieves a specific Type object that is associated with this Type"



On page 856, the description for GetInterfaces in Table 14-8 reads:



"Retrieves all the InterfaceInfo objects that are associated with this Type"



It should read:



"Retrieves all the Type objects that are associated with this Type"

Microsoft Press  Jul 13, 2010 
Printed
Page 864

Include statement referenced in place of using statement


On page 864, step 2 reads:



"Add an include statement (or Imports in Visual Basic) to the System.Reflection namespace to the main code file."



It should read:



"Add a using statement (or Imports in Visual Basic) to the System.Reflection namespace to the main code file."

Microsoft Press  Jul 13, 2010 
Printed
Page 871

Class referenced in place of method


On page 871, the first sentence following the first code sample reads:



"In this example, you are getting the MethodInfo for the overload of the WriteLine class that takes a single String and writes it out to the console."



It should read:



"In this example, you are getting the MethodInfo for the overload of the WriteLine method that takes a single String and writes it out to the console."

Microsoft Press  Jul 13, 2010 
Printed
Page 872

Include statement referenced in place of using statement


On page 872, step 2 reads:



"In the main code file, add an include statement (or Imports for Visual Basic) to the System.Reflection namespace."



It should read:



"In the main code file, add a using statement (or Imports for Visual Basic) to the System.Reflection namespace."

Microsoft Press  Jul 13, 2010 
Printed
Page 879

Class referenced in place of object


On page 879, the first sentence of the Creating Members section reads:



"The TypeBuilder class that the DefineType method returns is central to creating dynamic code."



It should read:



"The TypeBuilder object that the DefineType method returns is central to creating dynamic code."

Microsoft Press  Jul 13, 2010 
Printed
Page 882

Include statements referenced in place of using statements


On page 882, step 2 reads:



"In the main code file, add include statements (or Imports statements for Visual Basic) for System.Reflection and System.Reflection.Emit namespaces."



It should read:



"In the main code file, add using statements (or Imports statements for Visual Basic) for System.Reflection and System.Reflection.Emit namespaces."

Microsoft Press  Jul 13, 2010 
Printed
Page 924

"CultureType" used in place of "CultureTypes"


On page 924, the last sentence on the page reads:



"The GetCultures method takes a single parameter of type CultureType."



It should read:



"The GetCultures method takes a single parameter of type CultureTypes."

Microsoft Press  Jul 13, 2010 
Printed
Page 936

Culture class listed incorrectly in first paragraph
On page 936, the third sentence in the first paragraph reads:



"The CultureRegionAndInfoBuilder class enables you to create and use a customized culture."



It should read:



"The CultureAndRegionInfoBuilder class enables you to create and use a customized culture."

Microsoft Press  Jul 13, 2010 
Printed
Page 945

Clarification needed for answers B and D for question 2


On page 945, answers B and D for question 2 read:



"B. Correct: Procedures work with a copy of variables when you pass a value type. Therefore, any modifications that were made to the copy would not affect the original value.



D. Incorrect: If the variable had been a reference, the original value would have been modified."



They should read:



"B. Correct: Procedures work with a copy of variables when you pass a value type by value. Therefore, any modifications that were made to the copy would not affect the original value.



D. Incorrect: If the variable had been passed by reference, the original value would have been modified."

Microsoft Press  Jul 13, 2010 
Printed
Page 950

Correct answer should be A
On page 950, the correct answer to Chapter 2 Lesson Review Question 3 is incorrect.



Change:

"3. Correct Answer: B

A. Incorrect: The Path class deals only with the string of a path. It makes no changes to the file system.

B. Correct: The Path class deals only with the string of a path. It makes no changes to the file system."



To:

"3. Correct Answer: A

A. Correct: The Path class will change the file extension.

B: Incorrect: The Path class will change the file extension."

Microsoft Press  Jul 13, 2010 
Printed
Page 954

Corrections in answers for Lesson 2
On page 954, Chapter 3, Lesson 2, Question 1 answers B through D read:



"B. Incorrect: UTF-16 has a smaller byte size than UTF-3

C. Incorrect: UTF-8 has a smaller byte size than UTF-3

D. Incorrect: ASCII has a smaller byte size than UTF-3"



It should read:



"B. Incorrect: UTF-16 has a smaller byte size than UTF-32

C. Incorrect: UTF-8 has a smaller byte size than UTF-32

D. Incorrect: ASCII has a smaller byte size than UTF-32"

Microsoft Press  Jul 13, 2010 
Printed
Page 957

Answer B to question 1 of chapter 3 is incorrect
On page 957, the answer given for question 1 of Chapter 3 is incorrect.



Change:

"1. Correct Answers: B and D

A. Incorrect: GetType is not called to determine uniqueness.

B. Correct: The hash value from the object is used to see whether the hash has been used in the collection.

C. Incorrect: The string representation of the object does not determine whether the key is unique. The Hashtable class only uses the hash value to determine uniqueness.

D. Correct: If two hash values are identical, Equals can be called to determine whether two objects are in fact equal before assigning the value to a key."



To:

"1. Correct Answer: D

A. Incorrect: GetType is not called to determine uniqueness.

B. Incorrect: The hash value from the object is used to see whether the hash has been used in the collection, but does not indicate whether the object has been used as a key.

C. Incorrect: The string representation of the object does not determine whether the key is unique. The Hashtable class only uses the hash value to determine uniqueness.

D. Correct: If two hash values are identical, Equals can be called to determine whether two objects are in fact equal before assigning the value to a key."

Microsoft Press  Jul 13, 2010 
Printed
Page 977

Reference to question 3 should be removed
On page 977, the answer to chapter 9, lesson 2, question 3 reads:



"3. Correct Answer: D

A. Incorrect: The Custom Actions view is used to facilitate custom actions along the installation path. It has no true bearing on the registry.

B. Incorrect: The File System view is used to facilitate changes to the file system. It has no real control over the registry.

C. Incorrect: There is no Registry Editor view.

D. Correct: The Registry view is the correct view to allow additions and modifications to the registry."



This text should be disregarded.

Microsoft Press  Jul 13, 2010 
Printed
Page 978

Mapping specification is required for OpenMappedMachineConfiguration
On page 978, lesson 4, question 1, answer D reads:



"Correct: OpenMappedMachineConfiguration is a valid method to open the machine configuration file."



It should read:



"Correct: OpenMappedMachineConfiguration is a valid method to open a machine configuration file as long as a mapping is specified."

Microsoft Press  Jul 13, 2010 
Printed
Page 986

SecurityAction.Demand can be used declaratively
On page 986, the first answer for Chapter 11, Lesson 3, Question 2 reads:



"A. Incorrect: SecurityAction.Demand instructs the runtime to throw and exception if the caller and all callers higher in the stack lack the specified permissions. However, SecurityAction.Demand must be used imperatively, and the question describes a need for declarative security."



It should read:



"A. Correct: SecurityAction.Demand instructs the runtime to throw and exception if the caller and all callers higher in the stack lack the specified permissions."

Microsoft Press  Jul 13, 2010 
Printed
Page 1002

SmtpFailedReceipientException should be SmtpFailedRecipientException
On page 1002, Lesson 2, Question 3, Answer A includes a mispelling of the exception.



Change:



"A. Correct: The runtime throws SmtpFailedReceipientException if the SMTP server rejects an e-mail address."



To:



"A. Correct: The runtime throws SmtpFailedRecipientException if the SMTP server rejects an e-mail address."

Microsoft Press  Jul 13, 2010 
Printed
Page 1002

120.0.1 should be 127.0.0.1
On page 1002, the explanation for Answer D of question 2 is incorrect.



Change:

"120.0.1 is a special IP address that always describes the local computer."



To:

"127.0.0.1 is a special IP address that always describes the local computer."

Microsoft Press  Jul 13, 2010 
Printed
Page 1007

The Brush glossary entry is not identified as such
On page 1007, the last entry on the page reads:



"Located in the System.Drawing namespace, classes derived from the Brush class are required for drawing text and filling in shapes."



It should read:



"Brush Located in the System.Drawing namespace, classes derived from the Brush class are required for drawing text and filling in shapes."

Microsoft Press  Jul 13, 2010 
Printed
Page 1010

The Graphics glossary entry is not identified as such
On page 1010, the entry after globalization reads:



"Located in the System.Drawing namespace, this class provides methods for drawing lines, shapes, and text."



It should read:



"Graphics Located in the System.Drawing namespace, this class provides methods for drawing lines, shapes, and text."

Microsoft Press  Jul 13, 2010 
Printed
Page 1011

The ManagementQuery glossary entry is not identified as such
On page 1011, the entry after "managed code" reads:



"A request for information about a Windows Management Instrumentation object."



It should read:



"ManagementQuery A request for information about a Windows Management Instrumentation object."

Microsoft Press  Jul 13, 2010 
Printed
Page 1012

The Pen glossary entry is not identified as such
On page 1012, the entry after "partially trusted code" reads:



"Located in the System.Drawing namespace, this class is used to specify the color and width of drawings."



It should read:



"Pen Located in the System.Drawing namespace, this class is used to specify the color and width of drawings."

Microsoft Press  Jul 13, 2010 
Printed
Page 1014

The StackTrace glossary entry is not identified as such
On page 1014, the second entry ont he page reads:



"An ordered collection of one or more StackFrame objects."



It should read:



"StackTrace An ordered collection of one or more StackFrame objects."

Microsoft Press is committed to providing informative and accurate

books. All comments and corrections listed above are ready for

inclusion in future printings of this book. If you have a later printing

of this book, it may already contain most or all of the above corrections.

Microsoft Press  Jul 13, 2010 
Other Digital Version
CD-ROM

"not" should be removed from assessment question In the Lesson Review on the CD-ROM, one of the questions is incorrect. Change: "Which item is not generally considered a shortcoming associated with using COM Interop?" To: "Which item is generally considered a shortcoming associated with using COM Interop?"

Microsoft Press  May 06, 2010 
Other Digital Version
CD-ROM

Assessment answer should also include Resize event In the Readiness Review Assessment, one of the questions reads: "Which of the following are events for the System.Windows.Forms.Button class? (Choose three) Serializing Enter MouseHover Resize Click MosueOver" The assessment states that the correct answers are: Enter, MouseHover, Click. The assessment should also include the following answer as being correct: Resize.

Microsoft Press  May 06, 2010 
Other Digital Version
CD-ROM

Assessment qurestion scored incorrectly In the Lesson Review on the CD-ROM, one of the questions is scored incorrectly. The question reads: "You are writing an application that needs to perform processing that will run for several hours. However, you need the application to remain responsive to the user during that time, so you are using multiple threads. Which of the following code samples would launch the thread in such a way as to minimize the impact on the performance of other applications? (Choose all that apply.)" When the question is scored, one of the answers is marked correct, though it should be marked incorrect. The answer reads: 'VB Dim myThreadDelegate As New ThreadStart(AddressOf ThreasWork.DoWork) Dim mtThread As New Thread(myThreadDelegate) myThread.StartLowPriority() // C# ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork); Thread myThread = new Thread(myThreadDelegate); myThread.StartLowPriority();

Microsoft Press  May 06, 2010 
Printed

Page 89, Incorrect namespaces used in stream types. On page 89, the 3rd, 4th and 5th bullet points read: "* CryptoStream (System.Security) * NetworkStream (System.Net) * GZipStream (System.Compression)" They should read: "* CryptoStream (System.Security.Cryptography) * NetworkStream (System.Net.Sockets) * GZipStream (System.IO.Compression)"

Microsoft Press  May 06, 2010 
Printed
Page 5

Date/date should be Date/none On page 5, the first cell of the last row of Table 1-2 is incorrect. Change: "System.DateTime (Date/date)" To: "System.DateTime (Date/none)"

Microsoft Press  May 06, 2010 
Printed
Page 9

NOTE is incorrect On page 9, the NOTE reads: "NOTE .NET 2.0 The Operator keyword is new in .NET 2.0." This is incorrect and the note should be disregarded.

Microsoft Press  May 06, 2010 
Printed
Page 14

Term "class" used in place of term "structure" in step 5 On page 14, the first sentence of step 5 reads: "Modify your Main code to properly construct an instance of the Person class, as the following code sample demonstrates:" It should read: "Modify your Main code to properly construct an instance of the Person structure, as the following code sample demonstrates:"

Microsoft Press  May 06, 2010 
Printed
Page 24

C# code sample missing On page 24, the following code sample should be added directly below the VB code sample: // C# try { StreamReader sr = new StreamReader("text.txt"); Console.WriteLine(sr.ReadToEnd); } catch (System.IO.FileNotFoundException ex) { Console.WriteLine("The file could not be found."); } catch (System.UnauthorizedAccessException ex) { Console.WriteLine("You do not have sufficient permissions."); } catch (Exception ex) { Console.WriteLine("Error reading file: " + ex.Message); }

Microsoft Press  May 06, 2010 
Printed
Page 46

Correction in code example On page 46, the C# code example under the third bullet point is incorrect. Change:// C# MyEventHandler handler = MyEvent; EventArgs e = new EventArgs(); if (handler != null) { // Invokes the delegates. handler(this, e); } // Note that C# checks to determine whether handler is null. // This is not necessary in Visual BasicTo: // C# EventArgs e = new EventArgs(); if (MyEvent != null) { // Invokes the delegates. MyEvent(this, e); } // Note that C# checks to determine whether handler is null. // This is not necessary in Visual Basic

Microsoft Press  May 06, 2010 
Printed
Page 49

Invalid character in VB code sample On page 49, the VB code sample contains an invalid bracket character. Change: ' VB Imports System.Runtime.CompilerServices To: ' VB Imports System.Runtime.CompilerServices

Microsoft Press  May 06, 2010 
Printed
Page 51

Methods incorrectly named On page 51, in step 4 the code samples read:'VB Private Sub Form1_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) _' and //C# private void Timer_Shown(object sender, EventArgs e)They should read: 'VB Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _' and //C# private void Form1_Load(object sender, EventArgs e)

Microsoft Press  May 06, 2010 
Printed
Page 55

Incorrect description of narrowing conversion behavior On page 55, the sentence at the bottom of the page reads: "Narrowing conversions fail if the source value exceeds the destination type's range or if a conversion between the types is not defined, so you should enclose a narrowing conversion in Try blocks or use TryCast or TryParse and check the return value." It should read: "Narrowing conversions may return an incorrect result if the source value exceeds the destination type's range. If a conversion between the types is not defined you will receive a compile-time error."

Microsoft Press  May 06, 2010 
Printed
Page 59

Decimal used in place of Double in code for Exercise 1 On page 59, in the third line of VB code in the second step of Exercise 1 reads: Dim db As Decimal = 1It should read: Dim db As Double = 1

Microsoft Press  May 06, 2010 
Printed
Page 72

"Exist property" referenced in place of "Exists property" On page 72, the first sentence after the bulleted list reads: "For example, you can check whether a file exists by calling the FileInfo object’s Exist property, as shown in the following code:" It should read: "For example, you can check whether a file exists by calling the FileInfo object’s Exists property, as shown in the following code:"

Microsoft Press  May 06, 2010 
Printed
Page 74

DriveInfo class described incorrectly On page 74, the first sentence under the DriveInfo class section reads: “The DriveInfo class provides the basic functionality to access and manipulate a single directory in the file system.” It should read: "The DriveInfo class models a drive and provides methods and properties to query for drive information. Use DriveInfo to determine what drives are available, and what type of drives they are. You can also query to determine the capacity and available free space on the drive."

Microsoft Press  May 06, 2010 
Printed
Page 76

Procedure said to access rather than enumerate drives On page 76, the first sentence of the How to Enumerate Drives section reads: "You follow this procedure to access the drives in a system:" It should read: "You follow this procedure to enumerate all the drives in a system:"

Microsoft Press  May 06, 2010 
Printed
Page 83

Drive referred to in place of folder On page 83, the first sentence of Excercise 1 reads: "In this exercise, you will enumerate through all the files in a particular drive." It should read: "In this exercise, you will enumerate through all the files in a particular folder."

Microsoft Press  May 06, 2010 
Printed
Page 84

Incorrect direction in step 6 On page 84, the first sentence of step 6 reads: "In the Main method, write code to create a new instance of a DirectoryInfo object for the Windows directory and use it to call the new ShowDirectory method." It should read: "In the Main method, write code to create a new instance of a DirectoryInfo class for the System directory and use it to call the new ShowDirectory method."

Microsoft Press  May 06, 2010 
Printed
Page 92

Incorrect description of the functionality of the Directory class On page 92, the second sentence of the Directory Class section reads: "The Directory class provides the basic functionality to open file streams for reading and writing." It should read: "The Directory class provides the basic functionality to create, manage, delete, and analyze directories."

Microsoft Press  May 06, 2010 
Printed
Page 97

"read" used in place of "write" On page 97, the first sentence of the first paragraph reads:"The StreamReader class provides the basic functionality to write data from a Stream derived class."It should read: "The StreamReader class provides the basic functionality to read data from a Stream derived class."

Microsoft Press  May 06, 2010 
Printed
Page 104

Incorrect description of the behavior of the sample code On page 104, the last sentence on the page reads: "For example, the following code will read the code just shown:" It should read: "For example, the following code will read the data written by the code just shown:"

Microsoft Press  May 06, 2010 
Printed
Page 111

Incorrect instruction in step 3 of Excercise 1 On page 111, step 3 of Exercise 1 reads: "In the Main method, create a new StreamWriter from the Create method of the File class." It should read: "In the Main method, create a new StreamWriter by calling the CreateText method of the File class."

Microsoft Press  May 06, 2010 
Printed
Page 115

The descriptions of the CanRead property is incorrect On page 115, the description of the CanRead property in Table 2-30 reads: "Determines whether the stream supports reading while decompressing a file. (Inherited from the Stream class.)" It should read: "Determines whether the stream supports reading. (Inherited from the Stream class.)"

Microsoft Press  May 06, 2010 
Printed
Page 121

The term "include" used in place of "using" in Step 2 On page 121, step 2 reads:"Add an Import (or an include in C#) for the System.IO namespace into the new project." It should read: "Add an Import (or aa using statement in C#) for the System.IO namespace into the new project."

Microsoft Press  May 06, 2010 
Printed
Page 122

Additional note needs to be added for step 9. On Page 122, Step 9 an addition NOTE needs to be added before the code sample for more information: "NOTE: Using a small file may result in the compressed file being larger than the original because of the overhead of compression. If you use a larger file, the size of the overhead will not cause such a pallor on the size of the resulting file."

Microsoft Press  May 06, 2010 
Printed
Page 129

Incorrect definition for IsolatedStorageFileStream On page 129, the first sentence of the first paragraph reads: "The IsolatedStorageFileStream class encapsulates a stream that is used to create files in isolated storage." It should read: "The IsolatedStorageFileStream class encapsulates a stream that is used to read, write and create files in isolated storage."

Microsoft Press  May 06, 2010 
Printed
Page 135

The term "include" used in place of "using" in Step 2 On page 135, step 2 reads:"Add an Import (or an include in C#) for the System.IO namespace into the new project." It should read: "Add an Import (or aa using statement in C#) for the System.IO namespace into the new project."

Microsoft Press  May 06, 2010 
Printed
Page 135

Incorrect Visual Basic code in step 3 On page 135, the Visual Basic code in step 3 reads: ' VB IsolatedStorageFile userStore = _ IsolatedStorageFile.GetUserStoreForAssembly()It should read: ' VB Dim userStore as IsolatedStorageFile = _ IsolatedStorageFile.GetUserStoreForAssembly()

Microsoft Press  May 06, 2010 
Printed
Page 137

Sample code missing On page 137, the fifth line of the first section of sample code reads: // ...It should read: Console.WriteLine("No data saved for this user.");

Microsoft Press  May 06, 2010 
Printed
Page 140

Incorrect description of Case Scenarios On page 140, the first sentence of the Case Scenarios section reads: "In the following case scenarios, you will apply what you’ve learned about how to use application domains and services." It should read: "In the following case scenarios, you will apply what you’ve learned about files and directories."

Microsoft Press  May 06, 2010 
Printed
Page 145 & 146

Argument location is reversed On page 145, line 7 of the VB code example and on page 146 line 11 of the C# code example contain incorrect argument locations. Change (page 145 VB): If Regex.IsMatch(args(1),args(0)) ThenTo: If Regex.IsMatch(args(0),args(1)) ThenChange (page 146 C#): if (Regex.IsMatch(args[1], args[0]))To: if (Regex.IsMatch(args[0], args[1]))

Microsoft Press  May 06, 2010 
Printed
Page 165

IsZip method mentioned in place of ReformatPhone method On page 165, the last sentence before the code sample in step 3 of Exercise 2 reads: "Though many different regular expressions would work, the IsZip method you write could look like this:" It should read: "Though many different regular expressions would work, the ReformatPhone method you write could look like this:"

Microsoft Press  May 06, 2010 
Printed
Page 187

"or index" should be removed On page 187, there are errors in the descriptions of Hashtable and StringDictionary. Change: "Hashtable A collection of name/value pairs of objects that allows retrieval by name or index" To: "Hashtable A collection of name/value pairs of objects that allows retrieval by name" Change: "StringDictionary A collection of name/values pairs of strings that allows retrieval by name or index" To: "StringDictionary A collection of name/values pairs of strings that allows retrieval by name"

Microsoft Press  May 06, 2010 
Printed
Page 192

Missing newline in code sample On page 192, the seventh line of the second code sample reads: // C# IEnumerator enumerator = coll.GetEnumerator();It should read: // C# IEnumerator enumerator = coll.GetEnumerator();

Microsoft Press  May 06, 2010 
Printed
Page 200

Answer B to question 2 is imprecise On page 200, answer B reads: "To test whether two objects are the same reference of an object" It should read: "To test whether two variables are referencing the same object"

Microsoft Press  May 06, 2010 
Printed
Page 209

DictionaryEntry referred to as DictionaryEntries On page 209, the fourth bullet point reads: "Enumerate dictionaries and know how to use DictionaryEntries." It should read: "Enumerate dictionaries and know how to use DictionaryEntry."

Microsoft Press  May 06, 2010 
Printed
Page 213

Incorrect method used for supporting class On page 213, in the fourth sentence of the first paragraph under "Understanding Equality" reads: "This class supports the GetHash method, which returns an integer that uniquely identifies the object." It should read: "This class supports the GetHashCode method, which returns an integer that uniquely identifies the object."

Microsoft Press  May 06, 2010 
Printed
Page 214

Code example missing comment On page 214, in the second VB code example the 6th line of code is missing a comment. Change: Console.WriteLine(duplicates.Count)To: Console.WriteLine(duplicates.Count) ' 2

Microsoft Press  May 06, 2010 
Printed
Page 216

Incorrect description of Hashtable functionality On page 216, the second sentence on the page reads: "This situation is where the Hashtable’s ability to provide a class that calculates equality comes in." It should read: "This situation is where the Hashtable’s ability to use a class that calculates equality comes in."

Microsoft Press  May 06, 2010 
Printed
Page 227

Incorrect VB code used in BitArray example On page 227, the second part of the VB code in Step 4 reads: Dim moreBits As BitArray = New BitArray(3) bits(0) = True bits(1) = True bits(2) = FalseIt should read: Dim moreBits As BitArray = New BitArray(3) moreBits(0) = True moreBits(1) = True moreBits(2) = False

Microsoft Press  May 06, 2010 
Printed
Page 228

Four bits referenced in place of three bits On page 228, the second sentence of the third paragraph of the How to Use a BitVector32 for Bit Masks section reads: "Assume that you need to set the value of the first four bits in some 32-bit integer." It should read: "Assume that you need to set the value of the first three bits in some 32-bit integer." The first sentence of step 4 of the section reads: "Repeat steps 1 through 3 until you have four bit masks." It should read: "Repeat steps 1 through 3 until you have three bit masks."

Microsoft Press  May 06, 2010 
Printed
Page 230

Unsigned should be signed On page 230, the fourth sentence of the last paragraph in the Understanding Binary Math section refers to an unsigned integer, rather than a signed integer. Change: "Complicating matters even more is the fact that the BitVector32 actually works with an unsigned integer, so the last digit is actually –(2^31), which deals with the negative range of a signed 32-bit integer." To:"Complicating matters even more is the fact that the BitVector32 actually works with a signed integer, so the last digit is actually –(2^31), which deals with the negative range of a signed 32-bit integer."

Microsoft Press  May 06, 2010 
Printed
Page 234

CollectionsUtil referred to as CollectionUtil On page 234, the third sentence of the Case-Insensitive Collections section reads: "Because this is such a common use, the .NET Framework has a CollectionUtil class that supports creating Hashtable and SortedList objects that are case insensitive." It should read: "Because this is such a common use, the .NET Framework has a CollectionsUtil class that supports creating Hashtable and SortedList objects that are case insensitive."

Microsoft Press  May 06, 2010 
Printed
Page 235

Incorrect string used in VB and C# code sample On page 235, in the VB and C# code sample it reads: ' VB Dim hash As Hashtable = New Hashtable( _ StringComparer.InvariantCulture) Dim list As SortedList = New SortedList( _ StringComparer.InvariantCulture) // C# Hashtable hash = new Hashtable( StringComparer.InvariantCulture); SortedList list = new SortedList( StringComparer.InvariantCulture);It should read: ' VB Dim hash As Hashtable = New Hashtable( _ StringComparer.InvariantCulture) Dim list As SortedList = New SortedList( _ StringComparer.InvariantCultureIgnoreCase) // C# Hashtable hash = new Hashtable( StringComparer.InvariantCulture); SortedList list = new SortedList( StringComparer.InvariantCultureIgnoreCase);

Microsoft Press  May 06, 2010 
Printed
Page 238

Incorrect usage of ListCollection class name in Step 3 On page 238, Step 3 reads: "In the Main method of the project, create a new instance of the ListCollection class, specifying case insensitive and culture invariant." It should read: "In the Main method of the project, create a new instance of the ListDictionary class, specifying case insensitive and culture invariant."

Microsoft Press  May 06, 2010 
Printed
Page 246

KeyValuePair referred to as NameValuePair On page 246, the last entry on the page in Table 4-20 reads: "DictionaryEntry NameValuePair<>" It should read: "DictionaryEntry KeyValuePair

Microsoft Press  May 06, 2010 
Printed
Page 249

ReverseIntComparison should be AddressOf ReverseIntComparison On page 249, the first VB code sample is incorrect. Change: ' VB intList.Sort(ReverseIntComparison)To: ' VB intList.Sort(AddressOf ReverseIntComparison)

Microsoft Press  May 06, 2010 
Printed
Page 250

First line of VB code example incorrect On page 250, the first line of the VB code example reads: Dictionary(Of Integer, String) dict = new Dictionary(Of Integer, String)() dict(3) = "Three" dict(4) = "Four" dict(1) = "One" dict(2) = "Two" Dim str as String = dict(3)It should read: Dim dict = New Dictionary(Of Integer, String)() dict(3) = "Three" dict(4) = "Four" dict(1) = "One" dict(2) = "Two" Dim str As String = dict(3)

Microsoft Press  May 06, 2010 
Printed
Page 258

ReadOnlyCollectionBase class referred to as ReadOnlyCollection base On page 258, the first sentence of the fifth paragraph in the Writing Your Own Collections section reads: "Unlike the CollectionBase and ReadOnlyCollection base classes, the DictionaryBase implements the IDictionary, IEnumerable, and ICollection interfaces." It should read: "Unlike the CollectionBase and ReadOnlyCollectionBase classes, the DictionaryBase implements the IDictionary, IEnumerable, and ICollection interfaces."

Microsoft Press  May 06, 2010 
Printed
Page 280, 281

"XML" used in place of "SOAP" On pages 280 and 281, the title of Table 5-1 reads: "XML Serialization Attributes" It should read: "SOAP Serialization Attributes"

Microsoft Press  May 06, 2010 
Printed
Page 287

serialized used in place of deserialized On page 287, Question 4 reads: "Which of the following interfaces should you implement to enable you to run a method after an instance of your class is serialized?" It should read: "Which of the following interfaces should you implement to enable you to run a method after an instance of your class is deserialized?"

Microsoft Press  May 06, 2010 
Printed
Page 301

XML should be Xml On page 301, six review question answers use XML rather than Xml. In the answers to question 2, change: "B. XMLType C. XMLElement D. XMLAttribute" To: "B. XmlType C. XmlElement D. XmlAttribute" In the answers to question 4, change: "A. XMLType B. XMLIgnore C. XMLElement D. XMLAttribute" To: "A. XmlType B. XmlIgnore C. XmlElement D. XmlAttribute"

Microsoft Press  May 06, 2010 
Printed
Page 306

OnDeserializing should be OnDeserialized On page 306, the last sentence of the Deserialized section references OnDeserializing rather than OnDeserialized. Change: "Apply the OnDeserializing attribute to the method that should run during this event." To: "Apply the OnDeserialized attribute to the method that should run during this event."

Microsoft Press  May 06, 2010 
Printed
Page 370

ThreadState.WaitJoinSleep referenced in place of ThreadState.WaitSleepJoin On page 370, the description of Interrupt in Table 7-2 reads: "Raises a ThreadInterruptedException when a thread is in a blocked state (ThreadState.WaitJoinSleep). If the thread never blocks, the interruption never happens." It should read: "Raises a ThreadInterruptedException when a thread is in a blocked state (ThreadState.WaitSleepJoin). If the thread never blocks, the interruption never happens."

Microsoft Press  May 06, 2010 
Printed
Page 373

Correction in method name and output phrase On page 373, the first and second sentence of the paragraph below the first set of code examples reads: "When the Start method is called, the SomeWork method is called on a new thread and the thread executes until the method completes. In this example, our SimpleWork method writes the phrase "In Thread" and shows the ManagedThreadId Property." It should read: "When the Start method is called, the SimpleWork method is called on a new thread and the thread executes until the method completes. In this example, our SimpleWork method writes the phrase "Thread #" and shows the ManagedThreadId Property."

Microsoft Press  May 06, 2010 
Printed
Page 378

Missing line break in code sample On page 378, the first line of the code sample reads: ' VB ParameterizedThreadStart operation = _It should read: ' VB ParameterizedThreadStart operation = _

Microsoft Press  May 06, 2010 
Printed
Page 380

Domain referenced in place of state On page 380, the first sentence on the page reads: "To solve the problem of leaving objects or the AppDomain in an inconsistent domain, the Thread class has two important static methods: BeginCriticalRegion and EndCriticalRegion." It should read: "To solve the problem of leaving objects or the AppDomain in an inconsistent state, the Thread class has two important static methods: BeginCriticalRegion and EndCriticalRegion."

Microsoft Press  May 06, 2010 
Printed
Page 383

StartThread referenced in place of ThreadStart On page 383, step 7 reads: "Go back to the Main method, and create a new StartThread delegate that points to the Counting method." It should read: "Go back to the Main method, and create a new ThreadStart delegate that points to the Counting method."

Microsoft Press  May 06, 2010 
Printed
Page 389

Reading from memory referred to as reading into memory On page 389, the second sentence of the paragraph preceeding Figure 7-2 reads: "As shown in Figure 7-2, two threads could each read the values into memory and update them with the same updated value." It should read: "As shown in Figure 7-2, two threads could each read the values from memory and at the same time update them with the same updated value."

Microsoft Press  May 06, 2010 
Printed
Page 394

C# code sample is incorrect On page 394, the C# code sample incorrectly locks on a public instance where it should be private, it also uses an incorrect operator in the _evenCount variable. Change: // C# public void UpdateCount() { lock (this) { _count = _count + 1; if (Count % 2 == 0) // An even number { _evenCount = _evenCount + 1; } } }To: //C# private Object theLock = new Object(); public void UpdateCount() { lock (theLock) { _count = _count + 1; if (Count % 2 == 0) // An even number { _evenCount += 1; } } }

Microsoft Press  May 06, 2010 
Printed
Page 397

AddressOf missing from code sample On page 397, the third and fourth lines of the Visual Basic code sample are incorrect. Change: Dim firstStart As New ThreadStart(deadlock.First) Dim secondStart As New ThreadStart(deadlock.Second)To: Dim firstStart As New ThreadStart(AddressOf deadlock.First) Dim secondStart As New ThreadStart(AddressOf deadlock.Second)

Microsoft Press  May 06, 2010 
Printed
Page 410

Interlock class referenced in place of Interlocked class On page 410, the first bullet point reads: "To perform atomic math operations, use the Interlock class." It should read: "To perform atomic math operations, use the Interlocked class."

Microsoft Press  May 06, 2010 
Printed
Page 415

strm.Read method not required On page 415, the first line in the C# code sample under the "// Make the asynchronous call" comment is not required. Remove the following line of code: strm.Read(buffer, 0, buffer.Length);

Microsoft Press  May 06, 2010 
Printed
Page 419

Event referenced in place of class On page 419, the third sentence in the Windows Forms Application Exception Handling box reads: "You do this by registering for the ThreadException event on the Application event." It should read: "You do this by registering for the ThreadException event on the Application class."

Microsoft Press  May 06, 2010 
Printed
Page 421

Extra closing parenthesis included in code sample On page 421, the second code sample reads: ' VB Dim workItem As New WaitCallback(WorkWithParameter)) If Not ThreadPool.QueueUserWorkItem(workItem,"ThreadPooled") Then Console.WriteLine("Could not queue item") End If // C# WaitCallback workItem = new WaitCallback(WorkWithParameter)); if (!ThreadPool.QueueUserWorkItem(workItem, "ThreadPooled")) { Console.WriteLine("Could not queue item"); }It should read: ' VB Dim workItem As New WaitCallback(WorkWithParameter) If Not ThreadPool.QueueUserWorkItem(workItem,"ThreadPooled") Then Console.WriteLine("Could not queue item") End If // C# WaitCallback workItem = new WaitCallback(WorkWithParameter); if (!ThreadPool.QueueUserWorkItem(workItem, "ThreadPooled")) { Console.WriteLine("Could not queue item"); }

Microsoft Press  May 06, 2010 
Printed
Page 429

Thread execution behavior misrepresented On page 429, the last sentence of step 8 reads: "Note that some of the work items are executed on different threads." It should read: "Note that some of the work items may be executed on different threads."

Microsoft Press  May 06, 2010 
Printed
Page 438

Explanation of ASP.NET worker process incorrect On page 438, the second sentence in the first paragraph contains inconsistencies with ASP.NET.Change: "If 10 people visit an ASP.NET Web site simultaneously, ASP.NET will create a separate application domain for each user."To: "In one ASP.NET worker process there will be one application domain per web site. Users of the same web site will all run in the context of the same application domain."

Microsoft Press  May 06, 2010 
Printed
Page 456

Answer D of Question 3 partially incorrect On page 456, Answer D of Question 3 reads: "Create an instance of the AppDomainSetup class, and then set the Application-Base property. Pass the AppDomainSetup object to the AppDomain constructor." It should read: "Create an instance of the AppDomainSetup class, and then set the Application-Base property."

Microsoft Press  May 06, 2010 
Printed
Page 483

Configuration should be ConfigurationManager On page 483, the title of Table 9-2 is incorrect. Change: "Table 9-2 Configuration Properties and Methods" To: "Table 9-2 ConfigurationManager Properties and Methods"

Microsoft Press  May 06, 2010 
Printed
Page 512

The first paragraph on the page is not correct On page 512, the first paragraph on the page is a reproduction of the first paragraph on page 448. Please disregard this paragraph.

Microsoft Press  May 06, 2010 
Printed
Page 544-545

ConfigurationSection needs a custom constructor created On pages 544-545, steps 7 and 8 read: "7. Select either the Program.cs or Module1.vb file, and open it. Create a new static/shared method with no return type, and name it WriteSettings, as shown here: ' VB Private Shared Sub WriteSettings() End Sub // C# private static void WriteSettings() {}; 8. Insert the following code into the method: ' VB Private Shared Sub WriteSettings() Try Dim LabSection As ConfigurationSection Dim config As _ System.Configuration.Configuration = _ ConfigurationManager.OpenExeConfiguration( _ ConfigurationUserLevel.None) If config.Sections("LabSection") Is Nothing Then LabSection = New ConfigurationSection() config.Sections.Add("LabSection", ConfigurationSection) customSection.SectionInformation.ForceSave = True config.Save(ConfigurationSaveMode.Full) End If Catch ex As ApplicationException Console.WriteLine(ex.ToString()) End Try End Sub // C# try { ConfigurationSection LabSection; // Get the current configuration file. System.Configuration.Configuration config = ConfigurationManager. OpenExeConfiguration(ConfigurationUserLevel.None); if (config.Sections["LabSection"] == null) { customSection = new ConfigurationSection(); config.Sections.Add("LabSection", ConfigurationSection); customSection.SectionInformation.ForceSave = true; config.Save(ConfigurationSaveMode.Full); } } catch (ApplicationException ex) { Console.WriteLine(ex.ToString()); }" They should read: "7. Select either the Program.cs or Module1.vb file, and open it. Create a new static/shared method with no return type, and name it WriteSettings, as shown here: ' VB Private Shared Sub WriteSettings() End Sub // C# private static void WriteSettings() {}; Create a new public class called CustomSection, as shown here: ' VB Public Class CustomSection Inherits ConfigurationSection End Class //C# public class CustomSection : ConfigurationSection { public CustomSection() { } } 8. Insert the following code into the method: ' VB Try Dim customSection As CustomSection Dim config As _ System.Configuration.Configuration = _ ConfigurationManager.OpenExeConfiguration( _ ConfigurationUserLevel.None) If config.Sections("LabSection") Is Nothing Then customSection = New CustomSection() config.Sections.Add("LabSection", customSection) customSection.SectionInformation.ForceSave = True config.Save(ConfigurationSaveMode.Full) End If Catch ex As ApplicationException Console.WriteLine(ex.ToString()) End Try // C# try { CustomSection customSection; // Get the current configuration file. System.Configuration.Configuration config = ConfigurationManager. OpenExeConfiguration(ConfigurationUserLevel.None); if (config.Sections["LabSection"] == null) { customSection = new CustomSection(); config.Sections.Add("LabSection", customSection); customSection.SectionInformation.ForceSave = true; config.Save(ConfigurationSaveMode.Full); } } catch (ApplicationException ex) { Console.WriteLine(ex.ToString()); }"

Microsoft Press  May 06, 2010 
Printed
Page 549

Suggested practice heading correction On page 549, under the Suggested Practices heading it reads: "Create a Unit of Isolation for Common Language Runtime within a .NET Framework Application by Using Application Domains" It should read: "Embed configuration management functionality into a .NET Framework application."

Microsoft Press  May 06, 2010 
Printed
Page 564-565

The term methods is used in place of members On page 564, the last sentence reads: "Those methods are listed in Table 10-1." It should read: "Those members are listed in Table 10-1." On page 565, the title of Table 10-1 reads: "Methods of the Debugger Class" It should read: "Members of the Debugger Class"

Microsoft Press  May 06, 2010 
Printed
Page 568

Incorrect description of the WriteLine method of the Debug class On page 568, the description of the WriteLine method in Table 10-2 reads: "Writes information about attached Debug or Trace class listener objects in the Listeners collection." It should read: "Writes information to attached Debug or Trace class listener objects in the Listeners collection."

Microsoft Press  May 06, 2010 
Printed
Page 579

Method referenced in place of attribute On page 579, the second sentence of the DebuggerStepThroughAttribute section reads: "Unlike the DebuggerHiddenAttribute though, this method tells the Debugger to step over the code instead of hiding it from output." It should read: "Unlike the DebuggerHiddenAttribute though, this attribute tells the Debugger to step over the code instead of hiding it from output."

Microsoft Press  May 06, 2010 
Printed
Page 582-583

Methods referenced in place of members On page 582, the third sentence of the Trace Class section reads: "A list of the most useful methods is provided in Table 10-4." It should read: "A list of the most useful members is provided in Table 10-4." The title for Table 10-4 reads: "Methods of the Trace Class" It should read: "Members of the Trace Class" On page 583, the first sentence after Table 10-4 reads: "Because these methods are identical to those discussed in the earlier section about the Debug class or they are self explanatory, let’s move on." It should read: "Because these members are identical to those discussed in the earlier section about the Debug class or they are self explanatory, let’s move on."

Microsoft Press  May 06, 2010 
Printed
Page 590

MyListener not added to the Trace.Listeners collection On page 590, the code sample for step 4 reads: ' VB Trace.Listeners.Clear() Dim MyLog as New EventLog("Chapter10", "localhost", "Chapter10Demo") Trace.AutoFlush = True Dim MyListener as EventLogTraceListener = new EventLogTraceListener(MyLog) Trace.WriteLine("This is a test") // C# EventLog MyLog = new EventLog("Chapter10", "localhost", "Chapter10Demo"); Trace.AutoFlush = true; EventLogTraceListener MyListener = new EventLogTraceListener(MyLog); Trace.WriteLine("This is a test");It should read: ' VB Trace.Listeners.Clear() Dim MyLog as New EventLog("Chapter10", "localhost", "Chapter10Demo") Trace.AutoFlush = True Dim MyListener as EventLogTraceListener = new EventLogTraceListener(MyLog) Trace.Listeners.Add(MyListener) Trace.WriteLine("This is a test") // C# EventLog MyLog = new EventLog("Chapter10", "localhost", "Chapter10Demo"); Trace.AutoFlush = true; EventLogTraceListener MyListener = new EventLogTraceListener(MyLog); Trace.Listeners.Add(MyListener); Trace.WriteLine("This is a test");

Microsoft Press  May 06, 2010 
Printed
Page 601

The image in Figure 10-14 is incorrect On page 601, the image in Figure 10-14 should be replaced with the image from Figure 10-15 on page 607.

Microsoft Press  May 06, 2010 
Printed
Page 606

Incorrect variable declaration in second code sample On page 606, the third line of the second code sample reads: String FileName = "C:ProcessStartDemo.exe"It should read: Dim FileName As String = "C:ProcessStartDemo.exe"

Microsoft Press  May 06, 2010 
Printed
Page 607

Incorrect Figure 10-15 On page 607, Figure 10-15 is incorrect. Please disregard this figure.

Microsoft Press  May 06, 2010 
Printed
Page 612

XmlTextWriterListener should be XmlWriterTraceListener On page 612, the fourth sentence in the second bullet point includes an incorrect reference to XmlTextWriterListener. Change: "The XmlTextWriterListener allows Debug and Trace output to be written with detailed information stored in predefined Xml attributes." To: "The XmlWriterTraceListener allows Debug and Trace output to be written with detailed information stored in predefined Xml attributes."

Microsoft Press  May 06, 2010 
Printed
Page 619

IP_Address used in place of IP_Enabled On page 619, the 28th line of the code sample reads: if (Convert.ToBoolean(DemoManager[IP_Address]) == true)It should read: if (Convert.ToBoolean(DemoManager[IP_Enabled]) == true)

Microsoft Press  May 06, 2010 
Printed
Page 733

Managers group referenced in place of Accounting group On page 733, the last sentence reads: "Even though Mary is a member of the Managers group, and the Managers group has Full Control privileges, the Deny ACE means that all members of the Managers group are denied access to the file." It should read: "Even though Mary is a member of the Managers group, and the Managers group has Full Control privileges, the Deny ACE means that all members of the Accounting group are denied access to the file."

Microsoft Press  May 06, 2010 
Printed
Page 790

.NET application referenced in place of COM application On page 790, the description of the Type Library Exporter in Table 13-1 reads: "Creates a COM type library that can be consumed by a .NET application" It should read: "Creates a COM type library that can be consumed by a COM application"

Microsoft Press  May 06, 2010 
Printed
Page 799-800

Unneeded using statements in C# code samples On pages 799-800, the first three lines of the C# code sample reads: using System; using System.Collections.Generic; using System.Text;These lines should be removed.

Microsoft Press  May 06, 2010 
Printed
Page 816

"Layout.Explicit" used in place of "LayoutKind.Explicit" On page 816, the section heading at the top of the page reads: "Layout.Explicit" It should read: "LayoutKind.Explicit"

Microsoft Press  May 06, 2010 
Printed
Page 834

Code sample included in the wrong location On page 834, the second and third paragraphs read: "More interesting are the GetCallingAssembly, GetEntryAssembly, and GetExecutingAssembly calls. These methods allow you to retrieve an instance of the Assembly class for assemblies that are part of the current call stack. GetEntryAssembly returns an instance of the assembly that contains the start-up method (usually the executable assembly for a desktop application), as shown in the following example: ' VB Dim theAssembly As Assembly = Assembly.GetExecutingAssembly // C# Assembly theAssembly = Assembly.GetExecutingAssembly();You can retrieve the assembly for the currently running code by calling GetExecutingAssembly. In contrast, the GetCallingAssembly retrieves an instance of the Assembly class for the method one level up in the call stack. In other words, it retrieves the assembly that contains the method that called the currently executing code." They should read: "More interesting are the GetCallingAssembly, GetEntryAssembly, and GetExecutingAssembly calls. These methods allow you to retrieve an instance of the Assembly class for assemblies that are part of the current call stack. GetEntryAssembly returns an instance of the assembly that contains the start-up method (usually the executable assembly for a desktop application). You can retrieve the assembly for the currently running code by calling GetExecutingAssembly. In contrast, the GetCallingAssembly retrieves an instance of the Assembly class for the method one level up in the call stack. In other words, it retrieves the assembly that contains the method that called the currently executing code. See the following example: ' VB Dim theAssembly As Assembly = Assembly.GetExecutingAssembly // C# Assembly theAssembly = Assembly.GetExecutingAssembly();"

Microsoft Press  May 06, 2010 
Printed
Page 838

ShowAssembly method referenced in place of ShowAssemblyInfo On page 838, steps 3, 4, 7 and 9 read: "3. Create a new static method called ShowAssembly that takes an instance of the Assembly class as a parameter. 4. Inside the new ShowAssembly method, write out the FullName, GlobalAssemblyCache, Location, and ImageRuntimeVersion properties to the console. 7. Call the ShowAssembly method with the new assembly instance. 9. Call the ShowAssembly method again with this instance of the Assembly instance from the executing assembly. Your code might look something like this:" They should read: "3. Create a new static method called ShowAssemblyInfo that takes an instance of the Assembly class as a parameter. 4. Inside the new ShowAssemblyInfo method, write out the FullName, GlobalAssemblyCache, Location, and ImageRuntimeVersion properties to the console. 7. Call the ShowAssemblyInfo method with the new assembly instance. 9. Call the ShowAssemblyInfo method again with the Assembly instance from the executing assembly. Your code might look something like this:"

Microsoft Press  May 06, 2010 
Printed
Page 852

Class referenced in place of instance On page 852, the sentence following the bulleted list in the Getting Types section reads: "When working with an Assembly class, you can ask it for all the Types in all the modules of the assembly by calling the GetTypes method:" It should read: "When working with an Assembly instance, you can ask it for all the Types in all the modules of the assembly by calling the GetTypes method:"

Microsoft Press  May 06, 2010 
Printed
Page 861

Enumeration referenced in place of property On page 861, the first two sentences following Table 14-9 read: "You can see the type of member each of these MemberInfo objects is by checking the MemberType enumeration on the MemberInfo class. This enumeration contains all the different types of members that a MemberInfo object can represent." They should read: "You can see the type of member each of these MemberInfo objects is by checking the MemberType property on the MemberInfo class. This property contains an enumeration value that can represent all the different types of members that a MemberInfo object can represent."

Microsoft Press  May 06, 2010 
Printed
Page 864-865

BindingFlag referenced in place of BindingFlags On pages 864, step 4 reads: "Create a local BindingFlag variable, and store the flags to get only declared, public instance members." It should read: "Create a local BindingFlags variable, and store the flags to get only declared, public instance members." On page 865, step 10 reads: "Continue inside the iteration loop, and get all the members from each type using the BindingFlag variable from step 4." It should read: "Continue inside the iteration loop, and get all the members from each type using the BindingFlags variable from step 4."

Microsoft Press  May 06, 2010 
Printed
Page 871

Object referenced in place of class On page 871, the first sentence following the second code sample reads: "Because this is a static method, you specify a null in the parameter that would ordinarily take the instance of the object on which to run the method." It should read: "Because this is a static method, you specify a null in the parameter that would ordinarily take the instance of the class on which to run the method."

Microsoft Press  May 06, 2010 
Printed
Page 876

EventBulder class referenced in place of EventBuilder class On page 876, the fourth name in Table 14-11 reads: "EventBulder" It should read: "EventBuilder"

Microsoft Press  May 06, 2010 
Printed
Page 881

PropertyAttribute referenced in place of PropertyAttributes On page 881, the first sentence following the third code sample reads: "Although defining the property is much like defining a method, the PropertyAttribute enumeration does not allow defining as many aspects of the properties as you might expect." It shoulld read: "Although defining the property is much like defining a method, the PropertyAttributes enumeration does not allow defining as many aspects of the properties as you might expect."

Microsoft Press  May 06, 2010 
Printed
Page 887

Incorrect scope given for case scenarios On page 887, the first sentence reads: "In the following case scenario, you will apply what you’ve learned about how to use application domains and services." It should read: "In the following case scenario, you will apply what you’ve learned about the topics of this chapter."

Microsoft Press  May 06, 2010 
Printed
Page 930

Error in C# in code sample On page 930, the first line in the second C# code snippet on page 930 reads: CompareInfo DemoInfo = Thread.CurrentThread.CurrentCulture.CompareInfo;It should read: CompareInfo DemoInfo = new CultureInfo(“en-US”).CompareInfo;

Microsoft Press  May 06, 2010 
Printed
Page 936

Culture class listed incorrectly in first NOTE section On page 936, under the NOTE .NET 2.0 section it reads: "The CultureRegionAndInfoBuilder class is new in .NET 2.0" It should read: "The CultureAndRegionInfoBuilder class is new in .NET 2.0"

Microsoft Press  May 06, 2010 
Printed
Page 946

Creating items referenced rather than passing them On page 946, the answers to question 4 read: "A. Incorrect: You could create a reference class; however, it could be modified when passed to a procedure. B. Incorrect: You cannot create a reference structure. C. Incorrect: You could create a value class; however, structures tend to be more efficient. D. Correct: Value structures are typically the most efficient." They should read: "A. Incorrect: You could pass a class by reference; however, it could be modified when passed to a procedure. B. Incorrect: You could pass a structure by reference; however, it could be modified when passed to a procedure. C. Incorrect: You could pass a class by value; however passing structures by value tend to be more efficient. D. Correct: Structures passed by value are typically the most efficient."

Microsoft Press  May 06, 2010 
Printed
Page 953

Answer explanation incorrect On page 953, Chapter 3, Lesson 1, Question 2 answer A reads: "A. Correct: ISerializable is an interface that you can implement to perform custom serialization. It is not an attribute." It should read: "A. Correct: This code sample works correctly by using the RegexOptions.Multiline option to process multiline input."

Microsoft Press  May 06, 2010 
Printed
Page 954

Answer E is incorrect On page 954, Answer E for Question 4 should be incorrect. Change: "4. Correct Answers: A, C, and E" To: "4. Correct Answers: A and C" Change: "E. Correct: This string does match the regular expression." To: "E. Incorrect: This string does not match the regular expression because the first character must be "a"."

Microsoft Press  May 06, 2010 
Printed
Page 963

Incorrect .NET version referenced in Scenario 2, answer 1 On page 963, Answer 1 for Case Scenario 2 reads: "Yes, BinaryFormatter can deserialize objects serialized with .NET 0." It should read: "Yes, BinaryFormatter can deserialize objects serialized with .NET 1.0."

Microsoft Press  May 06, 2010 
Printed
Page 977

.NET Framework 0 referenced in place of .NET Framework 2.0 On page 977, answers A and B to lesson 3, question 1 read: "A. Incorrect: Processes can be viewed with the Process class but not with the .NET Framework 0 Configuration tool. B. Incorrect: Services cannot be viewed with the .NET Framework 0 Configuration tool." They should read: "A. Incorrect: Processes can be viewed with the Process class but not with the .NET Framework 2.0 Configuration tool. B. Incorrect: Services cannot be viewed with the .NET Framework 2.0 Configuration tool."

Microsoft Press  May 06, 2010 
Printed
Page 980

RemoveLog should be DeleteLog On page 980, answer D to question 4 refers to RemoveLog rather than DeleteLog. Change: "D. Incorrect: There is no RemoveLog method of the EventLog class." To: "D. Incorrect: There is no DeleteLog method of the EventLog class."

Microsoft Press  May 06, 2010 
Printed
Page 996

"overcode" used in place of "overcome" On page 996, in Question 2, Answer A, the second sentence reads: "Although the types might vary, the MarshalAs method can be used to overcode this." It should read: "Although the types might vary, the MarshalAs method can be used to overcome this."

Microsoft Press  May 06, 2010 
Printed
Page 1002

Answers to Question 1 are partially incorrect On page 1002, the answer to Question 1 of Lesson 2 is incorrect and the explanations of the other answers are partially incorrect. Change: "1. Correct Answer: B A. Incorrect: The MailMessage class does not have a Send method. B. Correct: To send a message, create an instance of SmtpClient and call the Send method. C. Incorrect: There is no SmtpServer class. D. Incorrect: There is no MailClient class." To: "1. Correct Answer: C A. Incorrect: The MailMessage class does not have a Send method. B. Incorrect: SmtpClient.Send does not wait for the transmission to complete before proceeding. C. Correct: SmtpClient.SendAsync sends an e-mail message and then waits for the transmission to complete before proceeding. D. Incorrect: There is no MailMessage class."

Microsoft Press  May 06, 2010 
Printed
Page 1007

The Bitmap glossary entry is not identified as such On page 1007, the third-to-last entry on the page reads: "Located in the System.Drawing namespace, this class provides methods for loading and saving images, and editing individual pixels." It should read: "Bitmap Located in the System.Drawing namespace, this class provides methods for loading and saving images, and editing individual pixels."

Microsoft Press  May 06, 2010 
Printed
Page 1009

The Debug and Debugger glossary entries are not identified as such On page 1009, the two entries below "Data Encryption Standard (DES)" read: "A specific constant defined in an application that allows Debugger objects to be attached to code. A class that provides access to the default debugger attached to an application." They should read: "Debug A specific constant defined in an application that allows Debugger objects to be attached to code. Debugger A class that provides access to the default debugger attached to an application."

Microsoft Press  May 06, 2010 
Printed
Page 1011

The LocalService and LocalSystem glossary entries are not identified as such On page 1011, the two entries after "localization" read: "A service account that runs with very limited privileges. A service account that runs with almost unlimited privileges." They should read: "LocalService A service account that runs with very limited privileges. LocalSystem A service account that runs with almost unlimited privileges."

Microsoft Press  May 06, 2010 
Printed
Page 1012

The NetworkService glossary entry is not identified as such On page 1012, the entry after ".NET Framework 2.0 Configuration tool" reads: "A service account that is capable of authenticating to remote computers." It should read: "NetworkService A service account that is capable of authenticating to remote computers."

Microsoft Press  May 06, 2010 
Printed
Page 1013

The SoapFormatter glossary entry is not identified as such On page 1013, the second-to-last entry on the page reads: "Located in the System.Runtime.Serialization.Formatters.Soap namespace, this XMLbased formatter is the most reliable way to serialize objects that will be transmitted across a network or read by non–.NET Framework applications. SoapFormatter is more likely to successfully traverse firewalls than BinaryFormatter." It should read: "SoapFormatter Located in the System.Runtime.Serialization.Formatters.Soap namespace, this XMLbased formatter is the most reliable way to serialize objects that will be transmitted across a network or read by non–.NET Framework applications. SoapFormatter is more likely to successfully traverse firewalls than BinaryFormatter."

Microsoft Press  May 06, 2010