Can't get started, seems to be the way i am telling to load images maybe?

Apr 6, 2010 at 9:45 PM

Having problems when i try and load a texture2d.

SilverSprite is supposed to allow you to run xna game through silverlight but i can't get it to work once it tries to load any texture2d.

If i have all commented out in load method then game opens fine in silverlight but once you uncomment a texture 2d it craps out.

This is how I have the xna code for the texture.

protected override void LoadContent()   
        {   
            // Create a new SpriteBatch, which can be used to draw textures.   
            spriteBatch = new SpriteBatch(GraphicsDevice);   
  
            // TODO: use this.Content to load your game content here   
            bgTexture = Content.Load<Texture2D>(@"images/backgrounds/bg");   
            //positionFont = Content.Load<SpriteFont>(@"fonts/Arial");   
           //charactorTexture = Content.Load<Texture2D>(@"images/charactors/Link");   
            //windmillTexture = Content.Load<Texture2D>(@"images/Buildings/windmill");   
           // Windmill = new Vector2(600, 600);   
            //Avatar = new Vector2(640, 297);    
        }  

Error.

throw new Error("Unhandled Error in Silverlight Application Value cannot be null.\nParameter name: input   at System.IO.BinaryReader..ctor(Stream input, Encoding encoding)\n   at System.IO.BinaryReader..ctor(Stream input)\n   at Microsoft.Xna.Framework.Content.ContentReader..ctor(ContentManager manager, Stream stream, GraphicsDevice graphicsDevice)\n   at Microsoft.Xna.Framework.Content.ContentManager.LoadXnb[T](String assetName)\n   at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)\n   at game.Game1.LoadContent()\n   at Microsoft.Xna.Framework.Game.Initialize()\n   at game.Game1.Initialize()\n   at Microsoft.Xna.Framework.Game.gameLoop_Update(Object sender, SimpleEventArgs`1 e)\n   at SilverArcade.SilverSprite.GameLoop.CompositionTarget_Rendering(Object sender, EventArgs e)\n   at System.Windows.Media.CompositionTarget.OnRendering(Object sender, RenderingEventArgs e)\n   at MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex)"); 
I have a folder under SilverlightApplication2 called images, then a folder in there called backgrounds, then a file called bg.png. 

Works just fine as a xna application its just when I go to use it with silversprite and silverlight.

What am I doing wrong in the loading of the graphic?
Developer
Apr 7, 2010 at 5:46 AM
Have you set the build action or what ita called, on your .png to be "Content"? Sounds like that's the problem.



Den 06/04/2010 kl. 23.45 skrev "wishdragon" <notifications@codeplex.com>:

From: wishdragon

Having problems when i try and load a texture2d.

SilverSprite is supposed to allow you to run xna game through silverlight but i can't get it to work once it tries to load any texture2d.

If i have all commented out in load method then game opens fine in silverlight but once you uncomment a texture 2d it craps out.

This is how I have the xna code for the texture.

protected override void LoadContent()   
        {   
            // Create a new SpriteBatch, which can be used to draw textures.   
            spriteBatch = new SpriteBatch(GraphicsDevice);   
  
            // TODO: use this.Content to load your game content here   
            bgTexture = Content.Load<Texture2D>(@"images/backgrounds/bg");   
            //positionFont = Content.Load<SpriteFont>(@"fonts/Arial");   
           //charactorTexture = Content.Load<Texture2D>(@"images/charactors/Link");   
            //windmillTexture = Content.Load<Texture2D>(@"images/Buildings/windmill");   
           // Windmill = new Vector2(600, 600);   
            //Avatar = new Vector2(640, 297);    
        }  

Error.

throw new Error("Unhandled Error in Silverlight Application Value cannot be null.\nParameter name: input   at System.IO.BinaryReader..ctor(Stream input, Encoding encoding)\n   at System.IO.BinaryReader..ctor(Stream input)\n   at Microsoft.Xna.Framework.Content.ContentReader..ctor(ContentManager manager, Stream stream, GraphicsDevice graphicsDevice)\n   at Microsoft.Xna.Framework.Content.ContentManager.LoadXnb[T](String assetName)\n   at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)\n   at game.Game1.LoadContent()\n   at Microsoft.Xna.Framework.Game.Initialize()\n   at game.Game1.Initialize()\n   at Microsoft.Xna.Framework.Game.gameLoop_Update(Object sender, SimpleEventArgs`1 e)\n   at SilverArcade.SilverSprite.GameLoop.CompositionTarget_Rendering(Object sender, EventArgs e)\n   at System.Windows.Media.CompositionTarget.OnRendering(Object sender, RenderingEventArgs e)\n   at MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex)"); 
I have a folder under SilverlightApplication2 called images, then a folder in there called backgrounds, then a file called bg.png. 

Works just fine as a xna application its just when I go to use it with silversprite and silverlight.

What am I doing wrong in the loading of the graphic?
Apr 7, 2010 at 1:14 PM

Yep, set for action and output directory set for copy always.

Does anyone have a very small xna program and silverlight app running together I can download and just take a look at to see how it is all set up and see where I have it set up wrong?

Apr 7, 2010 at 1:15 PM

I mean action set for content.

Apr 7, 2010 at 6:29 PM

Change int the properties Build options Content to Resource and Copy to output dir: Do not copy. That worked for me :)

 

Apr 7, 2010 at 7:12 PM

Didn't work either :(

still tells me same error that value can't be null, only way I don't get that error is if I tell build action to be embeded resource, it gets farther in the load then tells me it's not embeded, but any other build action tells me value can't be null.

Apr 8, 2010 at 5:46 AM

It's becouse silversprite wants the .xnb file. Get it from the XNA version; bin/x86/debug/Content. You must still set the build action to content and make it in folders!

Not meaning to be rude!

Developer
Apr 8, 2010 at 1:47 PM
Well he should be able to use the .png too. Look at the silversprite front page.
In our project we use the pure png files, but we doesn't run with the latest build so things could have changed.

But again it says he should be able to use png on the front page.



Den 08/04/2010 kl. 07.46 skrev "Mattan360" <notifications@codeplex.com>:

From: Mattan360

It's becouse silversprite wants the .xnb file. Get it from the XNA version; bin/x86/debug/Content. You must still set the build action to content and make it in folders!

Not meaning to be rude!

Apr 8, 2010 at 2:27 PM

I tried the .xnb file as well. Made sure I removed the .png file in case it was conflicting, nothing.

I am probably missing something obvious here if someone wouldn't mind taking a look at my file.

It is very stripped down, simply loading one texture and putting it on the screen.

I put an .xnb and .png in there.

http://visual-alchemist.com/SilverlightApplication2.rar

Coordinator
Apr 8, 2010 at 8:03 PM

Either change the Game1 constructor as follows:

<font size="2">

Content.RootDirectory =

</font>

"";

or put your content inside a folder called Content. Either should fix this.

Apr 8, 2010 at 8:44 PM

bah folder called Content....that was a fairly obvious mistake...I feel dumb now lol.

Thank you for the response, loaded fine when I did that.

Now I can begin loading everything else in and seeing what can be done :)