By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,579 Members | 1,618 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,579 IT Pros & Developers. It's quick & easy.

ISynchronizeInvoke - Object reference not set to an instance

P: n/a
I am getting an "Object reference not set to an instance of an object"
when I try to execute the Invoke method. I have it set up as follows:
---
Private _syncObject As System.ComponentModel.ISynchronizeInvoke
..
..
..
Dim args(0) As Object
Dim d As New RaiseReceiveEvent(AddressOf OnReceive)
..
..
args(0) = "Test Message"
..
..
_syncObject.Invoke (d, args)

---

Any help would be "GREATLY" appreciated.
Thanks-
Jennifer

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Jennifer,
You need to assign a value to your _syncObject variable. The value needs to
be of a type that supports ISynchronizeInvoke.

The only types that support ISynchronizeInvoke within the Framework inherit
from System.Windows.Forms.Control.

Normally I use the instance of my MainForm.

FWIW: You are free to implement ISynchronizeInvoke in your own classes,
however implementing ISynchronizeInvoke is a very advanced topic.

Hope this helps
Jay
"jherl" <je***********@aol-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
I am getting an "Object reference not set to an instance of an object"
when I try to execute the Invoke method. I have it set up as follows:
---
Private _syncObject As System.ComponentModel.ISynchronizeInvoke
.
.
.
Dim args(0) As Object
Dim d As New RaiseReceiveEvent(AddressOf OnReceive)
.
.
args(0) = "Test Message"
.
.
_syncObject.Invoke (d, args)

---

Any help would be "GREATLY" appreciated.
Thanks-
Jennifer

Nov 21 '05 #2

P: n/a
Do you mean something like:

x = _syncObject(d,args)

if so, how do I define x ? If not, I guess I don't quite understand.
Thanks for your help & PATIENCE -
Jennifer

Nov 21 '05 #3

P: n/a
Okay, forget that last post, I obviously don't know what I am doing.
Is this where the value is set:

<System.ComponentModel.Browsable(False)> _
Public Property SyncObject() As
System.ComponentModel.ISynchronizeInvoke
Get
If _syncObject Is Nothing And Me.DesignMode Then
Dim designer As IDesignerHost =
Me.GetService(GetType(IDesignerHost))
If Not (designer Is Nothing) Then
_syncObject = designer.RootComponent
End If
End If
Return _syncObject
End Get
Set(ByVal Value As System.ComponentModel.ISynchronizeInvoke)
If Not Me.DesignMode Then
If Not (_syncObject Is Nothing) And Not (_syncObject
Is Value) Then
Throw New Exception("Property can not be set at
run-time")
Else
_syncObject = Value
End If
End If
End Set
End Property

Thanks -
Jennifer

Nov 21 '05 #4

P: n/a
Jennifer,
Yes that is the code that sets _syncObject, Just remember that you need to
set the SyncObject property when you instantiate the class/component/control
that it is in.

Again you would set SyncObject (which sets _syncObject) to an instance of a
Control, normally I use my MainForm.

Hope this helps
Jay

"jherl" <je***********@aol-dot-com.no-spam.invalid> wrote in message
news:41********@Usenet.com...
Okay, forget that last post, I obviously don't know what I am doing.
Is this where the value is set:

<System.ComponentModel.Browsable(False)> _
Public Property SyncObject() As
System.ComponentModel.ISynchronizeInvoke
Get
If _syncObject Is Nothing And Me.DesignMode Then
Dim designer As IDesignerHost =
Me.GetService(GetType(IDesignerHost))
If Not (designer Is Nothing) Then
_syncObject = designer.RootComponent
End If
End If
Return _syncObject
End Get
Set(ByVal Value As System.ComponentModel.ISynchronizeInvoke)
If Not Me.DesignMode Then
If Not (_syncObject Is Nothing) And Not (_syncObject
Is Value) Then
Throw New Exception("Property can not be set at
run-time")
Else
_syncObject = Value
End If
End If
End Set
End Property

Thanks -
Jennifer

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.