首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在VBA中,C# dll说明没有入口点。

在VBA中,C# dll说明没有入口点。
EN

Stack Overflow用户
提问于 2019-02-08 05:07:30
回答 1查看 138关注 0票数 1

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

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

在我的VBA代码中,我声明:

代码语言:javascript
复制
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#代码:

代码语言:javascript
复制
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;
        }
    }
}

提前感谢您的帮助!!

EN

回答 1

Stack Overflow用户

发布于 2019-02-08 05:13:49

您可能希望使用InteropServices使COM可见DLL

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54582298

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档