xna 发布的项目没有内容管道?
我正在 XNA 中开展一个出于学习目的的个人项目。我在网上读到,使用内容管道需要人们安装 xna 运行时。所以我决定使用Texture2D.FromStream加载文件。
当我从 Visual C# 运行项目时一切都很好,但是当我发布项目并运行它时,它立即崩溃了。我不确定是否有办法查看有关崩溃的更多信息,但我认为没有。我认为这归因于不使用内容管道。
当我查看已发布项目的应用程序文件时,我只看到 .xnb 文件。并且没有我正在使用的原始 .png 和 .xml 文件。
我尝试手动将文件放入其中,但效果不佳。 这些文件都位于“Projectname\bin\x86\Debug\Content”文件夹中。
有人有什么想法吗?
编辑
我刚刚重写了我的内容管理器,因此它使用内容管道,并且发布的项目现在可以在我的电脑上正常运行。所以我必须找到一种方法让它在没有内容管道的情况下工作
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用Texture2D.FromStream,您必须关心两个事实:
您必须更改某些资源的属性:
复制到结果文件夹:始终
这样 xnb 就不会被构建,而您将获得资源
您有要设置适当的路径,现在您的路径中还没有“bin\Debug”。
if you work with Texture2D.FromStream, you have to care about two facts:
You have to change some resource's properties:
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.
正如@Blau 提到的,更改图像的属性将解决您的问题。如您所见,现在所有平台的框架都完全支持 FromStream 方法:
http://blogs.msdn.com/b/shawnhar/archive/2010/05/10/image-codecs-in-xna-game-studio-4-0.aspx。
至于看到错误......您始终可以在您认为引发错误的语句周围放置一个 try catch,然后将错误文本写到屏幕上,以便您可以看到它。像这样的东西
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