Game Development Community

Works in Windows, "Code 4" error on Xbox 360

by Dave Calabrese · in Torque X 2D · 06/25/2009 (3:03 am) · 10 replies

I'm working on a small project, and when testing on Windows I found it worked fine - stand alone, through Visual C# Express, everything. However, when I perform "Create Copy of Project for Xbox 360", rebuild, then deploy to the console, the game crashes right after it gets past the "XNA Creators Club" logo screen with a "Code 4" error.

I'm still wrapping my head around XNA development... from what I can tell, this means that I am incorrectly building the game for the wrong type of target, however I haven't been able to determine what the correct settings are.

Anyone with a little more experience here - think you could shine some light in the correct direction so I can better determine what is going on here and how I may fix it?

Thanks in advance!

#1
06/25/2009 (6:29 am)
How can I not help a fellow Pittsburgher named Dave lol.

A lot of things can cause this. I've had this happen on several occasions. One time, I found out that it had to do with me setting the particle life longer than the emitter life. Worked fine on Windows, not on Xbox. Other times, it was caused by a variable referencing a null value.

Just remember, on Xbox, the code has to be extremely tight. Windows is much more forgiving.

#2
06/25/2009 (12:09 pm)
Okay... that makes sense.
Now I'm trying to rip out / comment out everything in the game until it works and no luck yet. Is there any way to show a debug output from the Xbox360 while the game is running? I can only seem to get that also on Windows currently...
#3
06/25/2009 (1:12 pm)
Not that I know of :( .. though if I'm wrong that would be good to know. Maybe John K. can chime in here. Error 4 is such a non-helpful way to display an error!
#4
06/25/2009 (1:29 pm)
I found this article about debugging on the Xbox360. Sounds like it should be possible, though it isn't working:

http://msdn.microsoft.com/en-us/library/bb199628(XNAGameStudio.31).aspx

Following that, I get the following error:

"Visual Studio cannot start debugging because the debug target 'C:\Projects\MyGame\Game\bin\X86\Debug\StarterGame2D.exe' is missing. Please build the project and retry, or set the OutputPath and AssemblyName properties to point at the correct location for the target assembly."

What's interesting is that the game does deploy to the Xbox360 - however it does not get run, and it appears as if Visual Studio is trying to load a Windows version into the debugger even though we are building and running the Xbox360 target.
#5
06/25/2009 (2:35 pm)
Yes, it should be possible to debug while running on the Xbox. I usually have the best luck by right clicking on the Xbox project and selecting debug start new instance rather than hitting F5 or the run button on the toolbar. This should then deploy to the Xbox and bring up your debugger where you can set break points and step through the code while it is running on the Xbox.
#6
06/25/2009 (3:05 pm)
Hey, that worked, Jake! That got it to start up in debug mode on the Xbox360.

So, next step! Received an odd error when the game tried to run on the 360 in debug mode. I got this error as a dialog popup in Visual C#...

"There is no source code available for the current location."

This one caught me by surprise... the source code is all in the project. I tried output types of Console Application and Windows Application, however both do this.

Thoughts?
#7
06/25/2009 (3:13 pm)
Easiest thing to do to compare a working application, would be to create a new Starter2D application. Don't change anything, right click on project and make copy for Xbox360. At this point, you should be able to deploy and run the Xbox version with no problem. I would take a look the configuration of the two projects and compare them to your own project to see what is different. It is probably just something simple.
#8
01/22/2011 (1:26 pm)
did you ever figure this out dave? Im having the same problem. I have a platformer and Xbox load and goes to the Level Select Screen and load the first level it crash the game. Works great on PC but not on Xbox :( Its the only thing keeping me from submitting it to XBLIG.
#9
01/22/2011 (3:43 pm)
Aaron, you want to use debug mode to catch those type's of bugs, without stepping into the code with a breakpoint, it is anybody's guess what is causing your crash.
#10
01/22/2011 (7:43 pm)
Are you running your game at 1080p on the XBox? That can cause a crash. You must use 720p mode:

From torqueSettings.xml
<XboxGraphicsManagerSettings>
    <PreferMultiSampling>false</PreferMultiSampling>
    <UseDisplaySizeForBackbuffer>false</UseDisplaySizeForBackbuffer>
    <PreferredBackBufferHeight>720</PreferredBackBufferHeight>
    <PreferredBackBufferWidth>1280</PreferredBackBufferWidth>
    <SynchronizeWithVerticalRetrace>true</SynchronizeWithVerticalRetrace>
  </XboxGraphicsManagerSettings>