Groups | Blog | Home
all groups > dotnet general > april 2007 >

dotnet general : Can't clear Warnings



EdB
4/7/2007 3:10:03 PM
I guess my thing is that if you let the warnings sit then what's the point of
having them, so I like to clear them and I have a couple that I can't seem to.

1) Access of shared member, constant member, enum member or nested type
through an instance; qualifying expression will not be evaluated.

Here's the code:

MyContextMenu.Show(MyListView,
MyListView.PointToClient(MyListView.MousePosition()))

I get the warning on MyListView.MousePosition(). MousePosition is a Point,
and a Point is what the param of PointToClient is looking for.

2) Late bound resolution; runtime errors could occur.

Dim i As Int32 = CType(MyListBox.SelectedItem.ID, Int32)

I get the warning on MyListBox.SelectedItem.ID even though I am explicity
casting it.

How do I clear these? (BTW, I know I can just turn it off, but there must
be a way to resolve these, musn't there?)

Ed


AMercer
4/7/2007 3:36:01 PM
MyListView.MousePosition uses an object instance (MyListView) to refer to a
shared member (MousePosition). It suffices to use syntax like
Control.MousePosition. VB.NET used to be forgiving about this, the latest
version treats it as a warning.

[quoted text, click to view]
AddThis Social Bookmark Button