Debugging the content pipeline


Content pipeline importers and processors run inside Visual Studio
as part of building your game. This means you can’t just debug into
them like you would for normal game code.

Fortunately, the CLR
provides a handy way of hooking a debugger up to any managed program
you like. You just need to modify your processor code, adding this line
at the point where you want to start debugging:

    System.Diagnostics.Debugger.Launch();

Now when you build your game, when the processor hits this line it
will pop up a window titled “Visual Studio Just-In-Time Debugger”,
listing all the possible debuggers that are installed on your system.
You will generally want to pick “New instance of Microsoft CLR Debugger
2005”, which will connect to your processor and let you debug what is
going on during your content build.


Comments (17)

  1. johnnylightbulb says:

    I havn’t tried this yet, but will the standard attach-to-process debbuger also work in this case? (If we attach to devenv.exe?)

  2. mikeschuld says:

    I get a "No registered JIT debugger was specified." error. Did I miss something in the setup somewhere?

  3. ShawnHargreaves says:

    Interesting – I though the CLR debugger was included with .NET, but I guess it must not be.

    Looks like you can download it from here though: http://msdn2.microsoft.com/en-us/library/7zxbks7z(vs.80).aspx

  4. dubbadee says:

    This doesn’t appear to work with C# Express and the Game Studio. I’m trying to make some modifications to the shader code used in the XNA Animation Component Library at http://www.codeplex.com/animationcomponents. I’ve added the line

    System.Diagnostics.Debugger.Launch();

    to the Process() function of PaletteEffectContent.cs, which is part of the custom importer dll. When I rebuild my project which is set to reference that dll, it just builds as normal. Is that expected behavior?

    Thanks!

    Derek Hauffe

  5. dubbadee says:

    I’ve figured out what I was doing wrong. Thanks for this tip, Shawn!

  6. DarylJReed@hotmail.com says:

    This also does not work for me.  I’ve done a clean build, removed then added the content file again, everything I could think of.  My debugger line is not getting hit…

  7. DarylJReed@hotmail.com says:

    Just to be complete, the answer was that I am running on Vista, and had elevated the priviledges of VC# Express (run as administrator).  If you do this, the JIT Debugger will not even attempt to attach to the process.

  8. duncanf says:

    I can’t get the debugger to attach using Launch(), it just builds as normal and throws an exception during and outputs that exception in the error list. Am I missing something? Also, I’m trying to use a content processor to calculate normals and write them back into the data stream provided… is this allowed/sensible? This content pipeline stuff seems obscenely fiddly just to do something really simple like get access to mesh data and write out new normals…

  9. jbsosch says:

    it does not work for me, with GS3.0 and VS2008

  10. locus says:

    does not work for express editions…

  11. Zakus says:

    GS 3.1   VS2008 pro

    work perfectly

  12. Chris says:

    GS 3.1 VS2008 works, but Visual Studio always stops responding afterwards and I have to kill the process and restart.

  13. Zheng says:

    Thank you, great method

  14. Thomas says:

    Doesn't work with VS2010 / XNA4

  15. Matt says:

    Is there a way to do this in VS 2010 Express?

  16. Justin says:

    Express editions do not support attaching debugging processes.

  17. robot9706 says:

    Excellent! Thank you! (VS2010/XNA4)