Errata

Programming C# 4.0

Errata for Programming C# 4.0

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

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

Version Location Description Submitted by Date submitted
Other Digital Version Example 11-1
Example 11-1. Main mehtod of duplicate file finder

in the example there is an if statement that looks like this
if (args.Length > 1)
{

later nested in the if statement is another if like the following
if (args.Length < 2)
{

Since args.Length is an integer value it should never be possible to be greater than 1, but less than 2.
I'm sure the first statement should have been >= 1

Anonymous  Nov 09, 2010 
Printed Page 37
End of second paragraph in the "Order of Evaluation' block

Reads:
", because division has a higher precedence than division."

when it should read:
", because division has a higher precedence than addition."

based on the example.

Eric Reiss  Apr 11, 2011 
PDF Page 98
last paragraph

Text:

This one returns a bool to indicate whether we?re safe (true) or not (false).

This the wrong way around (Method is called "TooClose", after all), should be

This one returns a bool to indicate whether we?re safe (false) or not (true).

Hauke Hildebrandt  Sep 08, 2010 
PDF Page 103
code sample

Text doesn't state where the "Point" class comes from - is it from System.Drawing? Should give the appropriate "using" statement.

Hauke Hildebrandt  Sep 08, 2010 
PDF Page 104
example code top of page

To make use of the "Point" class in this text you must add the "using System.Windows" namespace, you may also need to add the reference this namespace resides in. To do this in Visual Studio click on Reference in Solution Explorer, choose "Add Reference", click on the .NET tab, and select "WindowsBase" from the list.

Gilbert Robinson  Dec 02, 2010 
PDF Page 117
last paragraph (code sample)

Console output is wrong, instead of

Joe is putting out the fire!
Training the hose on the fire.
The fire is going out.

as stated in the book, it really gives

Joe is putting out the fire!
The fire is going out.
Training the hose on the fire.

Also, the text seems to assume that nothing has changed ("Unit tests pass"), but the order *has* changed.

Hauke Hildebrandt  Sep 08, 2010 
Printed Page 137
3rd paragraph from the bottom

"Add the following line" comes *after* the line we're supposed to add. So it should be "Add the above line" or "Add that last line" or something line that, but not "following".

David A. Black  Nov 23, 2010 
PDF Page 165
code sample

Sample code does not work for me:

1) delegate LogTextProvider has the same name as the corresponding property, compiler flags ambiuity

2) both should probably have the same visibility

Hauke Hildebrandt  Sep 09, 2010 
PDF Page 169
code sample at top

Following the text there will still be the TrademarkFilter added to the process queue (the text does not suggest to delete it). Thi swill give an additional "(Document 3)" at the end of the output.

Hauke Hildebrandt  Sep 09, 2010 
Printed Page 174
Middle of the page

Just before example 5-23, you say "When you subscribe to an event your
subscriber implicitly holds a reference to thepublisher.". I think that should
read "the publisher implicitly holds a reference to the subscriber". I find
that to be a very important point as in my experience, this was a common cause
for memory leaks when small objects don't unsubscribe from events in their
dispose(). Not something I see recommended as good practice very often.

Anonymous  Apr 12, 2011 
PDF Page 179
console output at bottom

Once again the output does not match the code!

1) First two lines missing
2) "Tool2 has seen processing, and not canceled." is rather "Tool2 has seen processing, and canceled."

Also, by the way, it should be mentioned that CancelEventArgs requires a "using System.ComponentModel;"

Hauke Hildebrandt  Sep 09, 2010 
Printed Page 308
5th paragraph

In the last paragraph on the page there are two references to the structure KeyValuePair which are incorrectly written as KeyPairValue.

Michael Jordan  Dec 09, 2011 
Printed Page 350
Example 10-65

The Console.WriteLine statements read:

Console.WriteLine(builder1.Capacity);
Console.WriteLine(builder1.Length);

Console.WriteLine(builder2.Capacity);
Console.WriteLine(builder1.Length);

The second writeline statement in the second group references the first builder object when it should be the second. It should read:

Console.WriteLine(builder1.Capacity);
Console.WriteLine(builder1.Length);

Console.WriteLine(builder2.Capacity);
Console.WriteLine(builder2.Length);

Eric Reiss  Jul 29, 2011 
Printed Page 355-356
Examples 10-75 and 10-76

The output of these two examples does not describe the removal of the "blank lines" very well. The second example removes lines that have a null as well as the "" and String.Empty of the first example but with the way the lines break from the text to the output of the examples and with the unfortunate way that the output of Example 10-75 spans two pages, the removal of the blank lines is confusing.

Example 10-75 has one line of space between the output and the text as follows.


If we build and run, the output to the console looks like this:

To be, or not to be--that is the question:


So this example removes 8 blank lines but not the null. So assuming the initial blank line is to separate the text from the output, should there be a second blank line.

The output of Example 10-76 removes the null and the debug output reports 9 lines removed but now it has two blank lines separating the text from the output as below.

been ignored:


To be, or not to be--that is the question:

Seems backward and again the placement of the page break does not help.

Eric Reiss  Jul 29, 2011 
Printed Page 357
Fourth line from bottom

