繁体   English   中英

在VBA中,C#dll表示没有入口点

[英]In VBA, C# dll says there is no entry point

我查看了其他帖子,但找不到解决方案。

我试图使用在VBA代码中创建的C#dll,而不必添加引用。

在我的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;
        }
    }
}

预先感谢您的帮助!!

您可能要使用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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM