Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Getting an error on trying to run the example program  (Read 4535 times)

0 Members and 1 Guest are viewing this topic.

Superty

  • Newbie
  • *
  • Posts: 3
    • View Profile
Getting an error on trying to run the example program
« on: December 08, 2012, 05:18:00 pm »
The sample:

using System;
using SFML.Audio;
using SFML.Window;
using SFML.Graphics;

namespace Example
{
    class Program
    {
        static void OnClose(object sender, EventArgs e)
        {
            // Close the window when OnClose event is received
            RenderWindow window = (RenderWindow)sender;
            window.Close();
        }

        static void Main(string[] args)
        {
            // Create the main window
            RenderWindow window = new RenderWindow(new VideoMode(800, 600), "SFML window");
            window.Closed += new EventHandler(OnClose);

            // Load a sprite to display
            Texture texture = new Texture("cute_image.jpg");
            Sprite sprite = new Sprite(texture);

            // Create a graphical string to display
            Font font = new Font("arial.ttf");
            Text text = new Text("Hello SFML.Net", font);

            // Load a music to play
            Music music = new Music("nice_music.ogg");
            music.Play();

            // Start the game loop
            while (window.IsOpen())
            {
                // Process events
                window.DispatchEvents();

                // Clear screen
                window.Clear();

                // Draw the sprite
                window.Draw(sprite);

                // Draw the string
                window.Draw(text);

                // Update the window
                window.Display();
            }
        }
    }
}
 


And the error is

An unhandled exception of type 'System.BadImageFormatException' occurred in mscorlib.dll

Additional information: Could not load file or assembly 'sfmlnet-window-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.

NightCabbage

  • Newbie
  • *
  • Posts: 20
    • View Profile
    • Email
Re: Getting an error on trying to run the example program
« Reply #1 on: December 08, 2012, 05:38:28 pm »
Ok, well I just ran the whole thing, minus the music/ogg part, and it worked fine.

Don't forget to copy the jpg and ttf files into your bin directory (release/debug).

Other than that, I'll need more information! :)
such as line number of where the error is, etc.
« Last Edit: December 08, 2012, 05:40:03 pm by NightCabbage »

Superty

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Getting an error on trying to run the example program
« Reply #2 on: December 08, 2012, 06:29:18 pm »
I did forget to copy the files, but even after I did I still get the same error.

I'm using Visual Studio and C#

There're no line numbers, the error looks like this


If I try to break it shows this

krzat

  • Full Member
  • ***
  • Posts: 107
    • View Profile
Re: Getting an error on trying to run the example program
« Reply #3 on: December 08, 2012, 07:21:13 pm »
Wrong libraries probably. Add x84 libraries to x84 project.
SFML.Utils - useful extensions for SFML.Net

Superty

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Getting an error on trying to run the example program
« Reply #4 on: December 08, 2012, 07:52:16 pm »
You were right, thanks!