[SOLVED] MonoGame Pipeline Tool does not build images

Hello,

I have a problem when I try to build an image with the pipeline tool. Here is the error: -

Importer ‘TextureImporter’ had unexpected failure!
System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at FreeImageAPI.FreeImage.GetFileType(String filename, Int32 size)
at FreeImageAPI.FreeImage.LoadEx(String filename, FREE_IMAGE_LOAD_FLAGS flags, FREE_IMAGE_FORMAT& format)
at Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.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 am using MonoGame 3.6 with Visual Studio 2017. I tried to uninstall and reinstall MonoGame and Visual Studio, change the version of Visual Studio, and use development build of MonoGame but there was no luck. I tried to import both png and jpg files but it still produces the same error.

The project worked fine a few days ago but it suddenly stopped working only on this computer. I copied this project to another computer and it works just fine. I tried to create a new project but it still has the same error when I import and build images.

Does anyone have any ideas what is wrong with this computer? I suspect that it is something with Windows Update but there is no record of updates after the last time that MonoGame works on this computer. Thank you very much.

1 Like

That is the error when a 32-bit process tries to load a 64-bit DLL or vice versa. We support content building on 64-bit Windows only, and have done so for a while now. Are you running 32- or 64-bit Windows?

KonajuGames, I am running on 64-bit Windows.

So we have to work out what changed between the time it worked and the time it didn’t work. The call to FreeImageAPI.FreeImage.GetFileType(string, int) is the first call into the FreeImage DLL, and that is when it loads the FreeImage native library. If it is loading FreeImage.dll from another location on your system (not the one distributed with MonoGame, but a version installed by some other application that maybe modified the PATH), that is most likely a 32-bit version of FreeImage and that would cause this issue.

@KonajuGames Can I ask how to check which FreeImage.dll is loading and how to change the path back if it happens?

You could search your drive for copies of FreeImage.dll, or use Process Explorer or ListDLLs to list processes and the DLLs loaded by them, and where those DLLs are loaded from.

@KonajuGames I have tried to use both Process Explorer and ListDLLs but they do not give any of FreeImage.dll
I tried to use Debug Mode of the pipeline tool instead and it gave this output

‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\MGCB.exe’. Module was built without symbols.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\MonoGame.Framework.Content.Pipeline.dll’. Module was built without symbols.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\MonoGame.Framework.dll’. Module was built without symbols.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘Microsoft.GeneratedCode’.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\CppNet.dll’. Cannot find or open the PDB file.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘Microsoft.GeneratedCode’.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\SharpDX.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\SharpDX.DXGI.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\SharpDX.MediaFoundation.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Security\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Security.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Internals\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Internals.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.SqlXml\v4.0_4.0.0.0__b77a5c561934e089\System.Data.SqlXml.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\SharpFont.dll’. Module was built without symbols.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\SharpDX.Direct3D9.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Accessibility\v4.0_4.0.0.0__b03f5f7f11d50a3a\Accessibility.dll’. Cannot find or open the PDB file.
‘MGCB.exe’ (CLR v4.0.30319: MGCB.exe): Loaded ‘C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\FreeImageNET.dll’. Module was built without symbols.

The only FreeImage I can see is the last line which is FreeImageNET.dll. Is this the one it supposes to be?

I have just come across this post and tried reinstalling all Microsoft Visual C++ Redistributable Packages from this page. It seems that Microsoft Visual C++ Redistributable Packages for Visual Studio 2013 fixed my problem.

1 Like

Yes, this worked for me on Windows 8.1 x64 using Visual Studio Community 2017. Thank you!

1 Like