[英]In VBA, C# dll says there is no entry point
I looked at other posts and couldn't find the solution. 我查看了其他帖子,但找不到解决方案。
I am trying to use C# dll I created in VBA code without having to add reference. 我试图使用在VBA代码中创建的C#dll,而不必添加引用。
In my VBA code, I declared: 在我的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
I get an error saying entry point for my dll couldn't be found. 我收到一条错误消息,指出找不到我的dll的入口点。
The C# Code: 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;
}
}
}
Thank you in advance for your help!! 预先感谢您的帮助!!
You might want to use InteropServices to make a COM Visible DLL 您可能要使用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 >--------
}
Source: https://codedocu.com/Net-Framework/Controls/COM-ActiveX/Create-C_hash_-COM-Control-for-Office?2382 来源: https : //codedocu.com/Net-Framework/Controls/COM-ActiveX/Create-C_hash_-COM-Control-for-Office?2382
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.