嗨,我无法理解这个错误
我想阅读这个 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<XnaContent>
<Asset Type="ReadXML.Nod[]">
<Item>
<coneccion>
<Item>
<price>53.6003723</price>
<startNode>
<coneccion />
<position>347 0 228</position>
</startNode>
<endNode>
<coneccion />
<position>334 0 176</position>
</endNode>
</Item>
</coneccion>
<position>347 0 228</position>
</Item>
<Item>
<coneccion>
<Item>
<price>54.74486</price>
<startNode>
<coneccion />
<position>334 0 176</position>
</startNode>
<endNode>
<coneccion />
<position>280 0 167</position>
</endNode>
</Item>
<Item>
<price>53.6003723</price>
<startNode>
<coneccion />
<position>334 0 176</position>
</startNode>
<endNode>
<coneccion />
<position>347 0 228</position>
</endNode>
</Item>
</coneccion>
<position>334 0 176</position>
</Item>
</Asset>
</XnaContent>
我有这门课供阅读:
public class Nod
{
public List<Coneccion> coneccion;
public Vector3 position;
public Nodo(Vector3 p)
{
position = p;
coneccion = new List<Coneccion>();
}
}
和
public class Coneccion
{
public float price;
public Nodo startNode;
public Nodo endNode;
public Coneccion(Nod c, Nod f, float cost)
{
startNode = c;
endNode = f;
price = cost;
}
}
这些类模拟一个图。
我必须阅读这些名为 level.xml 的 xml 文件,并使用这些函数进行阅读
Nod[] graph1 = Content.Load<Nod[]>("level.xml");
但我运行项目并打印下一个错误:
Error 1 Building content threw InvalidOperationException: Cannot deserialize type ReadXML.Nod because it does not have a parameterless constructor.
en Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.ReflectiveSerializer.Deserialize(IntermediateReader input, ContentSerializerAttribute format, Object existingInstance)
en Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadRawObjectInternal[T](ContentSerializerAttribute format, ContentTypeSerializer typeSerializer, Object existingInstance)
en Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObjectInternal[T](ContentSerializerAttribute format, ContentTypeSerializer typeSerializer, Object existingInstance)
en Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.CollectionHelper.Deserialize(IntermediateReader input, ContentSerializerAttribute format, Object collection)
en Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.ArraySerializer`1.Deserialize(IntermediateReader input, ContentSerializerAttribute format, T[] existingInstance)
en Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.ContentTypeSerializer`1.Deserialize(IntermediateReader input, ContentSerializerAttribute format, Object existingInstance)
en Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadRawObjectInternal[T](ContentSerializerAttribute format, ContentTypeSerializer typeSerializer, Object existingInstance)
en Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObjectInternal[T](ContentSerializerAttribute format, ContentTypeSerializer typeSerializer, Object existingInstance)
en Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObject[T](ContentSerializerAttribute format)
en Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.Deserialize[T](XmlReader input, String referenceRelocationPath)
en Microsoft.Xna.Framework.Content.Pipeline.XmlImporter.Import(String filename, ContentImporterContext context)
en Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context)
en Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.ImportAssetDirectly(BuildItem item, String importerName)
en Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.ImportAsset(BuildItem item)
en Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAssetWorker(BuildItem item)
en Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAsset(BuildItem item)
en Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.RunTheBuild()
en Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildContent.RemoteProxy.RunTheBuild(BuildCoordinatorSettings settings, TimestampCache timestampCache, ITaskItem[] sourceAssets, String[]& outputContent, String[]& rebuiltContent, String[]& intermediates, Dictionary`2& dependencyTimestamps, KeyValuePair`2[]& warnings) C:\Downloads\Bomber-O-Man (Entrega 2)\IAJMovimiento\IAJMovimiento\IAJMovimientoContent\level.xml IAJMovimiento
请帮忙