【问题标题】:VS 2022 c# 'type or namespace name 'DllExport' could not be found'VS 2022 c# \'找不到类型或命名空间名称 \'DllExport\'
【发布时间】:2022-12-14 20:00:40
【问题描述】:

这是来自 GitHub 的一个 c# dll 被很多人使用所以它应该编译但是这一行 [DllExport(CallingConvention.StdCall)] 给出这些错误

错误 CS0246 找不到类型或命名空间名称“DllExport”(是否缺少 using 指令或程序集引用?)

错误 CS0246 找不到类型或命名空间名称“DllExportAttribute”(是否缺少 using 指令或程序集引用?)

这是代码中唯一有错误的行。

using System;

using System.Runtime.InteropServices;

using System.Threading.Tasks;

using Windows.Services.Store;
...
[DllExport(CallingConvention.StdCall)]
...
    

【问题讨论】:

    标签: namespaces dllexport


    【解决方案1】:

    从我收集到的你的特定代码行中

    [DllExport(CallingConvention.StdCall)]
    

    DllExport 是 UnmanagedExports 库中的一个函数,所以你只需要添加:

    using RGiesecke.DllExport;
    

    【讨论】:

      猜你喜欢
      • 2013-03-25
      • 2011-06-28
      • 2021-08-19
      • 1970-01-01
      • 2017-07-12
      • 2011-05-13
      • 2011-02-24
      • 2012-06-19
      相关资源
      最近更新 更多