XMLImporter failure - Unable to load one or more of the requested types

So I keep getting this error when attempting to load an XML file encoded by the IntermediateSerializer. I expect the error is mine rather than a bug in Monogame, but I can’t figure it out. However, I’m not ruling out the Monogame bug, especially since I’m in an odd situation as far as platforms.
Anyway, the error:

2>  E:/extra programming/C# Projects/PCSK/CityEditor/Content/cities.xml
2>EXEC : warning : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
2>E:/extra programming/C# Projects/PCSK/CityEditor/Content/cities.xml : error : Importer 'XmlImporter' had unexpected failure!
2>  System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
2>     at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
2>     at System.Reflection.Assembly.GetTypes()
2>     at System.Linq.Enumerable.<SelectManyIterator>d__22`3.MoveNext()
2>     at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
2>     at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
2>     at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.FindType(String typeName)
2>     at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
2>     at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
2>     at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
2>     at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.FindType(String typeName)
2>     at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObject[T](ContentSerializerAttribute format, ContentTypeSerializer typeSerializer, T existingInstance)
2>     at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObject[T](ContentSerializerAttribute format)
2>     at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.Deserialize[T](XmlReader input, String referenceRelocationPath)
2>     at Microsoft.Xna.Framework.Content.Pipeline.XmlImporter.Import(String filename, ContentImporterContext context)
2>     at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context)
2>     at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent)
2>C:\Program Files (x86)\MSBuild\MonoGame\v3.0\MonoGame.Content.Builder.targets(90,5): error MSB3073: The command ""C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\MGCB.exe" /@:"E:\extra programming\C# Projects\PCSK\CityEditor\Content\Content.mgcb" /platform:Windows /outputDir:"E:\extra programming\C# Projects\PCSK\CityEditor\Content\bin\Windows" /intermediateDir:"E:\extra programming\C# Projects\PCSK\CityEditor\Content\obj\Windows" /quiet" exited with code 1.

I have no idea how to “retrieve the LoaderExceptions property” so I can’t get that information.
The serialized class was a List of a custom type, and the XML file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:Generic="System.Collections.Generic">
  <Asset Type="Generic:List[WrathOfTheGods.City]">
      <position>273 283</position>
      <neighbors>1 2</neighbors>
      <position>419 239</position>
      <position>227 387</position>

(Uh… excuse the odd strings, I got a little keyboard flaily after doing so many tests leading up to this.)
So that file seems straightforward enough. The class is of course a little less so but still fine I should think:

([Usings excluded])

namespace WrathOfTheGods
    public class City
        public string Name
        { get; private set; }

        public string Region
        { get; private set; }

        public Vector2 Position
                return new Vector2(position.X, position.Y);
        private Vector2 position;

        private List<int> neighbors;

        private List<City> cityList;

        ([Methods excluded])

It doesn’t serialize that last list of course, but that’s by design. (Ish.)
Anyway so the thing that might be causing problems is that the project that I’m trying to deserialize into (and the one I serialized from) is a Windows(DX) project, but the project that actually encodes the class is an Android project. (The Windows project is an editing tool.) I’ve got references set up and all, of course, but the cross platforming has caused some oddness before (it tries to run the Windows project in the android emulator if my tablet isn’t plugged in :? ). But I’ve given the pipeline tool a reference to the version of the .dll that’s in the Windows project’s bin folder, so…?

Anyway, thanks for reading, please help if you can. :slight_smile:

EDIT: Well, I’ve confirmed that it’s not to do with the List - I serialized a single City and it can’t load that either. (I also tried removing the List from the City class, which also didn’t help.)

This is really quite frustrating. I cannot find any possible reason why this isn’t working - unless it’s just due to different platforms, which doesn’t seem like it should effect it. (Or, perhaps I should say, I can find plenty of possible reasons - but none of them seem to be it.)

Hnnnnnnnrgrh I am going crazy here.

So I tried pulling out the class into a library because A, it might help, and B, it’s probably good practice anyway. I had to install a NuGet package to get some very basic things working, which I thought was weird - but it still didn’t help, and in fact, if I try to add the class library as a reference to the pipeline tool, it immediately crashes. (Well, it crashes as soon as I click “OK” on the reference adding window.)

dammit I wanna work on this project before this kills all my steam T_T

How can one find the loaderexception? There is no ‘debug mode’ on the pipeline tool. @konaju @Jjagg or anyone?

I don’t know. This is not an exception thrown by MG. Sounds like Loader exception is a member of ReflectionTypeLoadException.

The pipeline tool does have a debug mode, if you enable (somewhere in the menu bar, I don’t remember exactly where) it it will ask you to attach a debugger when you start a build. Alternatively you can build from source and run the Pipeline Tool from within VS. Either way should let you see the members of the exception you’re getting, allowing you to further investigate the issue.

@littlebeast did you serialize the list of cities using the IntermediateSerializer? I think the List should look different in the serialization, though I could be wrong.

I remember having seen this button some time ago, but I can’t find it anymore in the latest build. :frowning:

I’ve tried to reproduce this using your example file and class. I put the City class into its own class library that was referenced by both the content project and the game project. Added the XML file to the content project, built the class library, then built the game project. The XML file was built into a XNB, and then successfully loaded into the game with Content.Load<List<WrathOfTheGods.City>>("cities").

1 Like

Okay, well… good news, it works now! I made a new class library, reserialized from that, and it worked as soon as I updated the references.

Bad news, I still don’t know why it wasn’t before?

Well, I know why it didn’t work last time I tried to use a class library - I made a “.NET Standard” library, which apparently targets really old versions of .NET - like, to the point I didn’t even have an mscorlib old enough to be compatible. Cleared up that problem with a NuGet package, but I’m guessing it being the old version messed with the content manager.

I’m still not really clear why it couldn’t deserialize from the main WrathOfTheGods .dll, but my money’s on incompatibility with the Android version.

@Jjagg I did try the debug mode (it’s under the Build menu) and running it from in VS, but neither one let me see the exception. It just said “The program is in a break state, but there’s nothing to show since it’s all external code.” or something similar. Maybe there would’ve been a way to investigate the exception from there, but I couldn’t find it. If you want to investigate further you can check out this commit on Github: https://github.com/littlebeast/WrathOfTheGods/tree/cba65e7f74b17b9f4e7ce447e67108df11af21e9

But I don’t have the debug anywhere in the menus:

Nowhere to be found.
I’m using MG 3.7 build 828 (one of the latest I think)

I’m not sure I will be able to debug with the sources if I don’t have this button, or I’ll have to add it myself if it’s no even a comment in the code?

I have the same error message about the LoadException property and have time to investigate from a rebuild of the source cloned (not done that yet) from git but before I start this I would like to know if some else is already on it.
I am not sure how many days I should wait for a response to this offer.

Ok. No responses so far. Continuing with setup for investigation using VS 2017 Community to build and debug Pipeline.exe.
Copied pipeline source from mygitrep\Monogame\Tools to my development area.
Created empty project and added all source with their folders.
First obstacle. Program.cs has using Eto;
Where do I find the reference for this name space?

Did you do all these steps:

The process on Windows is

  1. Clone the Git repository. Easiest way is via TortoiseGit or Git command-line.
  2. Update Git submodules.
  3. Run Protobuild.exe (simply double-click the exe, no parameters needed for default behaviour) to generate the .sln and .csproj files.

Am I the only one not having the “debug” option in the build menu of the MGPT ?

Ok. Thanks. Cloned and Opened solution file in VS 2017 and built net45 project and copied the Eto.dll to pipeline bin\debug and added ref to that and now Eto namespace resolves.
Build and debug to go next.

Ok, some progress but now the light is better I see more so more trouble ahead.
I am wondering if pipeline was written to be a bridge between the old pipeline and the new method. I have come to that from seeing that the pipeline code has dependencies on the old xna pipeline and its sub services.
Its looking for OpaqueDataDictionary class.
At this point I cannot resolve the Microsoft.xna.framework.pipeline. and Microsoft.Xna.Framework.Content.Pipeline.Builder.Convertors
I could go through the process of developing a solution but don’t want to if this is just a reference issue.
Anyone help? :frowning:

Ok I have an executable but it fails with System Argument Exception
Cant find Icon.ico in assembly.
I have tried numerous ways to get round this including using resourcemanager but although I can get it to find the ico file it wont cast the found System.Drawing.Icon to Eto.Drawing.Icon which the MainWindowEto,cs requires. I included Eto package as it seemed the easiest solution to resolve missing references.
I will continue scrambling to find a solution.

Ok. I got really confused by what I did to get to the compilable state so have scrapped that and am starting over.
As this is a monogame utility what add ons, enhacements, VS extensions may I use? I ma asking as I fell into a trap using Eto and don’t want to do that again.
I believe I also used Wxt as well before.
As this is a monogame utility/tool I was tempted into using the monogame windows project but maybe that’s where I went wrong before.
Can someone advise me on what type of project pipeline.exe should be started with. btw the originals were all built with msbuild not vs so the starter project type maybe misleading.
I will await some response before starting over again.

Ok. continuing to learn.
It looks like protobuild was used to drive the build process.
Ran protobuild in the momgame folder and it looked like it did the base setup.
Downloaded the current protobuild setup and ran that and selected the generated protobuild for monogame and ran that ok and the solution and all the project files were generated in VS 2017 so magic really does exist. :slight_smile:
I am able to run pipeline in debug mode so will look at the original problem and see if I can reproduce it.

Ok. success in reproducing the problem I had originally.
Will proceed with setting up a test project with just one xml file and see if it fails there and as I believe it will I will carry on with the debugging to try and find the root cause.

OK, so repeated error in test using only one xml document.
Error traceback is:
The thread 0x11614 has exited with code 0 (0x0).
E:/Development/MonoGame/pipelinetest/MagicStaff.xml: error: Importer ‘XmlImporter’ had unexpected failure!
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
The thread 0xef14 has exited with code 0 (0x0).
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.Assembly.GetTypes()
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.<>c.b__15_0(Assembly assembly) in E:\Development\MonoGame\MonoGame\MonoGame.Framework.Content.Pipeline\Serialization\Intermediate\IntermediateSerializer.cs:line 285
at System.Linq.Enumerable.d__233.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source) at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.FindType(String typeName) in E:\Development\MonoGame\MonoGame\MonoGame.Framework.Content.Pipeline\Serialization\Intermediate\IntermediateSerializer.cs:line 284 at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadTypeName() in E:\Development\MonoGame\MonoGame\MonoGame.Framework.Content.Pipeline\Serialization\Intermediate\IntermediateReader.cs:line 258 The thread 0x111d0 has exited with code 0 (0x0). at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObject[T](ContentSerializerAttribute format, ContentTypeSerializer typeSerializer, T existingInstance) in E:\Development\MonoGame\MonoGame\MonoGame.Framework.Content.Pipeline\Serialization\Intermediate\IntermediateReader.cs:line 71 at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObject[T](ContentSerializerAttribute format) in E:\Development\MonoGame\MonoGame\MonoGame.Framework.Content.Pipeline\Serialization\Intermediate\IntermediateReader.cs:line 42 The thread 0x119b0 has exited with code 0 (0x0). at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.Deserialize[T](XmlReader input, String referenceRelocationPath) in E:\Development\MonoGame\MonoGame\MonoGame.Framework.Content.Pipeline\Serialization\Intermediate\IntermediateSerializer.cs:line 98 at Microsoft.Xna.Framework.Content.Pipeline.XmlImporter.Import(String filename, ContentImporterContext context) in E:\Development\MonoGame\MonoGame\MonoGame.Framework.Content.Pipeline\XmlImporter.cs:line 27 at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context) in E:\Development\MonoGame\MonoGame\MonoGame.Framework.Content.Pipeline\ContentImporter.cs:line 45
at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent) in E:\Development\MonoGame\MonoGame\MonoGame.Framework.Content.Pi
Exception thrown: ‘System.Threading.ThreadAbortException’ in mscorlib.dll
Exception thrown: ‘System.Threading.ThreadAbortException’ in Pipeline.exe

Interesting thing for me is that one of the pieces is from xna
I thought we were supposed to have been weaned off xna.
I will do some more digging on the Microsoft module the exception originated in.

Ok. Got it.
Failing to connect to SharpDX.Mathematica
Fixed by adding SharpDX.MediaFoundation reference.

Whoever is doing current changes to Pipeline.exe can include this ‘fix’ before next release.

Now: Back to my dev activity,

What @harry-cpp thinks of this?