-
|
|
Missing custom ContentTypeReader on the XBox
|
Missing custom ContentTypeReader on the XBox
I'm starting this as a new thread because, I suspect, it's a different problem.
I have made a custom content pipeline dll for use with my models. It works OK on the PC solution, but when I run the XBox version, when it comes time to load the first model, I get
An unhandled exception of type 'Microsoft.Xna.Framework.Content.ContentLoadException' occurred in Microsoft.Xna.Framework.dll
Additional information: Error loading "Content\Models4\Holli". Cannot find ContentTypeReader HDModelImporter.HDModelReader, HDModelImporter, Version=1.0.0.0, Culture=neutral.
Do I have to tell the compiler to transfer the HDModelImporter dll file to copy it to the XBox?
David
|
|
-
-
- (518)
-
premium membership
MVP
-
Posts
941
|
Re: Missing custom ContentTypeReader on the XBox
|
yes ... just add a reference from your game to the HDModelImporter project and it should work.
Joel Martinez - XNA MVP Blog: http://codecube.netXNA Unit Testing: Scurvy Test
|
|
-
|
|
Re: Missing custom ContentTypeReader on the XBox
|
Thanks for your reply, Joel. I had a reference from HDModelImporter added to my game and when I tried adding a reference from the game to HDModelImporter, the compiler refused due to a circular dependency. I removed the HDModelImporter reference in the game and added the game reference to HDModelImporter, but got the same missing ContentTypeReader error when I ran the game. Maybe I'm not understanding what is meant by adding a reference. I right click the References part of the Solution Explorer, choose Add Reference, and choose an item from the Project tab, right? I don't have to specifically add a reference in my source code? David
|
|
-
-
- (518)
-
premium membership
MVP
-
Posts
941
|
Re: Missing custom ContentTypeReader on the XBox
|
When I say reference, I mean an assembly reference. So if the importer project is a part of your solution, you'd add a project reference. If it was part of a different solution, you'd browse to the .dll and add the reference that way.
You really shouldn't have a reference to the game project from the importer project. It should be the other way around, so game would have a reference to the importer.
Of course, in an ideal world, there wouldn't be any dependencies on the pipeline assembly at all. So the Importer, Processor, and Writers would be in the pipeline assembly. And the reader and runtime classes would only be in the game project.
Joel Martinez - XNA MVP Blog: http://codecube.netXNA Unit Testing: Scurvy Test
|
|
-
|
|
Re: Missing custom ContentTypeReader on the XBox
|
The HDModelImporter is a separate Windows Game Library project in my HolliDance360x XBox 360 solution. A reference has been added to my HolliDance360x project in the references section as well as via the properties/Content Pipeline
Thinking that, now that the files are in the XBox, I could manually load them via a direct call to one of my reader methods, I added the following to a class in HolliDance360x and got these errors.
byte[] sourceData = System.IO.File.ReadAllBytes(fullPath);
Error 8 'System.IO.File' does not contain a definition for 'ReadAllBytes' C:\Data\Projects\Holli\HolliDance\HolliDance360\HolliDance360\ModelObject.cs 300 48 HolliDance360x
ArrayList contentModel = Model_IO.Load_Model(sourceData);
Error 9 The type 'Microsoft.Xna.Framework.Content.ContentReader' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Xna.Framework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d'. C:\Data\Projects\Holli\HolliDance\HolliDance360\HolliDance360\ModelObject.cs 301 13 HolliDance360x
What's strange is the System.IO.File does have a ReadAllBytes method in the HDModelImporter project. It compiles OK and runs OK in the PC solution. Are there 2 different System.IO.File's for the PC and the XBox?
Another discrepancy I've found between the two projects in my XBox solution is the Microsoft.Xna.Framework items I can reference. The XBox project does not have an option to add Microsoft.Xna.Framework.Content.Pipeline like the Windows version. That would prevent me from creating an XBox Game Library version of HDModelImporter because it wouldn't compile.
Has anyone succeeded in get their own binary data loaded into an XBox XNA game?
David
|
|
-
|
|
Re: Missing custom ContentTypeReader on the XBox
|
ReadAllBytes is not supported on the Compact .NET Framework. Also, the Content.Pipeline assembly isn't supported on the 360. It is a PC only assembly, since your content builds are all done on the PC side. As for reading binary data on the 360, check out the BinaryReader class. It is supported in the Compact .NET Framework, so it should be available on the 360.
|
|
-
|
|
Re: Missing custom ContentTypeReader on the XBox
|
As an FYI for future reference, check the class members page in the .NET Framework docs for any class you want to use. If it doesn't have a little mobile device icon next to it, then it isn't supported on the Compact .NET Framework (which is what the 360's framework is a subset of).
|
|
-
|
|
Re: Missing custom ContentTypeReader on the XBox
|
I was using BinaryReader last week with the PC version, but it didn't work on the XBox because the data didn't get transferred. The content pipeline code now gets the data across so I can just go back to reading the file directly. I'll have to teach my model loader to skip the xnb parts of the transferred files, though.
BinaryReader compiles and runs on the XBox project, but it can't find the files. Is the directory structure different on the XBox? Thanks, by the way, for the tip about the reduced .NET Framework on the XBox.
David
|
|
-
|
|
Re: Missing custom ContentTypeReader on the XBox
|
To get at the application directory, you should use StorageContainer.TitleLocation. To get the full path to your xnb file, use something like this: string fullpath = Path.Combine( StorageContainer.TitleLocation, "Content/SomeContentDir/SomeFile.xnb" );
That is guaranteed to work on both the PC and 360.
|
|
-
|
|
Re: Missing custom ContentTypeReader on the XBox
|
Thanks! That did the trick. My data reads into my XBox program OK now . David
|
|
-
|
|
Re: Missing custom ContentTypeReader on the XBox
|
Cool. Glad you got it working.
|
|
|