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

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

@Jjagg
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.
Monitoring…

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.
So…
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:
E:/Development/MonoGame/pipelinetest/MagicStaff.xml
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
Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer
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?

OK, back from my dev activity. Because I found another problem in pipeline.
In this case its Could not resolve Type.
I saw this in my single file test but thought it was just my ported contents.
Following searches it appears this is another old problem that was not resolved.
Digging again and noticed that we are still using
Microsoft.Xna.Framework.Content.Pipeline.
XMLImporter and Serialization
Would someone please confirm that we should be using
MonoGame.Framework.Content.Pipeline

I get the same error in one project with this code:

foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
var types = asm.GetTypes();

It looks like SharpDX.MediaFoundation has a reference to SharpDX.Mathematics but MG doesn’t distribute this dll. I solved it with a try/catch

            try
             {
                 var types = asm.GetTypes();
                 // ...
             }
             catch (ReflectionTypeLoadException rtle)
             {
                 if (asm.GetName().Name == "SharpDX.MediaFoundation") // caused by a missing SharpDX.Mathematics
                     continue;
                 throw rtle;
             }

No, it’s ok, MG has the same namespace and API with XNA but everything were re-implemented from scratch.
What is the other problem?