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 8262631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:49:03+00:00 2026-06-08T03:49:03+00:00

I have created a DLL using the following code. I have compiled this code

  • 0

I have created a DLL using the following code. I have compiled this code as a DLL.

namespace DllEventTrigger
{
    public class Trigger
    {
        public delegate void AlertEventHandler(Object sender, AlertEventArgs e);

        public Trigger()
        {

        }

        public void isRinging()
        {
            AlertEventArgs alertEventArgs = new AlertEventArgs();
            alertEventArgs.uuiData = "Hello Damn World!!!";
            CallAlert(new object(), alertEventArgs);
        }
        public event AlertEventHandler CallAlert; 
    }

    public class AlertEventArgs : EventArgs
    {
        #region AlertEventArgs Properties
        private string _uui = null;
        #endregion

        #region Get/Set Properties
        public string uuiData
        {
            get { return _uui; }
            set { _uui = value; }
        }
        #endregion
    }
}

Now I’m trying to handle the event triggered by this dll in a forms application with this code.

namespace DLLTriggerReciever
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Trigger trigger = new Trigger();
            trigger.isRinging();
            trigger.CallAlert += new Trigger.AlertEventHandler(trigger_CallAlert);
        }

        void trigger_CallAlert(object sender, AlertEventArgs e)
        {
            label1.Text = e.uuiData;
        }
    }
}

My problem i’m not sure where i went wrong. Please suggest.

  • 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-08T03:49:05+00:00Added an answer on June 8, 2026 at 3:49 am

    You need to assign your event handler before the event is actually fired, otherwise the code will throw a NullReferenceException.

    trigger.CallAlert += new Trigger.AlertEventHandler(trigger_CallAlert);
    trigger.isRinging();
    

    Additionally, it’s a recommended practice to check first, whether there are handlers assigned:

    var handler = CallAlert; // local variable prevents a race condition to occur
    
    if (handler != null) 
    {
      handler(this, alertEventArgs);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .NET assembly DLL that is created on-the-fly from pre-compiled code in
I have the following table created using Entity Framework Code First approach. How do
I have created an ActiveX dll using VB6 and packaged it using the Package
I am using IIS 6 on 2003. I have created a HTTP handler dll
I have a DLL written in C#. In this DLL there is a class
I have created a C++/CLI mixed DLL which I am using from C# Winforms
I need to use a DLL created using .NET framework. This DLL is made
I have following code to insert data into GiftCouponPayment table and Payment table. This
I have created several DLL (.NET) libraries that are used in several projects. In
Just created a .dll file that has some methods. And I have a another

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.