views:

209

answers:

2

How to use System.Dynamic.DynamicObject in VB.NET 10.0 ?

I can create class that inherits from DynamicObject, but cannot actually use it.

A: 

See this page

Subclasses can override the various binder methods (GetMember, SetMember, Call, etc.) to provide custom behavior that will be invoked at runtime. If a method is not overridden then the DynamicObject does not directly support that behavior and the call site will determine how the binding should be performed.

Dario
Of course I read this. My point is, I cannot syntactically access dynamic properties and methods the same way I can do in C#. VB.NET just doesn't compile.
Prankster
+1  A: 

With VB, you have to turn Option Strict OFF on the class file that you want to consume the DynamicObject implementation. Doing this does mean that you lose the type safety that comes with Option Strict On. In addition, Dynamic opens you up to no longer relying on the compiler to check your method names for you.

I'm writing a series on creating a Dynamic CSV Enumerable type in VB at http://www.thinqlinq.com/Post.aspx/Title/LINQ-to-CSV-using-DynamicObject and can assure you that it does work in VB.

Jim Wooley

Jim Wooley