Unable to build empty project with GeonBit.UI (Throws XML import errors)

Hi, (Sorry if this is the wrong place to ask this)

I’m trying to try out GeonBit.UI and when I go to build the project the ContentManager gives me this error for every XML file:

[PROJECT DIRECTORY]/Content/GeonBit.UI/themes/lowres/textures/slider_fancy_md.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.
     at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
     at System.Reflection.Assembly.GetTypes()
     at System.Linq.Enumerable.<SelectManyIterator>d__23`3.MoveNext()
     at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
     at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
     at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.FindType(String typeName)
     at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObject[T](ContentSerializerAttribute format, ContentTypeSerializer typeSerializer, T existingInstance)
     at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateReader.ReadObject[T](ContentSerializerAttribute format)
     at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate.IntermediateSerializer.Deserialize[T](XmlReader input, String referenceRelocationPath)
     at Microsoft.Xna.Framework.Content.Pipeline.XmlImporter.Import(String filename, ContentImporterContext context)
     at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context)
     at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent)

I’m pretty sure it’s with MonoGame (3.7.1) because it happens with non-GeonBit.UI XML’s also.
Is there a fix for this?

Thanks.

I recall encountering this error in the past myself on GeonBit.UI. I checked my notes, and I cannot find the exact fix I applied.

This is happening because the content tool is encountering some exception on trying to load an importer for an XML file. For GeonBit, that’s the style sheet files, etc. I don’t think the exception is specific, however. You could have other failures that result in this one when it attempts to load.

Any XMLs will need an importer available to the MGCB for them to work, I believe.

There are a few things you need to have though:

  1. You need a DataTypes.dll from GeonBit.UI built separately from your project. The dll needs to be referenced in the monogame content tool. The MCGB will look at it during the build.

  2. Open the MGCB GUI tool and try to build an XML item there. If you cannot get it working, I doubt you’ll get it working in the build. You can edit the file or use the tool to make sure the DataTypes.dll is referenced.

  3. I recall some issue around namespaces and DLL naming in that DataTypes.dll. I didn’t change any of the default namespaces in the file. I needed to use .NET standard, but I had to make sure the DLL assembly name and namespace was specified like this:

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <Version>1.0.0.0</Version>
    <PackageId>DataTypes</PackageId>
    <Product>DataTypes</Product>
    <Company>GeonBits.UI</Company>
    <Authors>GeonBits.UI</Authors>
    <AssemblyName>DataTypes</AssemblyName>
    <RootNamespace>DataTypes</RootNamespace>
  </PropertyGroup>

Finally, if you cannot figure it out, build monogame and its content tool in debug mode. Copy the debug versions + PDBs over the installed version (e.g. C:\Program Files…). Then, run the content tool. Attach to it in VS. Set your exceptions to break on this type. You can look at exactly what it is failing on.