I am attempting to develop a .NET-based COM component for use in Excel applications. Using Visual Studio 2012 Express, I created a class library project, selected the "assembly COM-visible" and "register for COM interop" options, built the project, referenced the exported type library from an Excel workbook, and tested it sucessfully.
The question is: How do I deploy the DLL on other machines? I have tried compiling the library using csc, registering it with RegAsm /tlb -- both with and without the /codebase option -- and adding the output to the Global Assembly Cache. But the result is that there is no entry in the References dialog of the VBA editor. I can browse to the type library and set a reference to it, but attempting to create an object causes an error ("Can't create ActiveX object").
So what is Visual Studio doing that I am not? Any insights will be welcome.
My code:
using System;
using System.Reflection;
using System.Runtime.InteropServices;
[assembly : AssemblyTitle("Com Test 3")]
[assembly : AssemblyVersion("1.0.0.0")]
[assembly : Guid("F2715EE7-099F-464A-994A-390D34FAE6BA")]
[assembly : ComVisible(true)]
namespace ComTest3
{
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("C416AB08-4DE4-4E73-BDC4-B49B4CEE4901")]
public interface ITestClass3
{
string TestMethod3();
}
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("6383217C-1871-4AAA-BFA1-0CC077250DB3")]
public class ComTestClass3 : ITestClass3
{
public string TestMethod3()
{
return "TestMethod3 called on " + DateTime.Now.ToString();
}
}
}