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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:19:16+00:00 2026-06-16T01:19:16+00:00

After reading this post and links I still have 2 questions Question #1 What

  • 0

After reading this post and links I still have 2 questions

Question #1

What is the criteria so that I would be able to execute dynamic code in c# ? must the target classes/objects rely on .net clr ? I mean if someone gives me a Pascal DLL , I guess I won’t be able to use its code via dynamic ( or will ? )..so: What are the requirements for dynamic to work ?

Question #2

For example : In script object – in order to increase an int the code should be :

 Scriptobj.SetProperty("Count", ((int)GetProperty("Count")) + 1);

With dynamic I can do :

scriptobj.Count += 1;

Does it mean that the scriptobj’s class programmers wrote a supportive code which enables DLR to do =+1 ?

ScriptobjClass : DynamicObject
{
  ...
  public override bool TryInvokeMember (...when +=1 so do a+1....)...
}

Im missing something essential here.

Is it like : "we’re building a class but we should also let .net DLR access it – so let’s write more code so that this class also support operations which will allow .net users to access this class via dlr" ?

  • 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-16T01:19:18+00:00Added an answer on June 16, 2026 at 1:19 am

    Lets start by explaining what the DLR allows you to do, first:

    There are two facets to the DLR the first is that it allows dynamic binding of objects at run time.
    For example:

    class A
    {
        public int SomeProperty { get; set; }
    }
    
    class B
    {
        public int SomeMethod(int value)
        {
            return value;
        }
    }
    
    
    dynamic d = new A();
    d.Value = 1;
    
    d = new B();
    d.SomeMethod(2);
    

    The dynamic d can be assigned objects of any type and call their methods and properties. A more striking example:

    int CallSomeMethod(dynamic d)
    {
        return d.SomeMethod();
    }
    

    This works with any class that has a method “SomeMethod” returning an int. The strong typed way to do this would be create an interface with “SomeMethod”:

    int CallSomeMethod(IClassWithSomeMethod d)
    {
        return d.SomeMethod();
    }
    

    Note that this is not something which could not be done before with reflection, but the DLR and the dynamic keyword makes this much simpler. The DLR also creates and caches expression trees for the calls so using the DLR is almost always more efficient than reflection.

    The real strength of the DLR however is not just run time binding, it actually allows you to create objects that behave dynamically. Basically it lets you to specify what happens when you call a method or property that does not exist in the actual runtime object bound to the dynamic variable. This allows the CLR to be used for dynamic languages and to provide easy interoper with dynamic langues , create easy to use parsers which can represent a DOM as a dynamic object or ORM’s that can represent ad-hoc queries as objects, etc..

    More detailed information about the DLR can be found in its codeplex project documentation page. Especially worthwhile are the overview and the Sites, Binders, and Dynamic Object Interop Spec documents.

    Now to your questions:

    Question 1: No you can’t interact by magic with any dynamic language, there must be some supported interop (which may be facilitated by the DLR) to do so (I don’t know what you meant by Pascal dll.)

    Question 2: ScriptObjectClass uses the DLR facilities (by extending DynamicObject) to get and set the Count property dynamically as if it was an actual property of ScriptObjectClass (if you’re curious see Sites, Binders, and Dynamic Object Interop Spec for exactly how this is done.)

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

Sidebar

Related Questions

After reading this post i realized that i cannot pass an anonymous type as
After reading this post I was wondering what would be the best way to
After reading this post I kinda felt in the same position as the guy
After reading this post on Stackoverflow Google plus popup box when hovering over thumbnail?
After reading the Bash man pages and with respect to this post , I
After reading this question, I need to clear up some things. IQueryable<Customer> custs =
After reading this article I don't have a clear answer: http://palizine.plynt.com/issues/2010Oct/bypass-xss-filters/ Will browsers interpret
After reading this article on thedailywtf.com, I'm not sure that I really got the
After reading this: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-to-use-it I came to the conclusion that it is not valid
After reading this question , i saw the answer by Naveen containing a link

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.