简体   繁体   中英

Missing reference to netstandard for Cppsharp program

I'm trying to start my first project with Cppsharp using Visual Studio 2015, following the getting started guide.

The steps I followed were to:

  1. Create new C# console project
  2. Install Cppsharp using Nuget
  3. Add references to Dlls into the project
  4. Create C# source file based on the example in this old post

Whilst the example in the post is old, it still seems to be consistent with the getting started guide. The full program is listed below.

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) { }
        }

    }
}

However, I am already facing errors 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=...'

I was not able to find a way to add this reference. One solution I found proposed to target a higher .NET version (4.7.2) and I tried this, but the error still remains.

Can anyone help to overcome this problem?

Posted the same question on the Github page and was recommended to upgrade from VS2015

Installing VS2019 removed this error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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