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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:38:06+00:00 2026-06-11T13:38:06+00:00

Here is my code: public static class DynamicExtensions public static void Add(this ExpandoObject obj,

  • 0

Here is my code:

public static class DynamicExtensions

    public static void Add(this ExpandoObject obj, string path){
        dynamic _obj = obj;
        if (_obj == null) throw new ArgumentNullException("obj");
        _obj.path = path;
    }
}

But I got the error of “‘System.Dynamic.ExpandoObject’ does not contain a definition for ‘Add'”, when I call it in this way:

dynamic obj = new ExpandoObject();
obj.Add("p1");

How to fix it?

Thanks in advance!

  • 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-11T13:38:07+00:00Added an answer on June 11, 2026 at 1:38 pm

    The problem is using dynamic with extension methods – the two just don’t go together. This would be fine:

    ExpandoObject obj = new ExpandoObject();
    obj.Add("p1");
    

    … but with just dynamic, there’s no extension method support.

    From section 7.6.5.2 of the C# 5 spec:

    In a method invocation (§7.5.5.1) of one of the forms

    expr . identifier ( )
    expr . identifier ( args )
    expr . identifier < typeargs > ( )
    expr . identifier < typeargs > ( args )
    

    if the normal processing of the invocation finds no applicable methods, an attempt is made to process the construct as an extension method invocation. If expr or any of the args has compile-time type dynamic, extension methods will not apply.

    While the compiler could remember the using directives which it would have to check to apply extension methods, it just doesn’t – perhaps for performance reasons, or perhaps because it was just felt to be a lot of work for relatively little benefit.

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

Sidebar

Related Questions

Here is my code: public static class SerializationUtil { public static string Serialize(object obj)
Here is the code: class Time { public static void printTime (int hour, int
Here is my code : public static void main(String[] args) { // System.setProperty( //
Here's the code snippet: public static void main (String[]arg) { char ca = 'a'
Here is my sample code: public static class MySqlHelper { private static string constring
Here is my code: public class Test { static { main(null); } public static
Here's the code: class qual { public static int fibonacci(int n) { if (n
here is the code (java): class prime { public static boolean prime (int a,
Here is my code: import javax.swing.*; import java.awt.*; public class PanelModel { public static
here is the code public static final String DATE_TIME_FORMAT = yyyy-MM-dd kk:mm:ss; public static

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.