【问题标题】:Missing reference to netstandard for Cppsharp program缺少对 Cppsharp 程序的 netstandard 的引用
【发布时间】:2021-05-07 19:32:27
【问题描述】:

我正在尝试按照入门指南使用 Visual Studio 2015 使用 Cppsharp 开始我的第一个项目。

我遵循的步骤是:

  1. 创建新的 C# 控制台项目
  2. 使用 Nuget 安装 Cppsharp
  3. 在项目中添加对 Dll 的引用
  4. 根据旧post 中的示例创建C# 源文件

虽然帖子中的示例很旧,但它似乎仍然与入门指南一致。下面列出了完整的程序。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using CppSharp;

namespace CppSharpTest
{
    class Program
    {

        class DllDemoGenerator : ILibrary
        {
            static void Main(string[] args)
            {
                ConsoleDriver.Run(new DllDemoGenerator());
            }

            void Setup(Driver driver)
            {
                var options = driver.Options;
                options.GeneratorKind = LanguageGeneratorKind.CSharp;
                options.LibraryName = "DllDemo";
                options.Headers.Add("DllDemo.h");
                options.Libraries.Add("DllDemo.lib");
            }

            public void SetupPasses(Driver driver) { }

            public void Preprocess(Driver driver, CppSharp.AST.Library lib) { }

            public void Postprocess(CppSharp.AST.Library lib) { }
        }

    }
}

但是,我已经遇到了错误See image

CS0012  C# The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=...'

我无法找到添加此参考的方法。我发现一个解决方案建议针对更高的 .NET 版本(4.7.2),我尝试了这个,但错误仍然存​​在。

谁能帮助解决这个问题?

【问题讨论】:

    标签: cppsharp


    【解决方案1】:

    在 Github 页面上发布了同样的问题,建议从 VS2015 升级

    安装 VS2019 消除了这个错误

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-10
      • 2019-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多