---
title: "Method_Missing: Cool Uses"
url: "https://osherove.com/blog/2009/3/1/method_missing-cool-uses.md"
canonical: "https://osherove.com/blog/2009/3/1/method_missing-cool-uses.html"
published: "2009-03-01T10:26:01"
updated: "2009-03-01T10:26:01"
tags: [".NET"]
author: "Roy Osherove"
description: "I wrote the other day that I’ve added that ability to use a Method_Missing method in VB. I was also able to get something similar in C# 4 using dynamic types but people keep asking me “why is it useful?” I thought long…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Method\_Missing: Cool Uses

By Roy Osherove March 1, 2009 In [.NET](https://osherove.com/blog/category/net)

**Historical article** · Originally published March 1, 2009; technical details may be outdated.

I wrote the other day that [I’ve added that ability](http://weblogs.asp.net/rosherove/archive/2009/02/25/adding-method-missing-support-to-vb-net-using-ctru-and-typemock-open-aop.aspx) to use a Method\_Missing method in VB. I was also able to get something similar in C# 4 using dynamic types but people keep asking me “why is it useful?”

I thought long and hard and the first answer I came up with was “cause it sounds like a cool idea”.

Then I started looking up potential uses for this.This feature is used all over the place in [ruby](http://rubylearning.com/satishtalim/ruby_method_missing.html) on rails and such, to have "smart" methods that know what you need without you needing to define it beforehand.
good examples here:
[http://szeryf.wordpress.com/2008/06/05/eliminating-code-duplication-with-metaprogramming/](http://szeryf.wordpress.com/2008/06/05/eliminating-code-duplication-with-metaprogramming/)
[http://szeryf.wordpress.com/2007/07/15/extending-rails-magic-%EF%AC%81nders/](http://szeryf.wordpress.com/2007/07/15/extending-rails-magic-%EF%AC%81nders/)
[http://redhanded.hobix.com/inspect/theBestOfMethod\_missing.html](http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)

Today at work I thought of another cool use for such a thing: a proxy to private method invocations

When working with a type who has non public methods that you with to invoke, you can easily create a “wrapper” class that you can call those methods directly on, which, when Method\_Missing gets called, will be redirected as reflection invocation calls against that object.

Assuming you has method\_missing support in VB and in C# out of the box – what would you use it for?

## More in .NET

[All posts in .NET](https://osherove.com/blog/category/net)

- Mar 16, 2009

    ### [Creativity Cards in software](https://osherove.com/blog/2009/3/16/creativity-cards-in-software.html)

- Mar 16, 2009

    ### [Code Formatter plugin for live writer - updated](https://osherove.com/blog/2009/3/16/code-formatter-plugin-for-live-writer-updated.html)

- Feb 25, 2009

    ### [Adding Method-Missing support to VB.NET using CTru and Typemock Open-AOP](https://osherove.com/blog/2009/2/25/adding-method-missing-support-to-vbnet-using-ctru-and-typemo.html)

- Dec 31, 2008

    ### [The morning brew](https://osherove.com/blog/2008/12/31/the-morning-brew.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
