Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Excel VBA中的C#Dll调用方法_C#_Vba_Excel_Dll - Fatal编程技术网

从Excel VBA中的C#Dll调用方法

从Excel VBA中的C#Dll调用方法,c#,vba,excel,dll,C#,Vba,Excel,Dll,我试图在VBA中使用我创建的C#dll中的一个方法。该文件是COM可见的,并在我的VBA文件中引用 以下是我的VBA代码: Private Declare Function COMPaste Lib "C:\Blah\bin\x86\Debug\TestCOMExposure.dll" Alias "Countdown" (ByVal left As Integer) As Integer Sub TestA() Dim instance As TestCOMExposure.TestProgr

我试图在VBA中使用我创建的C#dll中的一个方法。该文件是COM可见的,并在我的VBA文件中引用

以下是我的VBA代码:

Private Declare Function COMPaste Lib "C:\Blah\bin\x86\Debug\TestCOMExposure.dll" Alias "Countdown" (ByVal left As Integer) As Integer
Sub TestA()
Dim instance As TestCOMExposure.TestProgram
Set instance = New TestCOMExposure.TestProgram
MsgBox (instance.COMPaste)

End Sub
要在C#dll中查看我的方法,请执行以下操作:

和我的接口代码:

[System.Runtime.InteropServices.ComVisible(true)]
[Guid("20DF3D06-0DC6-445D-9149-F23A34B0624F")]
public interface ITestProgram
{
    void Countdown();
}

当我运行VBA代码时,我得到的错误是“自动错误系统找不到指定的文件。请告诉我我做错了什么。

你是否仔细检查了DLL的路径?是的,我有。我只是写了“废话”来缩短它“看在帖子的份上。你仔细检查了DLL的路径了吗?是的,我查过了。为了这篇文章,我只写了一句“废话”。
[System.Runtime.InteropServices.ComVisible(true)]
[Guid("20DF3D06-0DC6-445D-9149-F23A34B0624F")]
public interface ITestProgram
{
    void Countdown();
}