Windows Phone Developers

Sunday, April 27, 2008

Access of shared member through an instance; qualifying expression will not be evaluated

Access of shared member through an instance; qualifying expression will not be evaluated

This error occurs when an instance variable of a class or structure is used to access a Shared variable, property, procedure, or event defined in that class or structure. This warning can also occur if an instance variable is used to access an implicitly shared member of a class or structure, such as a constant or enumeration, or a nested class or structure.

· Use the name of the class or structure that defines the Shared member to access it.

· Ensure that two variables do not have the same name in a particular scope

The purpose of sharing a member is to create only a single copy of that member and make that single copy available to every instance of the class or structure in which it is declared. It is consistent with this purpose to access a Shared member through the name of its class or structure, rather than through a variable that holds an individual instance of that class or structure.

Accessing a Shared member through an instance variable can make your code more difficult to understand by obscuring the fact that the member is Shared. Furthermore, if such access is part of an expression that performs other actions, such as a Function procedure that returns an instance of the shared member, Visual Basic bypasses the expression and any other actions it would otherwise perform.

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

1 comment:

  1. I get this warning on the command
    myProc.Start(myPsi) in

    Public Sub StartApp( _
    ByVal aFilename As String, _
    ByVal aArguments As String, _
    ByVal aWorkingDirectory As String)
    Dim myProc As New Process
    Dim myPsi As New ProcessStartInfo
    myPsi.FileName = aFilename
    myPsi.Arguments = aArguments
    myPsi.WorkingDirectory = aWorkingDirectory
    End Sub

    How can I solve this?