title: one or more types required to compile a dynamic expression c#
body: <p>I have already looked at: <a href="https://stackoverflow.com/questions/11725514/one-or-more-types-required-to-compile-a-dynamic-expression-cannot-be-found-are">One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll?</a> but after trying the top solution as well as other solutions I've researched I am still unable to resolve this error. My VS is targeting .NET 4.5.1. In addition, the reference to CSharp is added as well. Why am I still getting this error?</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Runtime.InteropServices;
  using System.Net;
  using Important.CoreInterfaces;
  using Adaptive.SimpleBinaryEncoding;
  
  private static T method&lt;T&gt;(byte[] pinned_memory, ref int offset)
              {
                  //dynamic var = typeof(T);
                  dynamic temp = 1;
                  DirectBuffer tempd = new DirectBuffer(pinned_memory);
                  char messageType = (char)pinned_memory[offset];
                  switch(messageType)
                  {
                      case 'H':
                          doStuff();
                          break;
                      case 'D':
                          doOtherStuff();
                          break;
                      case 'A':
                          stuff();
                          break;
                      case 'M':
                          break;
                      case 'P':
                          break;
                      case 'F':
                          break;
                      case 'K':
                          break;
                      case 'O':
                          break;
                      case 'C':
                          break;
                      case 'X':
                          break;
                      default:
                          break;
                  }
  
                  MessageHeaderEncoder header = new MessageHeaderEncoder();
                  header.Wrap(tempd, offset, 1);
                  temp.WrapForDecode(tempd, offset, temp.sbeBlockLength(), temp.sbeSchemaVersion()); 
              }
  </code></pre>