Home All Groups Group Topic Archive Search About

2005 Conversion Warning

Author
24 Jul 2006 3:14 PM
AZNewsh
Access of shared member, constant member, enum member or nested type
through an instance; qualifying expression will not be evaluated.

Here is the line that apparently causes it:

DirectoryServices.AuthenticationTypes.SecureSocketsLayer.FastBind

I am managing to clear up most warnings but am unsure about this one,
all help appreciated.

Thanks

Author
24 Jul 2006 4:56 PM
Jim Wooley
Typically this is caused by trying to call a static/shared method from an
instance of a class rather than calling it directly. Consider the following:

Public Class Foo
   Public Shared Sub DoBar()
       Messagebox("Doing the bar")
   End Sub
End Class

Now if you want to call the DoBar method, you can simply use the following
syntax:
   Foo.DoBar()

In your case, you are trying to call the method through an instance of the
Foo class rather than the foo type as follows:
   Dim myFoo as New Foo
   myFoo.DoBar()

The compiler is telling you that it won't use the instance myFoo to call
DoBar as it is a Shared method. Instead, it will call Foo.DoBar directly.
It can get tricky to debug if you use an instance name that is the same as
the type of the object as follows:
   Dim Foo as New Foo
   Foo.DoBar()

Although the compiler allows this syntax, I try to avoid it (or in c# with
the case sensitive changes) as it makes for more challenging debugging and
maintenance. Here, you are trying to call DoBar through the instance rather
than the Type, but this might not be apparent on first glance.

One other case where you will see this message is where there are potential
namespace conflicts which cause an instance member to be used rather than
the base type.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx

Show quoteHide quote
> Access of shared member, constant member, enum member or nested type
> through an instance; qualifying expression will not be evaluated.
>
> Here is the line that apparently causes it:
>
> DirectoryServices.AuthenticationTypes.SecureSocketsLayer.FastBind
>
> I am managing to clear up most warnings but am unsure about this one,
> all help appreciated.
>
> Thanks
>
Author
2 Aug 2006 10:13 PM
AZNewsh
Thank you for taking the time to answer.


Jim Wooley wrote:
Show quoteHide quote
> Typically this is caused by trying to call a static/shared method from an
> instance of a class rather than calling it directly. Consider the following:
>
> Public Class Foo
>    Public Shared Sub DoBar()
>        Messagebox("Doing the bar")
>    End Sub
> End Class
>
> Now if you want to call the DoBar method, you can simply use the following
> syntax:
>    Foo.DoBar()
>
> In your case, you are trying to call the method through an instance of the
> Foo class rather than the foo type as follows:
>    Dim myFoo as New Foo
>    myFoo.DoBar()
>
> The compiler is telling you that it won't use the instance myFoo to call
> DoBar as it is a Shared method. Instead, it will call Foo.DoBar directly.
> It can get tricky to debug if you use an instance name that is the same as
> the type of the object as follows:
>    Dim Foo as New Foo
>    Foo.DoBar()
>
> Although the compiler allows this syntax, I try to avoid it (or in c# with
> the case sensitive changes) as it makes for more challenging debugging and
> maintenance. Here, you are trying to call DoBar through the instance rather
> than the Type, but this might not be apparent on first glance.
>
> One other case where you will see this message is where there are potential
> namespace conflicts which cause an instance member to be used rather than
> the base type.
>
> Jim Wooley
> http://devauthority.com/blogs/jwooley/default.aspx
>
> > Access of shared member, constant member, enum member or nested type
> > through an instance; qualifying expression will not be evaluated.
> >
> > Here is the line that apparently causes it:
> >
> > DirectoryServices.AuthenticationTypes.SecureSocketsLayer.FastBind
> >
> > I am managing to clear up most warnings but am unsure about this one,
> > all help appreciated.
> >
> > Thanks
> >