I have a Public Class "General" in which is a Public Sub "updateDynamics". When I attempt to reference it in the code-behind for a page like so:
updateDynamics(get_prospect.dynamicsID)
I get the following error:
reference to a non-shared member requires an object reference
You have referenced a non-shared member within your code and failed to supply an object reference. You cannot use the class name itself to qualify a member that is not shared. The instance must first be declared as an object variable and then referenced by the variable name.
The message "object reference not set to an instance of an object" means that you are referring to an object the does not exist or was deleted or cleaned up. It's usually better to avoid a NullReferenceException than to handle it after it occurs.
You either have to make the method Shared
or use an instance of the class General
:
Dim gen = New General() gen.updateDynamics(get_prospect.dynamicsID)
or
General.updateDynamics(get_prospect.dynamicsID) Public Shared Sub updateDynamics(dynID As Int32) ' ... ' End Sub
Shared(VB.NET)
Go to the Declaration of the desired object and mark it Shared.
Friend Shared WithEvents MyGridCustomer As Janus.Windows.GridEX.GridEX
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With