title: How to invoke an Expression(Of Func(Of T, TResult))?
body: <p>I'm trying to get the result of an <code>Expression(Of Func(Of T, TResult))</code>, but I'm not sure how Expressions work.</p>
  
  <p>Here's where I am with my experiments</p>
  
  <pre><code>&lt;Extension&gt;
  Public Function Test(Of T, TResult)(site As Object, expr As Expression(Of Func(Of T, TResult))) As Boolean
  
      Dim result As Object = Nothing
      result = Expression.Lambda(expr).Compile.DynamicInvoke
      result = result()
  
  End Function
  </code></pre>
  
  <p>Here's the code I'm using to set up the test.</p>
  
  <pre><code>Public Sub Main()
  
      Dim dummy As Object = New Object
      Dim result As Boolean = dummy.Test(Function(x As A) x.Bee.Tag)
  
  End Sub
  
  Public Class A
  
      Public Property Bee As B = Nothing
  
  End Class
  
  
  Public Class B
  
      Public Property Tag As Object = Nothing
  
  End Class
  </code></pre>
  
  <p>Note this code is simply for exploration and learning.  It is definitely in no way shape or form production-ready.</p>
  
  <p>The error is</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.MissingMemberException'
    occurred in Microsoft.VisualBasic.dll</p>
    
    <p>Additional information: No default member found for type 'Func(Of
    A,Object)'.</p>
  </blockquote>