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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:40:51+00:00 2026-05-11T22:40:51+00:00

For example, I get this compiler warning, The event ‘Company.SomeControl.SearchClick’ is never used. But

  • 0

For example, I get this compiler warning,

The event ‘Company.SomeControl.SearchClick’ is never used.

But I know that it’s used because commenting it out throws me like 20 new warnings of XAML pages that are trying to use this event!

What gives? Is there a trick to get rid of this warning?

  • 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-05-11T22:40:51+00:00Added an answer on May 11, 2026 at 10:40 pm

    This appears to be warning 67 and can thus be suppressed with:

    #pragma warning disable 67
    

    Don’t forget to restore it as soon as possible (after the event declaration) with:

    #pragma warning restore 67
    

    However, I’d check again and make sure you’re raising the event somewhere, not just subscribing to it. The fact that the compiler spits out 20 warnings and not 20 errors when you comment out the event is also suspicious…

    There’s also an interesting article about this warning and specifically how it applies to interfaces; there’s a good suggestion on how to deal with “unused” events. The important parts are:

    The right answer is to be explicit about what you expect from the event, which in this case, is nothing:

    public event EventHandler Unimportant
    {
        add { }
        remove { }
    }
    

    This will cleanly suppress the warning, as well as the extra compiler-generated implementation of a normal event. And as another added benefit, it prompts one to think about whether this do-nothing implementation is really the best implementation. For instance, if the event isn’t so much unimportant as it is unsupported, such that clients that do rely on the functionality are likely to fail without it, it might be better to explicitly indicate the lack of support and fail fast by throwing an exception:

    public event EventHandler Unsupported
    {
        add { throw new NotSupportedException(); }
        remove { }
    }
    

    Of course, an interface that can be usefully implemented without some parts of its functionality is sometimes an indication that the interface is not optimally cohesive and should be split into separate interfaces.

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

Sidebar

Related Questions

I am following the quickstart guide for boost::spirit, and I get this compiler warning
I'm having troubles setting the background color for JButtons. For example I get this
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
I cannot for the life of me get this. Example of fails, the last
I am following this example to get JSONP data from remote server. jQuery append
I can't get past this issue I am having. Here's a simple example: class
hello i am make like this example which i get from www.xxxxxx.com http://s1172.photobucket.com/albums/r568/novikoraharja/?action=view&current=justanimage.png i
I have this simple example I can't seems to get working : MERGE INTO
example: at this domain http://www.example.com/234234/go.html is only one iframe-code how can i get the
Is this good approach to get data from stored procedure? For example procedure is

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.