Compile Error that I can't figure out

Running on macOS 10.12.6, Xojo 2017 r2.1

When a session starts, I want to collect some of the session info and write it to a log file. In the Session Open Event Handler I call a public method (GetSessionInfo) also in the Session object. This method then calls a shared method attached to a class that defines the session. The class is defined in a module called mClasses.
(how imaginative, right?)

[code]Public Sub GetSessionInfo()
dim oSession As mClasses.clsSession
dim drSession As new DatabaseRecord

oSession = new mClasses.clsSession
oSession = mClasses.clsSession.CreateSessionObject //this line generates the compile error

'drSession.DateColumn(“SessionStart”) = oSession.SessionStart
'drSession.Column(“SessionID”) = oSession.ID
'drSession.Column(“Account”) = oSession.Account
'drSession.DateColumn(“SessionEnd”) = Nil

'Session.dbSQL.InsertRecord(“SessionLog”, drSession)

End Sub

Then the shared method on the clsSession class is

[code]Public Shared Function CreateSessionObject() as Object
Dim oSession As mClasses.clsSession
dim dDate As new Date

oSession = new mClasses.clsSession

oSession.ID = Session.Identifier
oSession.Account = Session.sUserIDSession
oSession.SessionStart = dDate
oSession.SessionEnd = nil
oSession.Notes = “”

Return oSession
End Function

When I try to run the app, I get the following compile error:

[quote]Type mismatch error. Expected class mClasses.clsSession, but got Object.
oSession = mClasses.clsSession.CreateSessionObject[/quote]

I returned a clsSession object, so what does the error mean?


Your method is declared to return an object which is not a mClasses.clsSession
A cast is probably required where you call this method

But why return “object” when your code already actually creates & returns an mClasses.clsSession ?
That seems like asking for this error to occur


Public Shared Function CreateSessionObject() as Object


Public Shared Function CreateSessionObject() as mClasses.clsSession

Thanks Norman