# App crashed when starting : Event loop

**URL:** <https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801>\
**Category:** Windows\
**Created:** [October 23, 2025, 3:28pm UTC](https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801 "2025-10-23T15:28:36Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sébastien\_Angot](https://forum.xojo.com/user_avatar/forum.xojo.com/s%C3%A9bastien_angot/32/11094_2.png) [@Sébastien\_Angot](https://forum.xojo.com/u/S%C3%A9bastien_Angot)\
**Post date:** [October 23, 2025, 3:28pm UTC](https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801/1 "2025-10-23T15:28:37Z")

</div>

I developed an App for MacOS and Windows, and I want to build an update.

On MacOS, no trouble, everything is working well.

With the last XOJO relase 2025r2.1, I tested my App on Windows and it crashes while starting.

The debugger shows the following error:

```auto
Your application crashed due to an access violation. The Debugger may show invalid values. Check the selected line, make corrections, and try again.

> Stack - Main Thread
> Event Loop

```

I have no more details. What can I do?

---

<div class="post-metadata">

**Author:** ![Eric\_Williams](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ecccb3/32.png) [@Eric\_Williams](https://forum.xojo.com/u/Eric_Williams)\
**Post date:** [October 23, 2025, 3:34pm UTC](https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801/2 "2025-10-23T15:34:42Z")

</div>

Try launching the debug session using the “Run Paused” option. That may let you get into the debugger before whatever is causing this issue.

---

<div class="post-metadata">

**Author:** ![Sébastien\_Angot](https://forum.xojo.com/user_avatar/forum.xojo.com/s%C3%A9bastien_angot/32/11094_2.png) [@Sébastien\_Angot](https://forum.xojo.com/u/S%C3%A9bastien_Angot)\
**Post date:** [October 23, 2025, 4:14pm UTC](https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801/3 "2025-10-23T16:14:52Z")

</div>

Thanks, I finally found the origin of the problem : a function closed its window before returning a value, and it seems to crash the program.

---

<div class="post-metadata">

**Author:** ![Eric\_Williams](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ecccb3/32.png) [@Eric\_Williams](https://forum.xojo.com/u/Eric_Williams)\
**Post date:** [October 23, 2025, 7:51pm UTC](https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801/4 "2025-10-23T19:51:07Z")

</div>

If you can take a minute and create a small project that crashes like this, the Xojo team would surely appreciate it. You shouldn’t be able to crash like this using conventional Xojo code.

---

<div class="post-metadata">

**Author:** ![Arnaud\_N](https://forum.xojo.com/user_avatar/forum.xojo.com/arnaud_n/32/21824_2.png) [@Arnaud\_N](https://forum.xojo.com/u/Arnaud_N)\
**Post date:** [October 24, 2025, 7:15am UTC](https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801/5 "2025-10-24T07:15:59Z")

</div>

> [@Eric\_Williams](#):
>
> You shouldn’t be able to crash like this using conventional Xojo code.

Unless he’s returning a property of a control that belongs to the closed window.

---

<div class="post-metadata">

**Author:** ![Sébastien\_Angot](https://forum.xojo.com/user_avatar/forum.xojo.com/s%C3%A9bastien_angot/32/11094_2.png) [@Sébastien\_Angot](https://forum.xojo.com/u/S%C3%A9bastien_Angot)\
**Post date:** [October 24, 2025, 7:42am UTC](https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801/6 "2025-10-24T07:42:38Z")

</div>

I tried to reproduce this issue with a new project, but closing before returning a value doesn’t seem to crash the app.

It’s probably the combination with other factors that causes the crash.

---

<div class="post-metadata">

**Author:** ![Sébastien\_Angot](https://forum.xojo.com/user_avatar/forum.xojo.com/s%C3%A9bastien_angot/32/11094_2.png) [@Sébastien\_Angot](https://forum.xojo.com/u/S%C3%A9bastien_Angot)\
**Post date:** [October 24, 2025, 9:36am UTC](https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801/7 "2025-10-24T09:36:48Z")

</div>

It seems my issue is not fully resolved, unfortunately…

In fact, when my App is starting, I’m detecting if there is any News to display :

```xojo
dim w As new wNews
var newsFound As Boolean = w.readXml(progInit)
w.Close
return newsFound

```

Here is the readXml function:

```xojo
self.hide()

me.progInit = progInit

Dim file As FolderItem

#if TargetMachO
  file = sandBoxFolder.Child("mcnews.xml")
#elseif TargetWin32
  file =SpecialFolder.Preferences.child("MacCompta").child("mcnews.xml")
#endif

if (file = nil) then
  'close()
  return False
  
else

  dim url As String
  dim os As String
  dim systemVersion As String
  #if TargetMacOS then
    os = "Mac OS X"
  #elseif TargetWin32 then
    os = "Windows"
  #endif
  systemVersion = getSystemVersion()
  
  url = "https://www.mywebsite.ch/news/checknews.php?app="+str(app.majorVersion)+"."+str(app.minorVersion)+"."+str(app.bugVersion)+"&os="+os+"&v="+systemVersion+"&licence="+str(IDForSN(serialNumber))+"&lang="+kLanguageIdentifier+"&output="
  url = ReplaceAll(url," ","%20")
  
  if (System.Network.LookupIPAddress("mywebsite.ch")<>"" and socketUpdater.get(url+"xml",file, 5) and file.length>60) then
    
    Dim xml As new XmlDocument
    Dim nodeCurrentNews As XmlNode
    Dim currentNewsID As Integer
    Dim forceNews As Boolean = false
    
    if(file = nil or not file.Exists) then
      dim c As new Clipboard
      c.Text = url
      return false
    end if
    
    try
      xml.loadXml(file)
      xml.PreserveWhitespace = False
      
      nodeCurrentNews = xml.DocumentElement.FirstChild
      currentNewsID = val(nodeCurrentNews.Child(0).FirstChild.Value)
      forceNews = (val(nodeCurrentNews.Child(1).FirstChild.Value)=1)
      
    Catch e As XmlException
         return false
    end try
    
    if(showNews(currentNewsID, forceNews)) then
      dim s As new HTTPSocket
      dim sourceCode As String = DefineEncoding(replaceAll(s.Get(url+"html",90),chr(13),endOfLine), Encodings.UTF8)
      Dim f As FolderItem = GetTemporaryFolderItem
      HTMLInfos.LoadPage(sourceCode, f)
     
      return true
      
    else
      'close()
      return False
    end if
    
  elseif(not progInit) then
    'close()
    return False
  else
    'close()
    return False
  end if
end if

```

I finally found that the App crashed when w.Close is called. If I comment this line, everything works properly, and I don’t understand why.

I checked the wNews window and the closing event is not used.

Any idea? Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [October 24, 2025, 10:43am UTC](https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801/8 "2025-10-24T10:43:38Z")

</div>

A simple trick to avoid such situations is not to do too much in App.Open. Instead use a single timer call and do your initialisations there.

---

<div class="post-metadata">

**Author:** ![Sébastien\_Angot](https://forum.xojo.com/user_avatar/forum.xojo.com/s%C3%A9bastien_angot/32/11094_2.png) [@Sébastien\_Angot](https://forum.xojo.com/u/S%C3%A9bastien_Angot)\
**Post date:** [October 24, 2025, 11:29am UTC](https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801/9 "2025-10-24T11:29:30Z")

</div>

Thanks for your replies. I tried to use a timer in my wNews that closes the window after X seconds, it seems to work now.

---

<div class="post-metadata">

**Author:** ![Eric\_Williams](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ecccb3/32.png) [@Eric\_Williams](https://forum.xojo.com/u/Eric_Williams)\
**Post date:** [October 24, 2025, 11:58am UTC](https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801/10 "2025-10-24T11:58:25Z")

</div>

Why is that code even in a window? It doesn’t appear to interact with the UI at all.

---

<div class="post-metadata">

**Author:** ![Eric\_Williams](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ecccb3/32.png) [@Eric\_Williams](https://forum.xojo.com/u/Eric_Williams)\
**Post date:** [October 24, 2025, 11:59am UTC](https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801/11 "2025-10-24T11:59:29Z")

</div>

> [@Arnaud\_N](#):
>
> Unless he’s returning a property of a control that belongs to the closed window.

Even then, the framework should throw some kind of exception.

---

<div class="post-metadata">

**Author:** ![Sébastien\_Angot](https://forum.xojo.com/user_avatar/forum.xojo.com/s%C3%A9bastien_angot/32/11094_2.png) [@Sébastien\_Angot](https://forum.xojo.com/u/S%C3%A9bastien_Angot)\
**Post date:** [October 24, 2025, 12:49pm UTC](https://forum.xojo.com/t/app-crashed-when-starting-event-loop/86801/12 "2025-10-24T12:49:40Z")

</div>

Sure, it’s not the best way I guess, but when a news item exists, the _wNews_ window is shown and displays it.
