G
Guest
I'm raising an event from a C# component and trying to catch it in a VB.NET Windows application. The VB app recognizes my custom EventArgs object and catches the event. However, when I try to read any of the properties they are null or nothing. The EventArgs object itself is alive and well.
Here's some code:
C# Event
// HANDFOUND EVENT CODE
public event HandFoundEventHandler HandFound;
public delegate void HandFoundEventHandler(object sender,
HandFoundEventArgs e);
public class HandFoundEventArgs : EventArgs
{
// Properties.
public string TableTitle;
public string HandContents;
// Constructor.
public HandFoundEventArgs(string TableTitle, string HandContents)
{
TableTitle = TableTitle;
HandContents = HandContents;
}
}
....function in another class
.... code snipped...time to raise event
HandFoundEventArgs e = new HandFoundEventArgs(tableTitle, handContents);
OnHandFound(e);
finally, here's "OnHandFound"
protected virtual void OnHandFound(HandFoundEventArgs e)
{
if (HandFound != null)
{
HandFound(this, e);
}
}
'-------------------------------------------------------------------------------------------
All this seems to work fine. The following VB.NET code handles the event.
' EVENT HANDLER for the HAND FINDER OBJECT
Private Shared Sub myHandFinder_HandFound(ByVal Sender As Object, ByVal e As HandFoundEventArgs) Handles myHandFinder.HandFound
System.Diagnostics.Debug.Assert(Not e.TableTitle Is Nothing, "Nothing.")
System.Diagnostics.Debug.Assert(Not e.HandContents Is Nothing, "Nothing")
Dim tableNumber As String = ParseTableNumber(e.TableTitle)
'-------------------------------------------------------------------------------
Both Assert return false and first line throws a Null Object Exception.
Thanks for you help,
D
Here's some code:
C# Event
// HANDFOUND EVENT CODE
public event HandFoundEventHandler HandFound;
public delegate void HandFoundEventHandler(object sender,
HandFoundEventArgs e);
public class HandFoundEventArgs : EventArgs
{
// Properties.
public string TableTitle;
public string HandContents;
// Constructor.
public HandFoundEventArgs(string TableTitle, string HandContents)
{
TableTitle = TableTitle;
HandContents = HandContents;
}
}
....function in another class
.... code snipped...time to raise event
HandFoundEventArgs e = new HandFoundEventArgs(tableTitle, handContents);
OnHandFound(e);
finally, here's "OnHandFound"
protected virtual void OnHandFound(HandFoundEventArgs e)
{
if (HandFound != null)
{
HandFound(this, e);
}
}
'-------------------------------------------------------------------------------------------
All this seems to work fine. The following VB.NET code handles the event.
' EVENT HANDLER for the HAND FINDER OBJECT
Private Shared Sub myHandFinder_HandFound(ByVal Sender As Object, ByVal e As HandFoundEventArgs) Handles myHandFinder.HandFound
System.Diagnostics.Debug.Assert(Not e.TableTitle Is Nothing, "Nothing.")
System.Diagnostics.Debug.Assert(Not e.HandContents Is Nothing, "Nothing")
Dim tableNumber As String = ParseTableNumber(e.TableTitle)
'-------------------------------------------------------------------------------
Both Assert return false and first line throws a Null Object Exception.
Thanks for you help,
D