slimshady Posted May 18, 2006 Posted May 18, 2006 Is it not possible to retreive session variables created in a Sub in a Public Shared Function? I get the following error message: "BC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class". I underlined the code where the error occurrs. Here's the code: Sub GetLoggedInUser() Dim userID As String Dim strFullName As String strFullName = User.Identity.Name 'Get just the corpId (remove the domain info) userID = strFullName.Substring(strFullName.IndexOf("\", 0) + 1) Session("sUserId") = userID End Sub Public Shared Function HasPermission() As Boolean Dim myCheck As New PermissionCheckClass 'this is the class where the code is located myCheck.GetLoggedInUser() 'Get the users CorpId from the session variable. Dim pCorpId As String = CType([u]Session[/u].Item("sUserId"), String) End Function Has the problem anything to do with that I have both the sub to set the session variable AND the function to retreive the variable in the same class? Any thoughts appreciated! Quote
slimshady Posted May 18, 2006 Author Posted May 18, 2006 Ok, so by removing "Shared" from the "Public Shared Function" I solved the problem *eh* :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.