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

Author Topic: LoaderLock  (Read 7124 times)

0 Members and 2 Guests are viewing this topic.

Kwang1imsa

  • Newbie
  • *
  • Posts: 26
    • MSN Messenger - kwang1imsa@gmail.com
    • View Profile
LoaderLock
« on: July 15, 2011, 01:45:58 am »
Code: [Select]
private Sprite drawSpr = new Sprite();

In this line I am experiencing this error:

Quote
LoaderLock was detected:
Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
[/quote]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
LoaderLock
« Reply #1 on: July 15, 2011, 08:59:55 am »
The message says it all, don't try to call a SFML function to initialize a class member, since it will be called at global initialization.
Laurent Gomila - SFML developer

Kwang1imsa

  • Newbie
  • *
  • Posts: 26
    • MSN Messenger - kwang1imsa@gmail.com
    • View Profile
LoaderLock
« Reply #2 on: July 16, 2011, 06:54:38 am »
Thank you for the response.

How can I get around it? I am not familiar with MDAs.  How can I store a sprite without throwing it into a variable?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
LoaderLock
« Reply #3 on: July 16, 2011, 09:43:45 am »
Can't you initialize it in the constructor?
Laurent Gomila - SFML developer

Kwang1imsa

  • Newbie
  • *
  • Posts: 26
    • MSN Messenger - kwang1imsa@gmail.com
    • View Profile
LoaderLock
« Reply #4 on: July 16, 2011, 06:55:50 pm »
That's exactly what I do:

Code: [Select]
private Sprite drawSpr;

In the constructor:

Code: [Select]
drawSpr = new Sprite();

This is very odd. Am I doing something wrong?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
LoaderLock
« Reply #5 on: July 17, 2011, 10:48:23 am »
Quote
That's exactly what I do

That's not what you showed in your first post... ;)

Quote
This is very odd. Am I doing something wrong?

Can you show a complete and minimal source code that reproduces this problem?
Laurent Gomila - SFML developer

Kwang1imsa

  • Newbie
  • *
  • Posts: 26
    • MSN Messenger - kwang1imsa@gmail.com
    • View Profile
LoaderLock
« Reply #6 on: July 17, 2011, 11:04:00 pm »
Oh sorry. I meant to say "that's what I did after your first response"  :lol:

Anyways, that is essentially everything that is giving me problems.  I am also experiencing it with SFML.Graphics.Image();.

This is the entire constructor of my class:

