Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8420079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:47:33+00:00 2026-06-10T02:47:33+00:00

I have one WinForms control project that produces a dll. There is a second

  • 0

I have one WinForms control project that produces a dll. There is a second dll project (also winforms control) that uses the first project. There is a third winforms project, this time a form, that uses the second project. So [Third Project] <>——> [Second Project] <>——–> [First Project]

The first project exposes a static event. I’m trying to subscribe to that event from the third project. The event stays as null (not subscriptions) after the += call.

Why is it not subscribing? Is it because the Winforms controls have their own thread? The FirstProject user control is created on the fly at some point in time. But I will expect the static to work correctly, without doing anything else,

Project 1

namespace Something
{
  public partial class FirstClass : UserControl
  {
    ...
    public delegate void EventHandler();
    public static event EventHandler MyEvent;
    ...
  }
}

Project 3

namespace Another
{
  public partial class ThirdClass : Form
  {
     ...
     public ThirdClass()
     {
       ....
       Something.FirstClass.MyEvent += new Something.FirstClass.EventHandler(MyHandler);
     }
     public void MyHandler()
     {
     }
     ...
   }
 }

EDIT
I have created a small application with the basics to get the three projects and the static event. And it works. Therefore something else is going on.

EDIT 2
The dll that contained the first project, the one with the event, was being loaded twice. I have just added an alias, but didn’t help. And still will not explain when just after the += the event is still null.

EDIT 3 I transformed the event so I have the add/remove accessors pair. It does enter into the add. The Handler method gets the value correctly (and therefore no null), but once it goes outside, is null again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:47:35+00:00Added an answer on June 10, 2026 at 2:47 am

    And the reason will be in my EDIT 2. Because is a static event, loading twice the dll (two different paths) was creating two different static events (or two different handlers). My EDIT 3 clearly showed that the event was being subscribed to.

    Once I forced the third project (the one subscribing to the static event) to load the dll from the same location as the project creating the event (I didn’t wanted to use the GAC), all worked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this WinForms project (based on this one , but modified for SharePoint
Short Version: I have a WinForms app that uses a .NET 4.0 WebBrowser control
I have a winforms datagridview that seems to always have at least one row
I have a WinForms utility that I use constantly, and enhance regularly. Roughly one
I have created a WinForms user control that is a set of five cascading
I have an application written in .net winforms. There is a form that shows
I have a class that handles events from a WinForms control. Based on what
I have a listbox control (in a WinForms application) that lists a bunch of
I have a winforms app. I give it to three clients and each one
have one time consuming step that flattens a bunch of files. basically i'd like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.