Desktop App Crashes Runtime Error Bad Objective-C cast


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

closing controls like:

if curView <> nil then
  if curView isA conButtons then
  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.


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.