XNA Essentials

Game Programming for Xbox 360, PC + Windows Phone


Editing error's and my question's

Hi Chad,

             I am the guy that wrote that review on amazon earlier today and you told me to come here. So here I am and I already see you answered some of the editing errors I found from the performance chapter.

Here is the big error I have right now Page 62 code:

graphics.GraphicsDevice.VertexDeclaration = new
                  Vertex PositionNormalTexture.VertexElements);

BasicEffect effect = new BasicEffect(graphics.GraphicsDevice, null);

effect.Projection = projection;
effect.View = view;

On the disc you have:

graphics.GraphicsDevice.VertexDeclaration = vertexDeclaration;

effect.Projection = projection;
effect.View = view;

The book code does not work so I can only assume the code on the CD is correct because the code in the book has errors all over the place.


I see now what you mean by adding it as a reference. I am not really sure how to do it as every time I try I cannot find the file. This will take me some time but at least I have a better understanding of what is going on. I appreciate the help.

Pelham - Tuesday, July 21, 2009 @ 12:11 AM

Re: Editing error's and my question's

The console application (XNAPerfStarter) is simply a harness to execute the XNA Framework commands we created in the XNAPerformanceChecker XNA Game Library. The XNA Game Library already has the references it needs. So if you create the project as described (as a XNA Windows Game Library) then it will have all the references it needs.

The console app itself (XNAPerfStarter) does not need any XNA references. It simply needs the XNAPerformanceChecker library as a reference. As long as both projects are in the same solution (as they are on the CD) then it will be under the Projects tab.

If you look at the code from the CD (especially if you overwrite the .csproj file that you can download from the Errata page) then you will see how the references are listed in the different projects:

XNAPerformanceChecker (XNA Windows Game Library) references Microsoft.Xna.Framework and Microsoft.Xna.Framework.Game.

XNAPerfStarter (Windows Console Application) references the above project XNAPerformanceChecker.

You will not find XNAPerformanceChecker under the .NET tab of the references it will only be in the Projects tab of the dialog if both projects are in the same solution.


Chad Carter - Thursday, July 23, 2009 @ 9:27 AM

Re: Editing error's and my question's

That makes perfect sense actually. My problem still does not disappear with that understanding. Under the projects tab there is no XNAPerformanceChecker(there are actually no files under the projects tab what so ever.).......that being said I must have done something horribly wrong. I say that because it does not even show up when I go browsing for it in its folder. I am not sure what I have done but it is surely a class A screw up. *grabs swim suit* well time to dive back in *splash*



P.S. I am really sorry about being so thick thick skulled on this and appreciate the time you have taken to help me understand.

Pelham - Thursday, July 23, 2009 @ 11:37 AM

Re: Editing error's and my question's

Since you aren't seeing anything in the Projects tab of the References dialog it means that you are not loading both projects in the same solution.

Make sure you have BOTH projects in a single solution. If you don't then you will need to compile the Windows Game Library first and then in the Console application, browse for the assembly (.dll) in the Library's /bin/debug folder.

No problem on the help. 

Chad Carter - Thursday, July 23, 2009 @ 6:53 PM

Re: Editing error's and my question's

Welcome to the site. I'm glad you asked the question here. 

The code on page 62 is actually fine. It just isn't performant. By working through the book you will come to page 73 where we change the code. We introduce the vertexDeclaration variable and move the effect local variable to a private member field.

To begin with we are simply getting the first demo running. We then check performance and see different items we can do to help the application perform better.

The CD is a snapshot of the code in it's latest form. As you work through the chapter the code at any point in the chapter may not match the end result of the code on the CD. However, by the time the chapter is finished it should definitely match.

Hopefully this helps. If not, please let me know and I'll be glad to clarify.




Edit: You can find the Xna assemblies by making sure the .NET tab is selected after you click "Add Reference" from the context menu. (You bring up the menu by right clicking the References tree node in the Solution Explorer of the IDE)

You can scroll down and see all of the Microsoft.Xna.* assemblies. 

Chad Carter - Tuesday, July 21, 2009 @ 8:22 AM

Re: Editing error's and my question's

