Can't Load asset as XML file

限于喜欢 提交于 2020-01-11 13:56:18

问题


I have done my project with XNA and I'm currently trying to convert it while using Monogame.

My problem is that i can't load my XML file.

the error: Could not load Level asset as a non-content file!

My code: file = Content.Load<XmlData[]>(path);

Path = xml name file without extension. (i tried both).

class XMLData :

public class XmlData
{
    public int id;
    public int posx;
    public int posy;
    public int rot;
    public int Width;
    public int Height;
}

and some of my XML file:

<?xml version="1.0" encoding="utf-8" ?>
  <Asset Type="MyDataTypes.XmlData[]">
    <Item>
      <id>17</id>
      <posx>54</posx>
      <posy>30</posy>
      <rot>90</rot>
      <Width>184</Width>
      <Height>5</Height>
    </Item>

I had a problem like this with XNA, I had to add the following line to my XML file <XnaContent> </XnaContent> and I also had to add XML data as a library (even if it was only one class).

So what's the difference with Monogame? Why I can't load this XML file? In propriety, my xml file is a content.

Thanks for any help, I'll be grateful.

Edit: I thought I had found my problem here --> <Asset Type="MyDataTypes.XmlData[]"> I tried <Asset Type="XmlData[]"> cause i don't have MyDataTypes library anymore. I also tried with Content directory and asset directory. Nothing worked yet. I keep this post update.


回答1:


Have you tried to set the property file as Copy if newer?




回答2:


I believe that you cannot do that in monogame, as it does not have a content pipeline to convert the xml to xnb files, so, unless I'm mistaken, your better off to build the files in xna and just copy the xnb files in to your monogame project and set them to "Content" and "Copy if newer"



来源:https://stackoverflow.com/questions/20548783/cant-load-asset-as-xml-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!