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

Author Topic: Problem on using SFML.NET binding  (Read 10404 times)

0 Members and 1 Guest are viewing this topic.

usernameialwaysforgot

  • Newbie
  • *
  • Posts: 5
    • View Profile
Problem on using SFML.NET binding
« on: September 01, 2016, 04:57:58 pm »
I am having problem in using SFML.NET 2.2 64bit in Visual studio 2015.

I have added all the library in the "lib" folder(sfmlnet-audio-2.dll,sfmlnet-graphics-2.dll,sfmlnet-system-2.dll,sfmlnet-window-2.dll) (as references) and add the lib in "extlibs" by copying it into the visual studio and setting them to always copy to "output directory"

It is showing me the error on "sfmlnet-window-2.dll" saying that it is missing the required component.

Therefore, I try to add the source code while removing the references in the "lib" folder to understand what the error is really about. I doesn't remove the lib in "extlibs".

The stack trace is

System.BadImageFormatException was unhandled
  HResult=-2147024885
  Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
  Source=SFMLTest
  StackTrace:
       at SFML.Graphics.RenderWindow.sfRenderWindow_createUnicode(VideoMode Mode, IntPtr Title, Styles Style, ContextSettings& Params)
       at SFML.Graphics.RenderWindow..ctor(VideoMode mode, String title, Styles style, ContextSettings settings) in C:\Users\Steven\Documents\Visual Studio 2015\Projects\SFMLTest\SFMLTest\SFML.Net-2.2\Graphics\RenderWindow.cs:line 66
       at SFML.Graphics.RenderWindow..ctor(VideoMode mode, String title) in C:\Users\Steven\Documents\Visual Studio 2015\Projects\SFMLTest\SFMLTest\SFML.Net-2.2\Graphics\RenderWindow.cs:line 30
       at MotionNetPlayer.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\Steven\Documents\Visual Studio 2015\Projects\SFMLTest\SFMLTest\Form1.cs:line 24
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  InnerException:



The source code my WPF program is

using SFML.Graphics;
using SFML.Window;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SFMLTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            RenderWindow window = new RenderWindow(new VideoMode(640, 480), "MotionNET Playback Example");
        }
    }
}



dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Problem on using SFML.NET binding
« Reply #1 on: September 01, 2016, 08:08:06 pm »
Looks like you're not providing the correct CSFML dlls. You need x86 SFML.NET libraries with x86 CSFML libraries. Same goes for x64.

Side note: That's not WPF, that's WinForms.

usernameialwaysforgot

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problem on using SFML.NET binding
« Reply #2 on: September 01, 2016, 09:27:58 pm »
dabbertorres , Since the 64 bit doesn't work, I try it again with 32 bit work.

Unexpectedly , it work on 32 bit.

By 32 bit, 64 bit, I mean the complete package which can be found on

http://www.sfml-dev.org/download/sfml.net/

Maybe it have the wrong csfml wrong in the archive?

I thought of downloading csfml from

http://www.sfml-dev.org/download/csfml/

but I don't know which version of CSFML that SFML.NET 2.2 64 bit used.

Could you please help me with the problem?

Comment on side note: yes, it is a WinForms. I got it mix up somehow.

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Problem on using SFML.NET binding
« Reply #3 on: September 02, 2016, 03:18:19 am »
The SFML.NET 64-bit download already contains CSFML 64-bit in the extlibs folder.

The download page doesn't contain a "complete package" for 32-bit and 64-bit versions. You have to download each individually. I assume that's the issue.

usernameialwaysforgot

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problem on using SFML.NET binding
« Reply #4 on: September 02, 2016, 12:04:20 pm »
@dabbertorres , I know that the download package does not contain the complete package for both 32 bit and 64 bit.

I mean , when I download the 64 bit package and reference the CSFML in 64 bit package, it doesn't work.

Than

I try to download the 32 bit and use the CSFML in 32 bit package but it work.

The problem is that 64 bit package doesn't work while the 32 bit package work.

I am trying to use 64 bit one.

Sorry, if my question seem confusing and thank you for helping me out.
 

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Problem on using SFML.NET binding
« Reply #5 on: September 02, 2016, 10:22:11 pm »
Ah okay. How are you switching to the 64-bit libraries? What are your build configurations in Visual Studio?

usernameialwaysforgot

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problem on using SFML.NET binding
« Reply #6 on: September 03, 2016, 12:59:42 am »
@dabbertorres, I don't understand what you mean by build configuration so I will just explain the complete steps on how I try to use it.

  • I have added library in "lib" folder(sfmlnet-audio-2.dll,sfmlnet-graphics-2.dll,sfmlnet-system-2.dll,sfmlnet-window-2.dll) as references
  • I have copy (csfml-audio-2.dll,csfml-graphics-2.dll,csfml-system-2.dll,csfml-window-2.dll,libsndfile-1.dll,openal32.dll,OpenTK.Compatibility.dll,OpenTK.dll) from "extlibs" to a solution
  • I have set their "Build Action" as "Content" and set "Copy to Output Directory" as "Copy always"
  • I use the build configurations(I think this is what you mean by build configurations) as "Debug" and "Platform" as "Any CPU" 
I than try to use

 RenderWindow window = new RenderWindow(new VideoMode(640, 480), "MotionNET Playback Example");
            window.SetVerticalSyncEnabled(true);

and I error is shown

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Problem on using SFML.NET binding
« Reply #7 on: September 03, 2016, 02:27:38 am »
I use the build configurations(I think this is what you mean by build configurations) as "Debug" and "Platform" as "Any CPU"

Yep, this is it. I've never had good experience with using Any CPU when using native dlls (ie: CSFML). Easiest thing to do is add x86 and x64 Platforms, and remove Any CPU. That should solve your problem.

usernameialwaysforgot

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problem on using SFML.NET binding
« Reply #8 on: September 03, 2016, 12:26:14 pm »
@dabbertorres, Thank you.

When I try to change it to x64 in build configurations, it solve the problem.

Lesson Learn : Don't use "Any CPU" when you are using native dlls.