<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx</link><description>One of the new features in Game Studio 3.1 is automatic serialization for .xnb files. This is a feature I have wanted ever since we first designed the Content Pipeline, so it makes me very happy that we finally found time to implement it! &amp;#160; Short</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9509569</link><pubDate>Thu, 26 Mar 2009 07:25:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9509569</guid><dc:creator>wmfwlr</dc:creator><description>&lt;p&gt;This will come in very handy, for sure. I could have used it a month ago. I guess now I'll be one of those old guys who looks back and says &amp;quot;I remember when I had to write my own ContentTypeWriter. Kids nowadays have it easy&amp;quot;.&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9509905</link><pubDate>Thu, 26 Mar 2009 09:54:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9509905</guid><dc:creator>CatalinZima</dc:creator><description>&lt;p&gt;Ok, I was waiting for this post :) It's good to be finally be rid of writing those writers/readers.&lt;/p&gt;
&lt;p&gt;Now, a question:&lt;/p&gt;
&lt;p&gt;For the last example, the one with the Texture2DContent: what is the corresponding input XML for this example? Can the Texture2DContent be simply written in the XML (how?), or does it have to be initialized inside a ConentProcessor (because this is where you have access to the context)?&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9510796</link><pubDate>Thu, 26 Mar 2009 16:26:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9510796</guid><dc:creator>barkers crest</dc:creator><description>&lt;p&gt;Shawn, with this new feature is it possible to serialize to xnb during runtime?&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9511207</link><pubDate>Thu, 26 Mar 2009 19:20:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9511207</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;barkers crest: no. Writing .xnb files is done as part of the Content Pipeline build process, same as before.&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9511222</link><pubDate>Thu, 26 Mar 2009 19:23:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9511222</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;Catalin: in theory you could embed the texture data directly into XML (TextureContent can be serialized by IntermediateSerializer) but I'm not sure how useful that would be!&lt;/p&gt;
&lt;p&gt;More likely you would want to just store the texture filename in your XML, then go off and read that file in during the build process, which would require some processor code.&lt;/p&gt;
&lt;p&gt;Here's an example from one of our unit tests of what a TextureContent looks like in IntermediateSerializer XML:&lt;/p&gt;
&lt;p&gt;&amp;lt;XnaContent xmlns:Graphics=&amp;quot;Microsoft.Xna.Framework.Content.Pipeline.Graphics&amp;quot; xmlns:PackedVector=&amp;quot;Microsoft.Xna.Framework.Graphics.PackedVector&amp;quot;&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;Asset Type=&amp;quot;Graphics:Texture2DContent&amp;quot;&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;Mipmaps&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Mipmap Type=&amp;quot;Graphics:PixelBitmapContent[PackedVector:Alpha8]&amp;quot;&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Width&amp;gt;2&amp;lt;/Width&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Height&amp;gt;2&amp;lt;/Height&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Pixels&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Row&amp;gt;3B 6B&amp;lt;/Row&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Row&amp;gt;AA FF&amp;lt;/Row&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Pixels&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Mipmap&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Mipmap Type=&amp;quot;Graphics:PixelBitmapContent[PackedVector:Alpha8]&amp;quot;&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Width&amp;gt;1&amp;lt;/Width&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Height&amp;gt;1&amp;lt;/Height&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Pixels&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;Row&amp;gt;1F&amp;lt;/Row&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Pixels&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/Mipmap&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/Mipmaps&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;/Asset&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;/XnaContent&amp;gt;&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9513715</link><pubDate>Fri, 27 Mar 2009 12:59:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9513715</guid><dc:creator>CatalinZima</dc:creator><description>&lt;p&gt;Ok, so I still need a Processor to solve this in an elegant (and resource-cheap) way, since textures will be shared between different assets (which means embedding them isn't too good).&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9514635</link><pubDate>Fri, 27 Mar 2009 20:21:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9514635</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;I would most likely do this in a processor, yes. The auto serialization doesn't remove the need to write processor code if you want to process data or trigger other actions (like going off and building a texture) at runtime.&lt;/p&gt;
&lt;p&gt;There are a couple of other options, though:&lt;/p&gt;
&lt;p&gt;- you could just embed a string asset name in in the XML, then call ContentManager.Load on that name at runtime after you load the .xnb&lt;/p&gt;
&lt;p&gt;- or you could embed an ExternalReference instance, in which case the .xnb deserializer will automatically follow that reference and load the asset it points to in place of the original reference&lt;/p&gt;
&lt;p&gt;These options only work if the referenced asset is already being built through some other mechanism, though, so you know what name the reference should point to. They would be an option if you have a bunch of textures that are already added to your Content project, and can just put the name of these textures in this other XML asset, but unlike using a custom processor, they will not automatically go off and build that texture for you if the XML references a texture that is not otherwise part of your Content project.&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9529711</link><pubDate>Thu, 02 Apr 2009 23:51:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9529711</guid><dc:creator>CatalinZima</dc:creator><description>&lt;p&gt;And unfortunately, I'd have no errors during build telling me that some textures are missing.&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9609244</link><pubDate>Wed, 13 May 2009 16:26:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9609244</guid><dc:creator>DCCreation</dc:creator><description>&lt;p&gt;Just amazing !!!&lt;/p&gt;
&lt;p&gt;Thank you really !&lt;/p&gt;
&lt;p&gt;I work with XNA 3.0, and it couldn't auto serialize my XML objects, and I'm so happy to see this post !&lt;/p&gt;
&lt;p&gt;It's a very good new. I earn a lot of time.&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9735833</link><pubDate>Fri, 12 Jun 2009 19:26:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9735833</guid><dc:creator>Kevin Smeltzer</dc:creator><description>&lt;p&gt;I see that runtime serialization to .xnb will not be availble which makes sense because that is part of the build process.&lt;/p&gt;
&lt;p&gt;Does that mean that this new fancy reflection based auto serialization will be useless for necessary things such as saving/loading game states, or can you use the framework to seriliaze to something other than .xnb at run time?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9736139</link><pubDate>Fri, 12 Jun 2009 20:05:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9736139</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;Kevin: this new serializer is part of the Content Pipeline, so the writing part is only available at build time.&lt;/p&gt;
&lt;p&gt;For runtime serialization of things like save games, I would probably start with XmlSerializer, or if you need something more efficient, you could use BinaryWriter/BinaryReader to create a more compact binary format.&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9752246</link><pubDate>Mon, 15 Jun 2009 09:28:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9752246</guid><dc:creator>Kevin Gadd</dc:creator><description>&lt;p&gt;So I've finally gotten around to trying out the content pipeline. Until now, I've been loading/saving all my game data using XML serialization, even on the 360, and it works fine - but I want to start deploying my content as packed XNB files for better load performance.&lt;/p&gt;
&lt;p&gt;As a basic implementation, I wrote a raw importer to read in my XML files as byte[] and then a processor to convert those to my runtime data structures. This seems to work, but for some reason, the XNB files generated by this automatic reflection-based serializer are around 10 times larger than my XML files. &lt;/p&gt;
&lt;p&gt;Is this behavior intended, or am I using the content pipeline incorrectly? Will the overhead remain fixed as my files grow larger? It's hard to tell whether or not it's fixed overhead from looking at the XNB files in a hex editor.&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9753295</link><pubDate>Mon, 15 Jun 2009 17:08:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9753295</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;Kevin: this really depends on what your data looks like. XNB files are usually much smaller than XML (especially if you enable compression) but it's certainly possible to construct objects where this would not be the case.&lt;/p&gt;
&lt;p&gt;I would recommend the forums on creators.xna.com if you want to follow up with more details, as they're somewhat nicer than these comment boxes for having a discussion :-)&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9757546</link><pubDate>Tue, 16 Jun 2009 04:32:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9757546</guid><dc:creator>Kevin Gadd</dc:creator><description>&lt;p&gt;Luckily it turns out it was a bit of a false alarm :) The size went down significantly once I fiddled with some of the serialization attributes - there's still some overhead, but from testing it appears to be fixed - most of it comes from the fact that the ReflectiveWriter has to write out the fully qualified names of all the types it uses, which isn't the case in my source XML.&lt;/p&gt;
&lt;p&gt;The actual binary data for the content seems to be quite compact, which is what I was hoping for.&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9791982</link><pubDate>Fri, 19 Jun 2009 22:50:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9791982</guid><dc:creator>Phil</dc:creator><description>&lt;p&gt;I currently have several different (fairly large ~12KB) xml files that I copy to the output directory, and load when my game starts up. &amp;nbsp;They seem to take a long time to load on the Xbox.&lt;/p&gt;
&lt;p&gt;Would I expect to see a performance improvement by moving these files into content pipeline? (I would write a ContentImporter that deserializes from xml, and then uses this new automatic serialization functionality).&lt;/p&gt;
&lt;p&gt;There would be some improvement from the smaller file sizes... but is the deserialization functionality generally faster than what I have now (the standard Xml deserialization)?&lt;/p&gt;</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9791990</link><pubDate>Fri, 19 Jun 2009 22:56:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9791990</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;Phil: no promises (the only way to be 100% sure is to try this both ways and time it with your particular data) but in general I would expect XNB serialization to be much faster than XML.&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9828099</link><pubDate>Fri, 10 Jul 2009 06:09:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9828099</guid><dc:creator>mod</dc:creator><description>&lt;p&gt;something weird happens ! it tells me that it can't find the XML file .. i didn't try serializing before to tell u the truth.. but this really is bugging me..&lt;/p&gt;</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9830791</link><pubDate>Mon, 13 Jul 2009 03:51:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9830791</guid><dc:creator>GrahamRanson</dc:creator><description>&lt;p&gt;Is it possible to use serialize Dictionary objects? And if so, how should they be defined the &amp;nbsp;XML file?&lt;/p&gt;</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9849756</link><pubDate>Mon, 27 Jul 2009 10:11:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9849756</guid><dc:creator>Paul Solt</dc:creator><description>&lt;p&gt;What happens when you serialize a sub-class of another class? My game objects all have common attributes which are within the base class. Future classes sub-class and provide additional functionality. &lt;/p&gt;
&lt;p&gt;Does it automatically grab the super classes serializable attributes?&lt;/p&gt;</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9850086</link><pubDate>Mon, 27 Jul 2009 18:49:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9850086</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;&amp;gt; Does it automatically grab the super classes serializable attributes?&lt;/p&gt;
&lt;p&gt;Of course!&lt;/p&gt;
&lt;p&gt;More technically, it calls into the ContentTypeWriter for the base class, which might be either manually implemented or automatically generated (the base class writer doesn't have to be created the same way as that for the derived type).&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9863817</link><pubDate>Tue, 11 Aug 2009 07:19:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9863817</guid><dc:creator>Paul Solt</dc:creator><description>&lt;p&gt;Another question related to XNB serialization for game objects in &amp;quot;level files.&amp;quot;&lt;/p&gt;
&lt;p&gt;Is there any support for different &amp;quot;versions&amp;quot; of the class being serialized? My current solution is to mark public attributes as [ContentSerializer(Optional = true)]&lt;/p&gt;
&lt;p&gt;when I add a new attribute to the class.&lt;/p&gt;
&lt;p&gt;If I need version support would I have to keep track of a version value for the &amp;quot;game object&amp;quot; and then write my own reader/writer using that version number?&lt;/p&gt;</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9864698</link><pubDate>Tue, 11 Aug 2009 20:51:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9864698</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;&amp;gt; Is there any support for different &amp;quot;versions&amp;quot; of the class being serialized&lt;/p&gt;
&lt;p&gt;The only built in support for .xnb versioning is the TypeVersion property on ContentTypeWriter and ContentTypeReader, which deliberately prevents loading if the version has changed.&lt;/p&gt;
&lt;p&gt;I guess you could build some more flexible mechanism of your own, but I wouldn't really recommend this. The general thinking is that .xnb files are compiled data, so they don't really need to be versioned on the fly. It's usually easier to just recompile them from the source content (which obviously does need to have good versioning and backward compatibility) any time the version changes, which keeps the runtime loading code nice and simple. &lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9865226</link><pubDate>Wed, 12 Aug 2009 03:05:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9865226</guid><dc:creator>Paul Solt</dc:creator><description>&lt;p&gt;What does source content with good versioning and backward compatibility look like? Are there examples of this on the creators club website?&lt;/p&gt;
&lt;p&gt;My current routine is to convert the XML content for my game objects to the latest version using Find/Replace. I haven't figured out a good system to make it automated.&lt;/p&gt;</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9865231</link><pubDate>Wed, 12 Aug 2009 03:10:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9865231</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;The FBX file format is an example of something with good backward compatibility.&lt;/p&gt;
&lt;p&gt;In general, designing a format and writing a loader that supports multiple versions is a lot of work. The Content Pipeline does nothing to help with this, but also does nothing to get in your way: this is entirely down to what code you put in your importer, so any standard computer sciencey format versioning techniques can be used.&lt;/p&gt;
&lt;p&gt;Depending on the amount of data you are dealing with and how many people you have creating it, in many cases you may find it easier to just manually fix up any old files rather than doing the work to automate this.&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9885971</link><pubDate>Thu, 27 Aug 2009 00:56:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9885971</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;If I have a hierarchy of types like this:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;public class Animal&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public string Name;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;public class Cat : Animal&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public int Age;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;How do I create a corresponding content type (or types) decorated with the ContentSerializerRuntimeType attribute, so that I can load the Cat type at runtime without writing a custom ContentTypeReader/Writer for it?&lt;/p&gt;
&lt;p&gt;I tried this:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;[ContentSerializerRuntimeType(&amp;quot;Cat, MyAssembly&amp;quot;)]&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;public class CatContent&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public string Name;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public int Age;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;Which works during the build phase. &amp;nbsp;However when I attempt to call Content.Load&amp;lt;Cat&amp;gt;(&amp;quot;ACat&amp;quot;) I receive a ContentLoadException.&lt;/p&gt;
&lt;p&gt;Microsoft.Xna.Framework.Content.ContentLoadException was unhandled&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Message=&amp;quot;Error loading \&amp;quot;ACat\&amp;quot;. Cannot find ContentTypeReader for Animal.&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Source=&amp;quot;Microsoft.Xna.Framework&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;StackTrace:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; at Microsoft.Xna.Framework.Content.ContentTypeReaderManager.GetTypeReader(Type targetType, ContentReader contentReader)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; at Microsoft.Xna.Framework.Content.ContentTypeReaderManager.GetTypeReader(Type targetType)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; at Microsoft.Xna.Framework.Content.ReflectiveReader`1.Initialize(ContentTypeReaderManager manager)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; at Microsoft.Xna.Framework.Content.ContentTypeReaderManager.ReadTypeManifest(Int32 typeCount, ContentReader contentReader)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; at Microsoft.Xna.Framework.Content.ContentReader.ReadHeader()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; at Nexus.Client.Client.Initialize() in C:\Source\NexusC#\Client\Client.cs:line 97&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; at Microsoft.Xna.Framework.Game.Run()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; at Nexus.Client.Program.Main(String[] args) in C:\Source\NexusC#\Client\Program.cs:line 14&lt;/p&gt;
&lt;p&gt; &amp;nbsp;InnerException: &lt;/p&gt;</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9887031</link><pubDate>Thu, 27 Aug 2009 18:16:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9887031</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;chris:&lt;/p&gt;
&lt;p&gt;a) it's generally better to use the creators.xna.com forums for this kind of support question - blog comments aren't really the best place for posting code snippets!&lt;/p&gt;
&lt;p&gt;b) With automatic serialization, your design time inheritance hierarchy needs to match the runtime one, so you need an AnimalContent base class for use at design time. If your design time and runtime types are structurally different, you cannot use automatic serialization, and will have to write an old-style ContentTypeWriter/Reader pair for them.&lt;/p&gt;
</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9890329</link><pubDate>Wed, 02 Sep 2009 13:39:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9890329</guid><dc:creator>Thomas</dc:creator><description>&lt;p&gt;We have an article with some additional tipps to consider with XNB serialization on our blog &lt;a rel="nofollow" target="_new" href="http://blog.brightside-games.com/?p=65"&gt;http://blog.brightside-games.com/?p=65&lt;/a&gt; so maybe that can answer some of your questions here. best Thomas&lt;/p&gt;</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9906595</link><pubDate>Tue, 13 Oct 2009 12:41:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9906595</guid><dc:creator>Mike</dc:creator><description>&lt;p&gt;Hi Shawn,&lt;/p&gt;
&lt;p&gt;I hope you don't mind me posting a) to an old topic and b) with such a (probably) stupid question... But I have been going around in circles for days trying to find the best way around this problem, and I am at wit's end!&lt;/p&gt;
&lt;p&gt;Would it help if I described my problem as being pernicious? ;)&lt;/p&gt;
&lt;p&gt;I have implemented a content importer (without using a ContentTypeReader/Writer, since I am using XNA 3.1) which reads a XML file and creates a List of Sprites.&lt;/p&gt;
&lt;p&gt;(This Sprite object is in a (referenced) second project, as per the guidance on one of your previous posts).&lt;/p&gt;
&lt;p&gt;However, I now want to derive classes (Enemies, Scenery Tiles, Players etc) from this Sprite object, as I don't want the various specialized methods within the base Sprite class.&lt;/p&gt;
&lt;p&gt;I naively expected to be able to downcast from a (say) Sprite object to a Player, but I am unable to do so, as the importer creates instances of the base class (Sprite).&lt;/p&gt;
&lt;p&gt;(I should at this point say that I thought I understood down-casting, but I have always used it from an object that had previously been up-cast)&lt;/p&gt;
&lt;p&gt;How should I approach this design issue?&lt;/p&gt;
&lt;p&gt;Anyway, please forgive me for asking such a newbie question!&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;</description></item><item><title>re: Automatic XNB serialization in XNA Game Studio 3.1</title><link>http://blogs.msdn.com/shawnhar/archive/2009/03/25/automatic-xnb-serialization-in-xna-game-studio-3-1.aspx#9906677</link><pubDate>Tue, 13 Oct 2009 15:56:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9906677</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;Mike: you can only cast a Sprite object to a Player if the object in question is in fact a Player instance. How do you originally create these objects? You will need to make sure you create them all using the correct types for each. The serialization mechanism will preserve whatever types you give it so my guess is you are not creating the right types in the first place.&lt;/p&gt;
&lt;p&gt;btw. I would recommend the forums on creators.xna.com if you have further questions - those tend to work better than blog comments for this kind of support discussion!&lt;/p&gt;
</description></item></channel></rss>