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

Author Topic: A Classic Newbie Error Message (References missing)  (Read 12036 times)

0 Members and 1 Guest are viewing this topic.

vipar

  • Newbie
  • *
  • Posts: 23
    • View Profile
A Classic Newbie Error Message (References missing)
« on: May 15, 2013, 10:59:36 pm »
Hey guys

I am new around here and wanted to start with something simple.
I know C# so it seems that SFML would be a nice start in game development!

I followed the Example in the SFML.Net API documentation file but I get an error about the DLLs:

Quote
An unhandled exception of type 'System.DllNotFoundException' occurred in sfmlnet-window-2.dll

Additional information: Unable to load DLL 'csfml-window-2': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I am sure this is not the first one. It's probably all of the DLLs I included that will trigger this type of message. I read something about some kind of..config setup..? To bind the DLLs correctly. But I was not sure if this was necessary seeing as the documentation just threw a code example at me from the start :P

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

namespace SFMLExample
{
    class Program
    {
        static void OnClose(object sender, EventArgs e)
        {
            // Close the window when the 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("Hellow SFML.Net", font);

            // Start the game loop
            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();
            }
        }
    }
}
 
« Last Edit: May 15, 2013, 11:17:48 pm by vipar »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: A Classic Newbie Error Message (References missing)
« Reply #1 on: May 16, 2013, 01:42:27 am »
Read the error message, it says all you need to know.

Since SFML.NET binds to the CSFML you need to copy the CSFML unmanaged dlls to the project output directory. The easiest way to do this is to add the CSFML dlls (csfml-window-2.dll, csfml-graphics-2.dll, csfml-audio-2.dll) to your project. You can find these in the "extlibs" folder. Then select the CSFML dlls in your project and set the "Copy to Output Directory" to "Copy if Newer".
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

vipar

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: A Classic Newbie Error Message (References missing)
« Reply #2 on: May 16, 2013, 09:14:00 am »
I did read the error message and I understood that I was missing DLLs.
My problem was that using "Add Reference" didn't do anything for me. Just threw an error.

So I was confused as to what I should do about those DLLs.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: A Classic Newbie Error Message (References missing)
« Reply #3 on: May 16, 2013, 01:15:23 pm »
My problem was that using "Add Reference" didn't do anything for me. Just threw an error.

Did you even try my answer above? No where did I say to use "Add Reference". You use "Add Reference" for the managed sfmlnet-window-2.dll, sfmlnet-graphics-2.dll, sfmlnet-audio-2.dll. As you already did.

But you need to add the unmanaged (that's why "Add Reference" doesn't work here) CSFML dlls from "extlibs" folder just as normal files to your project. See my answer above.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

vipar

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: A Classic Newbie Error Message (References missing)
« Reply #4 on: May 17, 2013, 08:28:01 pm »
My problem was that using "Add Reference" didn't do anything for me. Just threw an error.

Did you even try my answer above? No where did I say to use "Add Reference". You use "Add Reference" for the managed sfmlnet-window-2.dll, sfmlnet-graphics-2.dll, sfmlnet-audio-2.dll. As you already did.

But you need to add the unmanaged (that's why "Add Reference" doesn't work here) CSFML dlls from "extlibs" folder just as normal files to your project. See my answer above.

Dude calm down.
I did do as you said and it's solved.

 

anything