I have written a project which has common functions in Visual Basic 2010 i.e. Visual Studio 2010. for e.g.

Public Function FlashPolygon(pDisplay As IScreenDisplay, pGeometry As IGeometry)
    Dim pFillSymbol As ISimpleFillSymbol
    Dim pSymbol As ISymbol
    Dim pRGBcolor As IRgbColor

    ' Set the Actions based on Error Mode
    If DEBUG_MODE = 0 Then On Error GoTo FlashPolygon_Error
    If DEBUG_MODE = 2 Then On Error Resume Next

    pFillSymbol = New SimpleFillSymbol
    pFillSymbol.Outline = Nothing

    pRGBcolor = New RgbColor
    pRGBcolor.Green = 128

    pSymbol = pFillSymbol
    pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen


    On Error GoTo 0
Exit Function

I want to access this function in a form in another project. I have already added reference to the commonfunctions project. But i am getting error Reference to a non-shared member requires an object reference.

Can someone help with what mistake I am doing in this code?


The error simply means that you have to create a new object of the type the function is in in order to call the function.

Dim myClass As New MyClass()
myClass.FlashPolygon(disp, geom)

or you can make the function shared.

Public Shared Function FlashPolygon(pDisplay As IScreenDisplay, pGeometry As IGeometry)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.