Pipeline tool won't build spritefont

I’ve found a couple of threads discussing this issue but no solution. Title says it all really - something relating to spritefont is causing a build error in the content pipeline tool.

Error looks like this:

… and the spritefont file looks like this (it’s a generic file provided by the Xamarin monogame tutorial):

<?xml version="1.0" encoding="utf-8"?>
<!--
This file contains an xml description of a font, and will be read by the XNA
Framework Content Pipeline. Follow the comments to customize the appearance
of the font in your game, and to change the characters which are available to draw
with.
-->
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
  <Asset Type="Graphics:FontDescription">

    <!--
    Modify this string to change the font that will be imported.
    -->
    <FontName>Arial</FontName>

    <!--
    Size is a float value, measured in points. Modify this value to change
    the size of the font.
    -->
    <Size>50</Size>

    <!--
    Spacing is a float value, measured in pixels. Modify this value to change
    the amount of spacing in between characters.
    -->
    <Spacing>0</Spacing>

    <!--
    UseKerning controls the layout of the font. If this value is true, kerning information
    will be used when placing characters.
    -->
    <UseKerning>true</UseKerning>

    <!--
    Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
    and "Bold, Italic", and are case sensitive.
    -->
    <Style>Regular</Style>

    <!--
    If you uncomment this line, the default character will be substituted if you draw
    or measure text that contains characters which were not included in the font.
    -->
    <!-- <DefaultCharacter>*</DefaultCharacter> -->

    <!--
    CharacterRegions control what letters are available in the font. Every
    character from Start to End will be built and made available for drawing. The
    default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
    character set. The characters are ordered according to the Unicode standard.
    See the documentation for more information.
    -->
    <CharacterRegions>
      <CharacterRegion>
        <Start>&#32;</Start>
        <End>&#126;</End>
      </CharacterRegion>
    </CharacterRegions>
  </Asset>
</XnaContent>

Anyone know what’s causing this?

Thanks.

A BadImageFormatException is usually caused by trying to load a 32-bit dll on a 64-bit OS or vice-versa.

Are you running 32-bit Windows? The content pipeline tool only officially supports 64-bit, so it does not include 32-bit dll’s of native dependencies.

I’m on 64 bit windows.

Is there any way I may have accidentally set my project (or something, somewhere) to 32 bit? I wouldn’t know where to check for such a thing. Currently running a VS2017 update. When it’s ready I’ll have a hunt around.

No, the Pipeline Tool runs independently from your game. There’s no setting or configuration that could cause this issue.

Maybe the .dll got corrupted somehow? You could try reinstalling MonoGame. Make sure you get either 3.6 or a development build.

Already tried that too. After discovering it wasn’t working, I downloaded Monogame 3.6 (my previous version was something like 3.4), but still the same problem exists.

I note that the latest DirectX Runtime is required too. My computer has this.

I’ve just installed the latest development build of Monogame, attempted a fresh project and still the same error occurs.

When attempting to build the project directly from Visual Studio, I’m getting these errors:

If I remove the font file, it builds fine.

Thread bump.

Anybody got any knowledge or info on this?

I’m on a newly updated version of VS2017, the newest version of MonoGame, 64-bit Windows, and am not trying anything out of the ordinary which might cause Spritefonts to mess up.

I really don’t know what might be going wrong. Thanks.

Final thread bump: PROBLEM SOLVED.

A bit more searching led me to a thread where someone had downloaded the latest version of VS2012 Visual C++ Redist and it solved the problem.

I tried the same, got latest version of VS2017 Visual C++ Redist (x64), and now the problem is sorted.

:grin:

1 Like

Right click the font file and click on “Install for All Users”

In my case the font wasn’t being installed in the system directory and only for the single user, which meant that the pipeline tool couldn’t find it.

1 Like

This worked for me as well. Thank you!

Thanks!!!