473,508 Members | 2,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ISynchronizeInvoke - Object reference not set to an instance

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
4 4010
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
20272
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
9
2210
by: GM | last post by:
Hi, My application has a need to cache a number of shared reference lists containing basic business objects. In order to improve performance these lists are fetched and updated in the...
0
1402
by: Jedrzej Miadowicz | last post by:
I have a problem when using ISynchronizeInvoke.BeginInvoke with polymorphic parameters. It seems that if I try to call BeginInvoke and in the array of parameters place an object that's derived from...
1
4991
by: Tim Murray | last post by:
Hi, I am creating a multithreaded server application in Managed C++. Each client that connects to the server will be running on their own thread to process their input. They all need to share...
0
2481
by: Wavemaker | last post by:
One of the things I've struggled with from time to time is handling events raised on different threads. For example, an object could be listening to events from one or more objects running in...
1
3070
by: Thai Mai Shu | last post by:
What is wrong with my call below. If I change the delegate and the CallBackComplete function to not take in parameters then the .Invoke call works fine. As soon as I put the parameters back I...
12
5505
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
6
2467
by: Shailen Sukul | last post by:
Observed a weird behaviour with object references. See code listing below: using System; using System.Collections.Generic; using System.Text; namespace PointerExceptionTest { /*
2
2621
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.