oh that reference......I was trying to reference CheckPerformance.cs. I know I know it did not sound right in my head but that is what I thought you were talking about.That makes so much more sense now....on the CD though it does reference XNACheckPerformance.....sorry I am somewhat daft at times.

Pelham - Tuesday, July 21, 2009 @ 12:28 PM

Re: Editing error's and my question's


I just came from the Amazon site where I saw you gave the book a 2 star rating. I have read this thread and now I'm wondering what your thoughts are. Are you going to update your review to include more stars, or do you still feel it is a 2 star book? I'm trying to decide if I will buy this book or not. 


hamlet - Tuesday, July 21, 2009 @ 10:11 PM

Re: Editing error's and my question's

I think I am going to go back and re-review the book on amazon. Primarily I think I need to do Mr. Carter some justice and break down my ratting a bit more so that it gives a better picture. I would say this book is a solid 3 stars out of 5 and if you can deal with bad editing then it is about a 4.5 out of 5.


I think Mr. Carter reconizes that there is a lot of bad editing and has went out of his way with this site and these forums to help sus out the bad editing and help people understnad. Mr. Carter himself gets a 5/5 for going to such lengths.


That said I am still confused about how the reference works as my current understanding does not match what is on the CD but I think it will all be figured out in time.

Pelham - Wednesday, July 22, 2009 @ 2:41 AM

Re: Editing error's and my question's



In order to add the reference we need to do the following:

The library itself has all of the XNA specific code in it. So we right click on the References node and select Add Reference. We then make sure the .NET tab is selected and we scroll down and add the appropriate references. The consumer of the library (XNAPerfStarter) is a console app and simply needs a reference to the class we made. We do this by right clicking on the References node of that project and then making sure the Projects tab is selected. Now we can see the XNAPerformanceChecker project listed and can select it.

When I loaded the version of the project on the CD I can see that the XNAPerformanceChecker.csproj actually is based on the CTP (Community Technical Preview) of XNA GS 3.0 and not the final release. This is causing the CD version of the project to not find the references properly. I have updated the Errata to include the new .csproj file.

I would like to blame the issues on bad editing and while certain things "should" have been caught, it really falls on me that these issues exists. My main concern is that people get use out of the material.

Please let me know if you have questions regarding adding references or anything else.




Chad Carter - Wednesday, July 22, 2009 @ 9:24 AM

Re: Editing error's and my question's

I understand what, in theory, should work to get the reference in there. My current problem is that it is not on the .net list when I go searching. I even went through the browse tab and went into the XNAPerformance project folder and it is still not there. As soon as you mentioned referencing it it dinged in my head what the book was talking about and made perfect sense. My problem is that I have done something wrong somewhere and the reference is not showing up and I do not know why. This is nothing to do with the book and just me being a silly novice programmer and making silly mistakes that any self-respecting programmer would laugh at. Now back to my C# book on references..........mmmm interesting...

Pelham - Wednesday, July 22, 2009 @ 11:41 AM

Re: Editing error's and my question's

Interesting. If you have Microsoft XNA Game Studio installed then you should definitely see the Microsoft.Xna.* assemblies in the .NET tab on the References dialog box. Visual Studio picks them up automatically when XNA Game Studio is installed. The XNA assemblies won't be located in the local projects (i.e. the XNAPerformance folder) but in a folder similar to:

C:\Program Files\Microsoft XNA\XNA Game Studio\v3.0\References\Windows\x86

Of course you shouldn't have to browse for them as they should definitely show up in the .NET tab.

Chad Carter - Wednesday, July 22, 2009 @ 4:36 PM

Re: Editing error's and my question's

well I can see Microsoft.XNA and its 100 different variations but I do not see is XNAPerformancechecker class that I made in the previous section and that is what is referenced on the code on the CD. None of the Microsoft.XNA.Framework or anything like it are referenced into the console project. I was thinking if I did reference them into the project then I could just add the class as an object. I had it like that at one point and the program reconized the line:


XNAPerformanceChecker.CheckPerformance cp =

new XNAPerformanceChecker.CheckPerformance();

but it did not understand what XNA was, so now I am going back and adding references to the XNA framework hoping that solves the issue. But like I said that is not how it is done in the examples on the CD.

Pelham - Thursday, July 23, 2009 @ 12:21 AM