This project is read-only.

Loading SpriteSheetSample and other custom content

Jul 3, 2010 at 1:45 AM

Hello, I've been trying to port my game over since I noticed support for loading custom content has begun in the latest builds. I use the SpriteSheetSample to set up my textures for loading in the game but I haven't been able to get it to work with the current code. When calling load I get the following exception.


{Microsoft.Xna.Framework.Content.ContentLoadException: Bad XNB ---> System.IO.FileLoadException: Could not load file or assembly 'SpriteSheetRuntime, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The requested assembly version conflicts with what is already bound in the app domain or specified in the manifest. (Exception from HRESULT: 0x80131053)


It happens when ContentTypeReaderManager.GetReaderType() is called, on the line "Type type = Type.GetType(readerTypeString);" Debugging shows readerTypeString contains the string "Microsoft.Xna.Framework.Content.ReflectiveReader`1[[SpriteSheetRuntime.SpriteSheet, SpriteSheetRuntime]]". I complied the SpriteSheet in MSVC# 2008 express and moved the built XNB to my project Content folder in MSWD 2010 Express. Target SilverLight version is v4. I notice in the typeString there is no AssemblyVersion or Cultural Info. Not sure if that matters? My game solution has the Main Game project where the load is called, a silverlight class library called SpriteSheetRuntime with SpriteSheet.cs from the XNA creators website SpriteSheetSample (which I used to build the XNB file). I've tried just including the SilverArcade.SilverSprite, .Core as references and also tried including the full SilverSprite source projects in my solutions with the same results. I feel like I'm doing something wrong when compiling the XNB, but really it's just leaving me scratching my head. Has anybody been able to get the sample to work?


Sorry for the long post but there's another problem I'm having with custom stuff when loading my level files. I have a list of Platform classes for each level and have a derived type called SwitchedPlatforms that uses the Platform class for the base. SwitchedPlatforms also has a class called Switch that was processed into the XNB file. In order to get the derived type to work I had to uncomment the line in the ContentReader.Read<T>(ContentTypeReader, T) method 


if (tmp > 0) typeReader = typeReaders[tmp-1];


It seems this gets the new typeReader when targetType is derived. It works for about 23 elements in the list (i.e. 23 levels) and by that point all the types the reader might see have since been read, meaning nothing new should be thrown at it. Then when the next element in the list read, when Read7BitEncodedInt() is called, it returns a number outside of the bounds of the typeReader array. So it's another Bad XNB error? Could this have something to do with the versions of VS I'm using? (They are both express versions but VSC# is 2008, XNA 3.1 and SilverLight is v4, Web Developer is 2010) Any help will be greatly appreciated. Thank you in advance.

...One more thing, don't know if this should be in Issue Tracker, but in the ReflectiveReader when trying to SetValue obj2 to parent, if the field is declared "protected" but marked with [ContentSerilizer] (making IsPrivate == false), setting the value fails.

Thanks for reading this long post:)