peichun tsai

peichun tsai

  • NA
  • 1
  • 2.7k

excel use c# dll problem

Apr 18 2011 10:58 PM

hi,

I write a dll and register it by following command,
and excel use the dll by add it as a reference .

%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\regasm.exe regasmxp.dll /tlb:regasmxp.tlb /codebase

It works fine in the develop machine but not in another machines.
The error message is [-2147024894 - File or assembly name regasmxp, or one of its dependencies, was not found.]

What's wrong ?  Someone can help me?

//---------------c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace regasmxp
{
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    [Guid("01A31113-9353-44cc-A1F4-C6F1210E4532")]  //Allocate your own GUID
    [ComVisible(true)]
    public interface _Test
    {
        int addnum(int a, int b);
    }

    [ClassInterface(ClassInterfaceType.None)]
    [Guid("E2F07CD4-CE73-4102-B35D-119362624542")]  //Allocate your own GUID
    [ProgId("regasmxp.Class1")]
    [ComVisible(true)]
    public class Class1 : _Test
    {
        public Class1()
        {

        }
        public int addnum(int a, int b)
        {
            return a + b;
        }
    }
}
//------------vba

Dim a as regasmxp.Class1
set a  = New regasmxp.Class1
MsgBox a.addnum(4 , 5)


Answers (1)