SFML community forums

Bindings - other languages => DotNet => Topic started by: Darwin226 on April 07, 2010, 02:01:22 am

Title: Setting up Visual Studio 2008
Post by: Darwin226 on April 07, 2010, 02:01:22 am
So, I created a new project (console application) added the files in lib directory to the references and added the files in the extlibs directory next to my exe. Now I get this error

An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

Help please :D
Title: Setting up Visual Studio 2008
Post by: Laurent on April 07, 2010, 08:27:25 am
Which version of SFML do you use?

Do you compile for 32 or 64 bits?
Title: Setting up Visual Studio 2008
Post by: Spodi on April 07, 2010, 09:02:26 am
If you are on 64-bit Windows, you will have to recompile. Easiest thing to do is just rebuild the SFML .NET bindings, and your program you are using SFML in, as x86 instead of Any CPU. This way you can bypass recompiling SFML itself for the time being.
Title: Setting up Visual Studio 2008
Post by: Xeon06 on April 09, 2010, 11:20:09 pm
Target x86 when building.

This is the most common problem I see with beginners of SFML.Net. Maybe this should be stickied or something.
Title: Setting up Visual Studio 2008
Post by: Spodi on April 10, 2010, 01:25:02 am
Or maybe it the .NET bindings should be x86 by default. I don't see why Any CPU should be used for the samples when the sample build doesn't support x64.
Title: Setting up Visual Studio 2008
Post by: Laurent on April 10, 2010, 10:46:12 am
Quote from: "Spodi"
Or maybe it the .NET bindings should be x86 by default. I don't see why Any CPU should be used for the samples when the sample build doesn't support x64.

I'm not a .Net expert, the only reason why it is "Any CPU" is because it is the default option :)
If switching to "x86" is really better I'll change it.
Title: Setting up Visual Studio 2008
Post by: Spodi on April 10, 2010, 10:14:55 pm
Fair enough. Most people will just use Any CPU, too, until something breaks. After all, it is the best of all the options. :)

With Any CPU selected, .NET will use x86-64 if its a 64-bit OS. Otherwise, it will use x86. So anyone with a 32-bit OS won't be noticing this error when using the .NET bindings. When a user with a 64-bit OS runs the program, the .NET framework will end up looking the 64-bit version of the CSFML libraries. And this is why people get InvalidImageFormatException or whatever it is - since the program is trying to load a 32-bit library as 64-bit.

So yes, please use x86. :)
Title: Setting up Visual Studio 2008
Post by: Laurent on April 11, 2010, 09:56:57 am
Ok ;)
Title: Setting up Visual Studio 2008
Post by: messiaen on February 12, 2011, 04:48:41 am
Sorry for bumping this old thread, however I came across SFML.net and I ran into the same problem described in this thread. I am using Visual Studio C# Express 2008, but the problem is that I can't compile from the source targetting x86 because that feature isn't available in the express version.

Would anyone be kind to provide the x86-targetted .dll files or some alternative so I can overcome this and start learning SFML (it looks great!)?

edit: I use a x64 Windows 7 system.
Title: Setting up Visual Studio 2008
Post by: Brendon on February 12, 2011, 06:35:00 pm
I'm using Visual Studio C# 2008 Express and the downloaded sfml libraries seem to work for me.

In the dropdown box labeled "Any CPU", go to:
Configuration Manager > Active Solution Platform > Type or select new platform > x86