0

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();
        }
    }
}
  • Just to check, have you been through all of the steps described in this answer? http://stackoverflow.com/a/1171227/1073107 It seems so, but... – dash Jun 19 '13 at 21:06
  • Seems the problem was I was using the 64-bit verson of RegAsm instead of the 32-bit version. (I feel rather silly now.) – user2502829 Jun 19 '13 at 21:18
  • Don't! Consider adding this as the answer along with the difference between using the two, and accept it. It may help someone else in future! – dash Jun 19 '13 at 21:50

0 Answers0