Desktop App Crashes Runtime Error Bad Objective-C cast

Heya,

I have a small problem. I am running a Desktop App which crashes spontaneously on macOS.

Most of the time I don’t even get an error. Sometimes I get a Runtime Error like:

Runtime Error
Location Common/Cocoa/ObjCObject.h:135
Condition: !"Bad Objective-C cast"

This happens in an 8 Hour Use time around 3-8 Times a Day which is kinda often.
We tried to find reproducible Steps but it happens always in Different Scenarios. The only thing shared in the Scenarios is that I create controls on the fly and embed them. So anyone has an idea if it’s probably this?

For ex:

Dim cc as new conProductButton //container ctrl
cc.EmbedWithin(con,posx*cc.Width,posy*cc.Height,cc.Width-15,cc.Height)

closing controls like:

if curView <> nil then
  if curView isA conButtons then
    conButtons(curView).Close
  end if
end if

If anyone has an Idea what exactly could cause the bad objective-c cast I would be happy.

Thanks in advance.

Christian

I would suggest you contact Xojo support as I don’t see anything that could cause this and I think they need to see it crash from their IDE so that they can see what’s going on behind the scenes.

I use code like this all the time.