2005 Conversion Warning

A

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
 
J

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
 
A

AZNewsh

Thank you for taking the time to answer.


Jim said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top