我想在 VBA 中使用 C# 回调函数。但是当我调用 C# 函数时,它显示“找不到入口点”
我该如何解决?谢谢
PS:我检查了 Make assembly COM-Visible and Register for COM inter Environment:MS Office Excel 2007, MS Visual Studio 2008
VBA代码:
Declare Function Result Lib"C:\Users\admin\Desktop\myprog\New_DLL_Test\New_DLL_Test\bin\Debug\New_DLL_Test.dll" Alias "Msg" (ByVal p As Long) As Integer
Function Disp()
MsgBox x
End Function
Sub AddResult(ByVal p As Long)
Dim x As Long
x = Result(p)
Debug.Print x
End Sub
Sub testnow_Click()
Call AddResult(AddressOf Disp)
End Sub
C#代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace New_DLL_Test
{
[Guid("f1286974-0f1a-466c-8389-dd1ab7e3eed2"), InterfaceType(ComInterfaceType.InterfaceIsDual)]
interface Msginterface
{
int Msg;
}
public unsafe class MsgProcess
{
public int Msg(int* p)
{
return add(p,1);
}
public int add(int* p, int j)
{
return j+1;
}
}
}