SFML community forums

Bindings - other languages => DotNet => Topic started by: bepawuca on December 04, 2010, 11:08:20 pm

Title: Crash on exit when using String2D
Post by: bepawuca on December 04, 2010, 11:08:20 pm
Anything I write with SFML.NET 1.6 crashes on exit ('vshost.exe has stopped working' on Windows 7 and 'memory could not be read' on XP) if I create an instance of String2D at some point in the program, even in the sample included with the documentation. This problem also occurs when I do not draw the String2D to the screen, but only create it. I am using VS2005, and have added the csml-***.dll files under extlibs to bin\Debug and bin\Release, and added references to the .NET assemblies lib\sfml-***.dll.

Any ideas what might be going on? And, if not, are there any alternatives to String2D I could use?
Title: Crash on exit when using String2D
Post by: Laurent on December 04, 2010, 11:23:51 pm
It's a known bug. It shouldn't crash if you never use the default font.
Title: Crash on exit when using String2D
Post by: bepawuca on December 04, 2010, 11:39:27 pm
I get the same crash even if I don't use the default font.
Title: Crash on exit when using String2D
Post by: Laurent on December 04, 2010, 11:40:43 pm
How do you create your String2Ds?
Title: Crash on exit when using String2D
Post by: bepawuca on December 05, 2010, 12:14:36 am
Here's the full code, taken from the documentation sample:

Code: [Select]
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 app = new RenderWindow(new VideoMode(800, 600), "SFML window");
            app.Closed += new EventHandler(OnClose);

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

            // Start the game loop
            while (app.IsOpened())
            {
                // Process events
                app.DispatchEvents();

                // Clear screen
                app.Clear();;

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

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


Naturally, I've put arial.ttf in the right place for it to work.
Title: Crash on exit when using String2D
Post by: Laurent on December 05, 2010, 10:17:10 am
Ok, seems like it's not the same bug. I don't think there's a workaround for this one, except switching to SFML 2.
Title: Crash on exit when using String2D
Post by: bepawuca on December 05, 2010, 03:13:27 pm
Can I use SFML 2 with .NET 2.0 and VS2005?
Title: Crash on exit when using String2D
Post by: Laurent on December 05, 2010, 08:38:05 pm
Should be ok, yes.
Title: Crash on exit when using String2D
Post by: bepawuca on December 05, 2010, 10:24:48 pm
I just tried it out and it works fine. Thanks for the help!