MGCB Spritefont error

I am having difficulty getting MGCB to work with Spritefonts.

I am taking a simple Spritefont file that I would normally use with XNA, and the XML is


EDIT: It doesn’t allow me to paste XML. However, I can assure you it’s just a simple Spritefont file that basically loads Comic Sans and works with XNA.


I copy the MGCB folder and place it into it’s own directory. I then copy the spritefont into that directory. I run


mgcb.exe /clean /rebuild /platform:Windows /build:TestSpriteFont2.spritefont


It simply crashes after some text, which includes:


Z:/MGCB/MGCB/TestSpriteFont2.spritefont
Building Font C:\WINDOWS\Fonts\comic.ttf
Building Font C:\WINDOWS\Fonts\comic.ttf
System.BadImageFormatException: An attempt was made to load a program with an in
correct format. (Exception from HRESULT: 0x8007000B)
at SharpFont.FT.FT_Init_FreeType(IntPtr& alibrary)
at SharpFont.Library…ctor()
at Microsoft.Xna.Framework.Content.Pipeline.Graphics.SharpFontImporter.Import
(FontDescription options, String fontName)
at Microsoft.Xna.Framework.Content.Pipeline.Processors.FontDescriptionProcess
or.ImportFont(FontDescription options, Single& lineSpacing, ContentProcessorCont
ext context, String fontName)
at Microsoft.Xna.Framework.Content.Pipeline.Processors.FontDescriptionProcess
or.Process(FontDescription input, ContentProcessorContext context)

Unhandled Exception: System.ArgumentOutOfRangeException: Index was out of range.
Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.Texture2DW
riter.Write(ContentWriter output, Texture2DContent value)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentWri
ter.WriteObject[T](T value)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.SpriteFont
ContentWriter.Write(ContentWriter output, SpriteFontContent value)
at Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler.ContentCom
piler.Compile(Stream stream, Object content, TargetPlatform targetPlatform, Grap
hicsProfile targetProfile, Boolean compressContent, String rootDirectory, String
referenceRelocationPath)
at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.WriteXnb(Objec
t content, PipelineBuildEvent pipelineEvent)
at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.BuildContent(P
ipelineBuildEvent pipelineEvent, PipelineBuildEvent cachedEvent, String eventFil
epath)
at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.BuildContent(S
tring sourceFilepath, String outputFilepath, String importerName, String process
orName, OpaqueDataDictionary processorParameters)
at MGCB.BuildContent.Build(Int32& successCount, Int32& errorCount)
at MGCB.Program.Main(String[] args)

I guess you are running the 32-bit (x86) version of Windows. MGCB (specifically the MonoGame.Framework.Content.Pipeline.dll) links against the 64-bit version of the SharpFont.dll and therefore only runs on 64-bit (x64) Windows.

I am running the 64-bit (x64) version of Windows 8.1, not the 32-bit version.

The exception System.BadImageFormatException usually points to a 32/64-bit conflict. Perhaps MGCB.exe does not find the right SharpFont.dll or freetype6.dll?

The SharpFont.dll and the freetype6.dll are located in the same directory as MGCB.exe.

Also I did not alter any of the files that were in the MGCB folder, I just simply moved the folder to it’s own directory, so I don’t think it could have the wrong versions of the dll.