C#DLL出类拔萃 - 不能引用到指定的文件中添加 - regasm [英] c# excel dll - can't add a reference to the specified file - regasm

查看:1169
本文介绍了C#DLL出类拔萃 - 不能引用到指定的文件中添加 - regasm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在部署和另一台计算机上注册一个 Excel.dll ,我得到一个错误无法引用添加到指定的文件当试图添加引用 DLL VBA 编辑。



我在 C#创建 Excel.dll 的Visual Studio 运行罚款我的机器上使用 Windows 7的的Office 2010 。没问题添加引用的DLL中的我的电脑上的Excel VBA 编辑。我的问题是其部署在运行 Vista的 Excel 2007中另一台机器上。我复制DLL到此计算机并使用 regasm 注册DLL。



任何人都可以点我在正确的方向?这里是代码和regasm:




C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm。 exe文件excelDll.dll




 使用系统; 
使用System.Collections.Generic;
使用System.Linq的;
使用System.Text;使用System.Windows.Forms的
;使用System.Runtime.InteropServices
;

命名空间TestDll
{
[ClassInterface(ClassInterfaceType.AutoDual)
公共类测试
{
公共字符串的HelloWorld
{
获得
{
返回的Hello World;
}
}

公共无效sayGoodbye1()
{
MessageBox.Show(说再见);

}

公共字符串sayGoodbye2()
{
返回说再见;
}
}
}


解决方案

您需要注册为Excel看到引用您的DLL类型库。



regasm.exe excelDll.dll /tlb:excelDll.tlb



标记。


When deploying and registering a .Net Excel.dll on another computer, I get an error Can't add a reference to the specified file when attempting to add reference to DLL in VBA editor.

I have created the Excel.dll in C# in Visual Studio that runs fine on my machine with Windows 7 and Office 2010. No problem adding reference to the dll in Excel VBA editor on my computer. My problem is deploying on another machine which is running Vista and Excel 2007. I copied dll to this computer and used regasm to register the dll.

Can anyone point me in the right direction? Here is code and regasm:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm.exe excelDll.dll

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace TestDll
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Test
{
    public string HelloWorld
    {
        get
        {
            return "Hello World";
        }
    }

    public void sayGoodbye1()
    {
        MessageBox.Show("Say Goodbye");

    }

    public string sayGoodbye2()
    {
        return "Say Goodbye";
    } 
  }
}

解决方案

You need to register the type library for excel to see your dll in References.

i.e. regasm.exe excelDll.dll /tlb:excelDll.tlb

Mark.

这篇关于C#DLL出类拔萃 - 不能引用到指定的文件中添加 - regasm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