In this sample output, "nobler" should be "nobelr", because the sample code does not include the replace operation.

The same is true of sample output in the middle of page 358.

David A. Black  Dec 08, 2010 
Printed Page 361
Last line of 3rd paragraph

ASCII backspace code should be 0x08, not 0x09.

David A. Black  Dec 08, 2010 
Printed Page 411
Example 11-38

The parameter list for the method in Example 11-38 has a parameter that isn't used what so ever. That of "List<FileContents> files".

Rune Star  Jun 16, 2011 
Printed Page 483
Example 13-2

example 13-2 has "Debug.WriteLine("{0}: {1}", from, note);" which does not compile. It needs to use String.Format().

Anonymous  Apr 12, 2011 
Printed Page 509
"Duplex Client"

Full duplex xxample code, when locally built on Windows XP professional version 2002 SP3, fails when client attempts to connect to host. Could this be a local policy problem or a problem in the example itself?

From the client invocation, where I enter "N1" as the name:

Please enter your name:
N1

Unhandled Exception: System.ServiceModel.AddressAlreadyInUseException: HTTP could not register URL http://+:80/Temporary_Listen_Addresses/e5ec59bb-ac66-4a12-936a-b7041396c389/ because TCP port 80 is being used by another application. ---> System.Net.HttpListenerException: The process cannot access the file because it is being used by another process
at System.Net.HttpListener.AddAllPrefixes()
at System.Net.HttpListener.Start()
at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
--- End of inner exception stack trace ---
at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.HttpChannelListener.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.DatagramChannelDemuxer`2.OnOuterListenerOpen(ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout)
at System.ServiceModel.Channels.SingletonChannelListener`3.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.LayeredChannelListener`1.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.DatagramChannelDemuxer`2.OnOuterListenerOpen(ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout)
at System.ServiceModel.Channels.SingletonChannelListener`3.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.InternalDuplexChannelFactory.OnOpen(TimeSpantimeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ReliableChannelFactory`2.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelFactory.TypedServiceChannelFactory`1.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ChannelFactory.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ChannelFactory.EnsureOpened()
at System.ServiceModel.DuplexChannelFactory`1.CreateChannel(InstanceContext callbackInstance, EndpointAddress address, Uri via)
at System.ServiceModel.DuplexChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
at System.ServiceModel.ChannelFactory`1.CreateChannel()
at System.ServiceModel.DuplexClientBase`1.CreateChannel()
at System.ServiceModel.ClientBase`1.CreateChannelInternal()
at System.ServiceModel.ClientBase`1.get_Channel()
at ChatClient.ChatService.ChatServiceClient.Connect(String name) in C:\notes\2010\11\ProgrammingCSharp4\Chapter 13\WcfDuplex\WcfChat\ChatClient\Service References\ChatService\Reference.cs:line 64
at ChatClient.Program.Main(String[] args) in C:\notes\2010\11\ProgrammingCSharp4\Chapter 13\WcfDuplex\WcfChat\ChatClient\Program.cs:line 20


PhilA  Nov 10, 2010 
Printed Page 522
Example 13-21

The CookieContainer must be associated with the initial HttpWebRequest for there to be values in resp.Cookie following the response. This is not done in Example 13-21

// Example 13-21. Getting the cookies from a response
CookieContainer container = new CookieContainer();

Uri address = new Uri("http://amazon.com/");
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(address);
// following line is needed
req.CookieContainer = container;
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();


CookieCollection cookies = resp.Cookies;
container.Add(address, cookies);


See MSDN HttpWebRequest.CookieContainer Property

Mark Fox  Jan 05, 2012 
Printed Page 548
First full sentence at the top of the page

The book makes the following statement regarding installing and setting up SQL Server 2008 Express; "Since that could well happen again between us finishing the book and you reading it, we're providing the instructions as part of the sample code you can download for this book from the O'Reilly website so that we can update them when necessary."

I couldn't find this instruction information anywhere on the O'Reilly website. I looked in the sample code files, the errata area and the main web page for the book and did not find any information on installing and setting up SQL Server 2008 Express. Where is this information located?

Michael Jordan  Jan 13, 2012 
Printed Page 651
Entire page

Pages 651-698 are missing. In their place appears a repeat of pages 603-650.

Will Montgomery  Aug 29, 2010 
Printed Page 651
Entire page 651

Pages 651-698 are missing. In their place appears to be a repeat of pages 603-650.

Basil Eliopoulos  Sep 13, 2010 
Printed Page 651
Missing Page

Half of chapters 16 & 18 and all of 17 (Pages 651-698) are missing. In their place appears a repeat of pages 603-650.

Robert S.  Sep 16, 2010 
Printed Page 757
top of page

example 20-17 sets the Text property to "Text and graphics" but figure 20-12 displays "Content" as the text.

Anonymous  Apr 12, 2011 
Printed Page 760-761
5th line of example 20-19 and first sentence of first paragraph on page 761

The name space of the classes in print are different from the example code for the book. The book has xmlns:app="clr-namespace:SlUcExample" but the example code from the web site has xmlns:app="clr-namespace:UserControlComposition". References to SlUcExample should be changed to UserControlComposition to match the example code.

Michael Jordan  Jan 30, 2012