Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

'Access of shared member' warning on RedirectFromLoginPage

0 views
Skip to first unread message

Nick Large

unread,
Nov 23, 2009, 10:34:18 AM11/23/09
to
Hello.

I have a class library with a class for authentication that uses forms
authentication.

The RedirectFromLoginPage class is called through my application using:

ClassLibrary.Authentication.FormsAuthentication.RedirectFromLoginPage(UserID,
False)

and, although this method works as intended, it leaves a warning (green
squiggly) which looks like I don't know what I'm talking about
(unprofessional). Here is the declaration:

Public Shared mFormsAuthentication As New
System.Web.Security.FormsAuthentication

Public Shared Property FormsAuthentication() As
System.Web.Security.FormsAuthentication

Get

Return mFormsAuthentication

End Get

Set(ByVal value As FormsAuthentication)

mFormsAuthentication = value

End Set

End Property


Can I resolve this? I tried using an assigned instance (objClassLibrary as
ClassLibrary), but reached a lot of errors all over the application when I
do that so I stick with this method instead.

Thanks in advance.


Family Tree Mike

unread,
Nov 23, 2009, 12:03:01 PM11/23/09
to

"Nick Large" wrote:

> Hello.
>
> I have a class library with a class for authentication that uses forms
> authentication.
>
> The RedirectFromLoginPage class is called through my application using:
>
> ClassLibrary.Authentication.FormsAuthentication.RedirectFromLoginPage(UserID,
> False)
>
> and, although this method works as intended, it leaves a warning (green
> squiggly) which looks like I don't know what I'm talking about
> (unprofessional). Here is the declaration:
>

Is the warning on the line above? If so, what is the declaration of
RedirectFromLoginPage()? You would get the warning if you tried to call a
shared method on an instance variable.


> Public Shared mFormsAuthentication As New
> System.Web.Security.FormsAuthentication
>
> Public Shared Property FormsAuthentication() As
> System.Web.Security.FormsAuthentication
>
> Get
>
> Return mFormsAuthentication
>
> End Get
>
> Set(ByVal value As FormsAuthentication)
>
> mFormsAuthentication = value
>
> End Set
>
> End Property
>

Those declarations don't seem to have any relationship to the question.


>
> Can I resolve this? I tried using an assigned instance (objClassLibrary as
> ClassLibrary), but reached a lot of errors all over the application when I
> do that so I stick with this method instead.

ClassLibrary "appears" to be a namespace in your application, not a class.
That is why you would get errors doing that.

>
> Thanks in advance.
>

Mike

Colbert Zhou [MSFT]

unread,
Nov 24, 2009, 2:14:38 AM11/24/09
to
Hello Nick,

The right MSDN managed newsgroup for ASP.NET issues is
public.dotnet.framework.aspnet. Would you mind reposting the questions
there. We will have ASP.NET dedicated engineer supports on this issue there.

Please let me know if there is anything else I can help! Have a nice day,
Sir!


Best regards,
Ji Zhou
Microsoft Online Community Support

Gregory A. Beamer (MVP)

unread,
Nov 26, 2009, 4:11:34 PM11/26/09
to
"Nick Large" <msne...@nospam.nospam> wrote in
news:uWi8sJF...@TK2MSFTNGP05.phx.gbl:

> I have a class library with a class for authentication that uses forms
> authentication.
>
> The RedirectFromLoginPage class is called through my application
> using:
>
> ClassLibrary.Authentication.FormsAuthentication.RedirectFromLoginPage(U
> serID, False)
>
> and, although this method works as intended, it leaves a warning
> (green squiggly) which looks like I don't know what I'm talking about
> (unprofessional). Here is the declaration:
>
> Public Shared mFormsAuthentication As New
> System.Web.Security.FormsAuthentication
>
> Public Shared Property FormsAuthentication() As
> System.Web.Security.FormsAuthentication


Why are you setting up FormsAuthentication as Shared in your application?
The methods are already Shared in nature, so you are not saving anything
here, but you are likely setting yourself up for other problems.

You can access FormsAuthentication at any point in time without wrapping it
in a class as a Shared member.

Peace and Grace,

--
Gregory A. Beamer
Microsoft MVP (Visual C# Architecture)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

**********************************************
| Think outside the box! |
**********************************************

0 new messages