我看了其他帖子,也找不到解决方案。
我正在尝试使用我在C#代码中创建的VBA,而不必添加引用。
在我的VBA代码中,我声明:
Public Declare Function message Lib "path_to_my_dll" _
(ByVal message As String) As String
Sub Test()
Dim hello As String
hello = message("hi!!")
Debug.Print hello
End Sub我得到一个错误,说我的dll的入口点找不到。
C#代码:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace DLLImport
{
public class Class1
{
[DllImport("DLLImport", EntryPoint = "Run")]
extern string Run(string message)
{
return message;
}
}
}提前感谢您的帮助!!
发布于 2019-02-08 05:13:49
您可能希望使用InteropServices使COM可见DLL
using System.Runtime.InteropServices;
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("your-GUID-1")]
public interface _Visible_Methods
{
//--------< _Visible_Methods >--------
//*visible COM Methods of this Control under Office,Excel, Word
string get_Hello();
//--------</ _Visible_Methods >--------
}来源:https://codedocu.com/Net-Framework/Controls/COM-ActiveX/Create-C_hash_-COM-Control-for-Office?2382
https://stackoverflow.com/questions/54582298
复制相似问题