I'm working on a personal project for learning purposes in XNA. I've read online that using the content pipeline requires people to have the xna runtime installed. So i've decided to load files using Texture2D.FromStream.
Everything is fine when I'm running the project from visual c#, but when I publish the project and run it, it crashed immediatly. I'm not sure if there is a way to see more info on the crash, but I assume not. I'm thinking it's down to not using the content pipeline.
When I look inside the application files for the published project I only see .xnb files. and no raw .png and .xml files that I'm using.
I tried 开发者_运维技巧to place the files in there manually but that didn't work aswell. The files are all in the "Projectname\bin\x86\Debug\Content" folder.
Anyone has any idea?
edit
I have just rewritten my contentmanager so it uses the content pipeline, and the published project now works fine on my pc. So I have to figure out a way to get it to work without the content pipeline
if you work with Texture2D.FromStream, you have to care about two facts:
You have to change some resource's properties:
- Compile action: None
Copy to result folder: Always
This way the xnb won't be builded and you will get your resources instead
You have to set the appropiate path, now you have not "bin\Debug" in your path.
As @Blau mentions, changing the image's properties will fix your problem. As you can see, the FromStream method is fully supported on the framework on all platforms now:
http://blogs.msdn.com/b/shawnhar/archive/2010/05/10/image-codecs-in-xna-game-studio-4-0.aspx.
As far as seeing errors ... you can always put a try catch around the statement that you think is throwing the error and then write out the error text to the screen so you can see it. Something like
try
{
//The offending code
}
catch(Exception ex)
{
WriteError(ex.Message);
}
精彩评论