title: DLLImport a variable MFC dll
body: <p>So I created the following test project:</p>
  
  <pre><code>[DllImportAttribute("TestMFCDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  internal static extern int test(int number);
  
  private void button1_Click(object sender, EventArgs e)
  {
      int x = test(5);
  }
  </code></pre>
  
  <p>Which works fine for my MFC dll that has the function test defined, however what I actually have is many MFC dlls that all share a common entry function and run differently based on my inputs.  So basically I have tons of dlls that I cannot know at compile time what the name is, I just know that they have a function similar to how this program is setup, is there a way to import a dll based on run-time knowledge?  Simply doing this returns an error:</p>
  
  <pre><code>static string myDLLName = "TestMFCDLL.dll";
  [DllImportAttribute(myDLLName, CallingConvention = CallingConvention.Cdecl)]
  </code></pre>
  
  <blockquote>
    <p>An attribute argument must be a constant expression, typeof expression
    or array creation expression of an attribute parameter type</p>
  </blockquote>