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

  • Home
  • SEARCH
  • 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 4606790
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:36:51+00:00 2026-05-22T00:36:51+00:00

This compiles: public interface IMyInterface { event Action<dynamic> OnSomeEvent; } class MyInterface : IMyInterface

  • 0

This compiles:

public interface IMyInterface
{
    event Action<dynamic> OnSomeEvent;
}

class MyInterface : IMyInterface
{
    public event Action<dynamic> OnSomeEvent;
}

But when i separate the interface and the implementation to different projects, i get:

Accessor
‘TestProject2.MyInterface.OnSomeEvent.remove’
cannot implement interface member
‘InterfaceNamespace.IMyInterface.remove_OnSomeEvent(System.Action)’
for type ‘TestProject2.MyInterface’.
Use an explicit interface
implementation.

This occurs only with a dynamic parameter…

  • 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-22T00:36:51+00:00Added an answer on May 22, 2026 at 12:36 am

    Good catch. This looks like it’s possibly a bug in the C# compiler – I’ll ping Eric Lippert to see what he thinks. (dynamic can be a bit tricksy; there may well be a perfectly good but non-obvious reason for this error.)

    EDIT: The code below appears not to work after all. I could have sworn I had it working this morning… I’m very confused as to what’s going on. As per Simon’s comments, the code fails with a message saying it’s not supported by the language.

    Note that if you do use explicit interface implementation, it appears to compile just fine:

    // Doesn't actually compile - see edit above
    class MyInterface : IMyInterface
    {
        private Action<dynamic> foo;
    
        event Action<dynamic> IMyInterface.OnSomeEvent
        {
            // TODO (potentially): thread safety
            add { foo += value; }
            remove { foo -= value; }
        }
    }
    

    EDIT: The rest of this answer still stands…

    Note that you can’t specify a field-like event as an explicitly-implemented event, i.e. this doesn’t work:

    event Action<dynamic> IMyInterface.OnSomeEvent;
    

    It gives the following error message:

    Test.cs(15,39): error CS0071: An explicit interface implementation of an event must use event accessor syntax

    And if you just try to change to the event accessor syntax, you get the same error as the
    original code.

    Note that changing the event to a property works fine with an auto-implemented property implementation.

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

Sidebar

Related Questions

This compiles: class Ex1 { public int show() { try { int a=10/10; return
This confuses me. The following compiles fine under Eclipse. package com.example.gotchas; public class GenericHelper1
Why does this conversion not work? public interface IMyInterface { } public interface IMyInterface2
Let's supposed i have this interface: public interface MyInterface { void doStuff(); } With
This causes a compile-time exception: public sealed class ValidatesAttribute<T> : Attribute { } [Validates<string>]
Why doesn't this code compile? public boolean isOf(Class clazz, Object obj){ if(obj instanceof clazz){
Why doesn't this class compile? import java.util.*; public class Caesar { public static void
When I try to compile this: import java.awt.* ; class obj { public static
How come this code doesnt compile? class A { class B { public enum
I have a number of class, all with exactly the same interface. This interface

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.