Code: [Select]
public class GridEditGL : Panel
    {
        private Sprite drawSpr;
        private Sprite objSpr;
        public Dictionary<string,Sprite> drawSprList = new Dictionary<string,Sprite>();
        public List<tile> tilelist = new List<tile>();
        public List<obj> objlist = new List<obj>();
        public Sprite bgSpr;
        public SFML.Graphics.Image bg;
        private string defaultEmpty = @"resources\engine\editor\images\empty.png";
        public EnviroEditor parent;
        public RenderWindow mainWin;
        public GridEditGL(EnviroEditor par)
        {
            this.parent = par;
            this.Size = new Size(320, 320);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            drawSpr = new Sprite();
            bg = new SFML.Graphics.Image();
            objSpr = new Sprite();
            bgSpr = new Sprite();
            timer = new Timer();
            mainWin = new RenderWindow(this.Handle);
            mainWin.PreserveOpenGLStates(true);
            mainWin.UseVerticalSync(true);
 
            updateSize();
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
            SetStyle(ControlStyles.Opaque, true);
            UpdateStyles();

        }


Edit: By the way, the class GridEditGL is created inside of the constructor of another class, which is created in the constructor of another class.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
LoaderLock
« Reply #7 on: July 18, 2011, 07:33:39 am »
Quote
Edit: By the way, the class GridEditGL is created inside of the constructor of another class, which is created in the constructor of another class.

This is exactly why I'd prefer to see a complete and minimal code, not an incomplete piece of code from your big program ;)
Laurent Gomila - SFML developer

Kwang1imsa

  • Newbie
  • *
  • Posts: 26
    • MSN Messenger - kwang1imsa@gmail.com
    • View Profile
LoaderLock
« Reply #8 on: July 18, 2011, 08:29:17 am »
Alright, sorry.  This is as much as I think is related to the issue.  I hope this supplement will cover it:

Main:
Code: [Select]
           Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.DoEvents();
            Application.Run((Form)new MainGui());


MainGui Constructor:
Code: [Select]

this.Hide();
                MainGui.root = this;
                this.splashScreen = new Splash();
                BackgroundWorker backgroundWorker = new BackgroundWorker();
                backgroundWorker.WorkerReportsProgress = true;
                backgroundWorker.DoWork += new DoWorkEventHandler(this.backgroundWorker1_DoWork);
                backgroundWorker.RunWorkerAsync();
                backgroundWorker.ReportProgress(this.loadState += 5);
               
                this.InitializeComponent();
                /*some irrelevant code here*/
                EnviroEditor enviroEditor = new EnviroEditor(par2); //<-- this contains GridEditGL
                this.loadState = 100;
                //System.Threading.Thread.Sleep(1000);
                ((Control)this).Show();


EnviroEdit Constructor:
Code: [Select]

public GridEditGL editor;
public EnviroEditor(EnviroBox par)
        {
            parent = par;
            InitializeComponent();
            editType.SelectedIndex = 0;
            teditor = new GridEdit(this);
            editor = new GridEditGL(this); //this is it <---
            Application.EnableVisualStyles();
            editor.tilelist = parent.tilelist;
            editor.objlist = parent.objlist;
            /*more irrelevant code*/
           
        }


I hope I didn't miss anything this time.  Thank you for keeping me company through this issue.[/code]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
LoaderLock
« Reply #9 on: July 18, 2011, 08:50:36 am »
Sorry if it wasn't clear, but I don't want pieces of your original code. I'd like you to write a (new) complete code that reproduces the problem -- without the 99% of your initial code that is irrelevant. I need something that I can test quickly, something that focuses on the problem, and only the problem.

That's what "minimal and complete code" means ;)
Laurent Gomila - SFML developer

Kwang1imsa

  • Newbie
  • *
  • Posts: 26
    • MSN Messenger - kwang1imsa@gmail.com
    • View Profile
LoaderLock
« Reply #10 on: July 18, 2011, 06:43:05 pm »
Ok. I understand.

A quick note to make, I tested this on 2 computers.  On one, the LoaderLock actually hangs the application, on the other, it is just thrown but can be ignored.

I will get something up shortly.

Kwang1imsa

  • Newbie
  • *
  • Posts: 26
    • MSN Messenger - kwang1imsa@gmail.com
    • View Profile
LoaderLock
« Reply #11 on: July 18, 2011, 06:52:03 pm »
Ok, so here is how to reproduce:

This did not throw a LoaderLock exception for me, but all the same it hangs the application:

1. Start a new Windows Forms Project
2. Go into Form1() and write this:

Code: [Select]

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            new SFML.Graphics.Sprite();
        }

    }
}



The application hangs on my new computer, and shouldn't on my old.  If I comment out SFML.Graphics.Sprite, it will run fine.

EDIT: I have been using SFML 1.6 and I just realized that my new computer runs an ATI graphics card.

Is there a version of 2.0 I can get for .NET?[/code]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
LoaderLock
« Reply #12 on: July 18, 2011, 10:51:39 pm »
Quote
I have been using SFML 1.6 and I just realized that my new computer runs an ATI graphics card.

Oh... that explains everything :)

Quote
Is there a version of 2.0 I can get for .NET

https://github.com/SFML/SFML.Net
Laurent Gomila - SFML developer

Kwang1imsa

  • Newbie
  • *
  • Posts: 26
    • MSN Messenger - kwang1imsa@gmail.com
    • View Profile
LoaderLock
« Reply #13 on: July 19, 2011, 03:19:07 am »
Awesome. I have been looking for that for ages!

Radnen

  • Newbie
  • *
  • Posts: 17
    • View Profile
LoaderLock
« Reply #14 on: August 07, 2011, 11:08:41 pm »
Quote from: "Laurent"
Quote
I have been using SFML 1.6 and I just realized that my new computer runs an ATI graphics card.

Oh... that explains everything :)


How does that explain everything? I have the same issue and use an Nvidia card.

Or is this loader lock present in version 1.6?

 

anything