Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing reference to netstandard for Cppsharp program #1609

Closed
jamesetch opened this issue May 14, 2021 · 3 comments
Closed

Missing reference to netstandard for Cppsharp program #1609

jamesetch opened this issue May 14, 2021 · 3 comments

Comments

@jamesetch
Copy link

Hello. I put a question on stack overflow last week (repeated below), but didn't get a reply. So I ask it here, although it is not an issue per se. Any help would be much appreciated.


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?

@tritao
Copy link
Collaborator

tritao commented May 14, 2021

I think the problem might be you are using VS 2015. Try using a more recent version of VS with .NET Core.

@jamesetch
Copy link
Author

Thanks for the quick reply. Yes, I am using VS2015. I will try to organize an update from my IT dept.

@jamesetch
Copy link
Author

Upgrading to VS2019 seems to have fixed that particular issue. Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants