SFML community forums
Bindings - other languages => DotNet => Topic started by: random_canadian on June 03, 2013, 03:20:07 am
-
Following the steps given on this thread (http://en.sfml-dev.org/forums/index.php?topic=7674.0), I managed to setup SFML.Net 2.0 with Visual Studio C# 2012. However, I get the following error whenever I actually try to build something that references the SFML library...
An unhandled exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
Additional information: Could not load file or assembly 'sfmlnet-graphics-2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
According to this page (http://msdn.microsoft.com/en-us/library/system.badimageformatexception.aspx), the file image of the sfmlnet-graphics-2 DLL is "invalid."
The exception that is thrown when the file image of a dynamic link library (DLL) or an executable program is invalid.
Any ideas about what I may have done wrong?
Thanks!
EDIT: After some more research it appears this is a problem with discrepancies between x64 or x86 builds (http://en.sfml-dev.org/forums/index.php?topic=9917.0). If I change the CPU settings to "prefer x64" (I am using 64-bit SFML), then the build succeeds. So my question is what happens if my user wants to run the game on a x86 system? Do I need to include DLLs of both x64 and x86 versions of SFML? How do I do this?
EDIT #2: Here's yet another thread about this issue (http://en.sfml-dev.org/forums/index.php?topic=2405.0) but, my question remains. What is the permanent solution?
-
You must use the x86 DLLs for the x86 build of your application, and the x64 DLLs for the x64 build of your application. Simple.
-
Fair enough :)
Thanks Laurent.
-
Hey, I had the same problems as random_canadian. Then I tried to run a 32Bit and 64Bit sfml project,
but I always get the same Exception:
"BadImageFormatException"
"HRESULT: 0x8007000B"
Here's my code:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using SFML;using SFML.Graphics;namespace SFML
.Net_Test{ class Program
{ static void Main
() { RenderWindow window
= new RenderWindow
(new Window
.VideoMode(200,
200),
"test"); Window
.Window win
= new Window
.Window(new Window
.VideoMode(200,
200),
"test"); CircleShape cs
= new CircleShape
(100
.0f
); cs
.FillColor = Color
.Green; while (win
.IsOpen()) { } } }}
-
Phew! I'm really glad I stumbled across this post. Same exact problem on my end, and same exact solution.
Thanks so much!
-
I have the same problem was. Thanks for the help