473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Events within a DLL doesn't fire

Hi guys,

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...?

Dev. Environment:
VS2005 SP1, Framework 2.0, C#

Any help will be greatly appreciated
aTTi
Oct 19 '08 #1
4 1242
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
Oct 19 '08 #2
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
Oct 19 '08 #3
Atilla Gökcegün <NO**********************@hotmail.comwrote:
what do you mean I haven't actually subscribed to the event..?
That was just a guess. Until we see full code, it's hard to know for
sure.
here is the code:
Please see http://www.pobox.com/~skeet/csharp/incomplete.html

--
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
Oct 20 '08 #4
I found the solution.

tnx

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
Atilla Gökcegün <NO**********************@hotmail.comwrote:
>what do you mean I haven't actually subscribed to the event..?

That was just a guess. Until we see full code, it's hard to know for
sure.
>here is the code:

Please see http://www.pobox.com/~skeet/csharp/incomplete.html

--
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
Oct 22 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: MLH | last post by:
If you have these lines in code on MyForm1... DoCmd OpenForm "MyForm2`" MsgBox "I opened MyForm2" Is it #ALWAYS# true that all form events on MyForm2 will occur before the MsgBox statement...
14
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
2
by: Philipp Sumi | last post by:
Hello newsgroup I'm using a library to discover UPnP devices on the network via sockets. Its use is pretty straightforward: private void Discover() DevDiscovery disco = new DevDiscovery ();...
3
by: Rick Strahl [MVP] | last post by:
I'm working on an app that's using the WebBrowser control. I got the control working fine, hooking to the document object. But I've run into a major issue with hooking the Document events....
4
by: blue | last post by:
I have a drop-down list, a radio button list and a submit button. I'm adding these controls to a table and I'm adding the table to a Placeholder. I'm adding it to the Placeholder because I don't...
0
by: ariesc | last post by:
I upgraded from .NET 2002 to .NET 2003 and found one weird things on the LEAVE / ENTER events within a datagrid. I added handler to each textbox of a datagrid, then handle the ENTER/LEAVE events....
6
by: Joseph Geretz | last post by:
Writing an Outlook AddIn with C#. For the user interface within Outlook I'm adding matching pairs of Toolbar buttons and Menu items. All of the buttons and menu items are wired up to send events to...
0
by: jonathan.beckett | last post by:
I have been working on a client project recently that is using winforms ..NET user controls within web pages in Internet Explorer, and need to find out how to make the user control communicate back...
8
by: MrNobody | last post by:
If I have a control like say a drop down list and I have some kind of onSelectItem change event, is there a way to temporarily suspend the event handling (without removing the event and then...
1
by: slikrik98 | last post by:
Greetings, I believe I have narrowed down my issues to one simple question, and I'm hoping someone with async events experience can help me out. My question is: how is using...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.