NilObjectException for System.VersionData


I dont know the specific code Xojo uses but does this code generate a nil object exception ?

OSVersionInfo is a structure defined as

Attributes( StructureAlignment = 1 ) Protected Structure OSVersionInfo
  major as integer
  minor as integer
  bug as integer
End Structure
Private Function MacOSVersionInfo() As OSVersionInfo
  #If targetMacOS
    Static rvalue As OSVersionInfo
    Static inited As Boolean
    If inited Then 
      Return rvalue
    End If
    Declare Function NSClassFromString Lib "AppKit" ( className As CFStringRef ) As Ptr
    Declare Function processInfo Lib "AppKit" Selector "processInfo" ( ClassRef As Ptr ) As Ptr
    Dim myInfo As Ptr = processInfo( NSClassFromString( "NSProcessInfo" ) )
    Declare Function operatingSystemVersion Lib "AppKit" selector "operatingSystemVersion" ( NSProcessInfo As Ptr ) As OSVersionInfo
    rvalue = operatingSystemVersion( myInfo )
    inited = True
    Return rValue
End Function


I wonder if they try to parse the string version (which apple says is NOT safe)

What does this show on your users German M1 ?

Declare Function NSClassFromString Lib "Foundation" (ClassObj As CFStringRef) As ptr
Declare Function NSProcessInfo Lib "Foundation" Selector "processInfo" (ClassName As ptr) As ptr
Declare Function NSVersionString Lib "Foundation" Selector "operatingSystemVersionString" (prInfo As ptr) As CFStringRef

Dim className As ptr = NSClassFromString("NSProcessInfo")

Dim procInfo As ptr = NSProcessInfo( className )

Msgbox NSversionString( procInfo )

could someone who CAN post on TOF point Beatrix here ?

While I might not know the Xojo framework issue I might have an alternative that is suitable

She does have an account here.

She does
Hasn’t been seen here in some time so I figured pinging her on TOF might work

But if MBS works for w this for her then she’s possibly not interested in another workaround

Oh well

I’ve included a revised version of my own functions for this in the Starter I posted in Shared (again)

And since its full source its a tad easier to fix for yourself IF you need

INN links and INN references are banned from TOF. Like Twitter bans Mastodon links.

BTW: I see no reason as to why your first code snippet would return a NOE, the only thing that might cause a problem down the road is that NSClassFromString is under the Foundation umbrella, not AppKit.

1 Like

yeah someone else mentioned that to me in a direct message

but & other link shorteners work :stuck_out_tongue:

oh well

I’m sure she’ll be fine using MBS

Adding more dependencies atop dependencies.

When built in stuff fails and you cant get fixes ASAP through patches what options do you have ?

Maybe Xojo needs to start on 2022r4.1 already ?

Declares; as you’re in control, not someone else.


But MBS is “the easy way” to get this done & he is VERY responsive

So its “the next best thing” and you dont have to mess with declares at all :stuck_out_tongue:

I usually sleep during the night.

As the MBS plugin works and Xojo does not the bug must be with Xojo. I just don’t understand why the guy who tested in a German system didn’t get the NOE, too.

I’ll try with 2022r4 next. But I don’t like to switch versions at the end the end of a release cycle.

Having a reliable partner who specialises in knowledge that I don’t have time to acquire.

1 Like

If Xojo would be as fast, precise and reliable as MBS we wouldn’t be here.

plus all the stuff that Xojo can’t and will never do.


Do you have access to that German M1 ?
I suspect f you try the code I posted at the outset that might give a clue
BUT if you have already tried MBS and use that widely then there’s no need to check my declares further