title: Excel 2010 VSE 2012 C# dll and tlb - Can't create reference to specified file
body: <p>I'm interested in finding how to call C# code from Excel, and have been following the method here <a href="https://richnewman.wordpress.com/2007/04/15/a-beginner%E2%80%99s-guide-to-calling-a-net-library-from-excel/" rel="nofollow">https://richnewman.wordpress.com/2007/04/15/a-beginner%E2%80%99s-guide-to-calling-a-net-library-from-excel/</a>. </p>
  
  <p>The C# code is a "Hello World" example, called DotNetClass.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Text;
  
  namespace DotNetLibrary
  {
      public class DotNetClass
      {
          public string DotNetMethod(string input)
          {
              return "Hello " + input;
          }
      }
  }
  </code></pre>
  
  <p>The build configuration has "Register for COM interop" and "Make assembly COM-visible" checked. I also have the options ".NET Framework 4.5" and "Any CPU" (I'm working on a 64bit machine). I have tried a few NET versions and CPU options without success. I have cleaned and rebuilt it several times.</p>
  
  <p>In Excel 2010 I cannot create a reference to DotNetLibrary.dll. I can browse to it, and I can even create a reference to a file in the same place - DotNetLibrary.tlb.</p>
  
  <p>The call from Excel is</p>
  
  <pre><code>Private Sub TestDotNetCall()
  Dim testClass As New DotNetClass
  MsgBox testClass.DotNetMethod(“World”)
  End Sub
  </code></pre>
  
  <p>... and this works - almost. If I run the VBA code (F5), I get a MsgBox (woot!) with the message "Hello " (no "World" - unwoot!). So, it seems to be ignoring the argument ("World"), which appears to defeat the purpose of doing this.</p>
  
  <p>I'd appreciate any explanations. Is it a good thing to reference the tlb file? Why can't I seem to pass the argument to, or get the result from the dll/tlb? Is there a better way to do this?</p>