what do you mean I haven't actually subscribed to the event..?
here is the code:
users-class-library:
public Users(string _user, int _color)
{
this._userName = _user;
this._colorNumber = _color;
e = new UserInitializedEventArgs("User: " + _user + " registered
at " + DateTime.Now.ToString());
OnUserInitialized(e);
}
public static void OnUserInitialized(UserInitializedEventArgs e)
{
if (UserInitialized != null)
{
MessageBox.Show("OnUserInitialized(" + e.Message + ") fired
up..");
UserInitialized(this, e);
}
}
client-class:
public Form1()
{
InitializeComponent();
Application.ApplicationExit += new
EventHandler(OnApplicationExit);
Users.Users.UserInitialized += new
UserInitializedEventHandler(Users_UserInitialized) ;
}
void Users_UserInitialized(object sender, UserInitializedEventArgs
e)
{
_userObject = (Users.Users)sender;
_userCustomColor = _userObject.TextFont;
}
even I put the namespace (users) to the client-class I need to put it within
code to see the users-class-library.. can you explain me that behaviour?
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
Atilla Gökcegün <NO**********************@hotmail.comwrote:
>i've created a Client- and a Server-Forms-Class and a
Users-Class-Library.
The Class-Library (publisher) fires the event wich is handled within the
Client-Class (subscriber).. but the Client-Class gets never notified...
I've noticed that the following code:
if (UserInitialized != null)
{
UserInitialized(this, e);
}
returns null. that seems very strange to me because i've registered the
eventhandler within the Client-Class.
Is there a different workaround for implementing events within a
Class-Library...?
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
I suspect you haven't actually subscribed to the event that you think
you have.
--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com