PC Review


Reply
Thread Tools Rate Thread

'Access of shared member' warning on RedirectFromLoginPage

 
 
Nick Large
Guest
Posts: n/a
 
      23rd Nov 2009
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.


 
Reply With Quote
 
 
 
 
Family Tree Mike
Guest
Posts: n/a
 
      23rd Nov 2009


"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
 
Reply With Quote
 
Colbert Zhou [MSFT]
Guest
Posts: n/a
 
      24th Nov 2009
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

 
Reply With Quote
 
Gregory A. Beamer (MVP)
Guest
Posts: n/a
 
      26th Nov 2009
"Nick Large" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> 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! |
**********************************************
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RedirectFromLoginPage warning message Nick Large Microsoft ASP .NET 6 4th Dec 2009 08:36 PM
Access of shared member, constant member, etc. warning William O''Connor Microsoft VB .NET 4 18th Feb 2009 05:26 PM
Access of Shared member... mr t Microsoft VB .NET 1 17th Nov 2007 01:52 AM
Compile warning Access of shared member will not be evaluated Rick Microsoft ASP .NET 1 26th Jun 2007 09:16 PM
Access of shared member, constant member, enum member or nested type through an instance Jeffrey Grantz Microsoft VB .NET 3 7th Sep 2006 04:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:33 PM.