Open samohd opened 2 weeks ago
I cannot add System::Text::Json using Nuget Package Manager in VS2022, as it errors: ... trying to install this package into a project that targets 'native,Version=v0.0'.
I tried downloading the package and referencing that. No go.
But I can add a reference to it and System::Memory from: C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\PublicAssemblies as apparently it's a part of the VS2022 install.
You do need to use NuGet to reference NuGet package. It's the only correct way to use System.Text.Json. It's incorrect to use them from any other place like Visual Studio installation. The same file name doesn't mean the files are the same.
It seems that your C++/CLI project isn't recognized as C++/CLI by NuGet.
I should clarify that I did download NuGet packages manually and referenced those... that has the same C2079 issue as with using the VS installation.
I cannot find anything about the Version=v0.0 issue online. But, it doesn't seem to matter given those result in the same error anyway.
Also, as mentioned, the VS installed files work with a C# project without the error
I also noticed that JsonDocument::Parse(astring) is not usable with c++/cli. It seems to only support this variation JsonDocument::Parse(astring, JsonDocumentOptions())
I cannot find anything about the Version=v0.0 issue online. But, it doesn't seem to matter given those result in the same error anyway.
Your project is recognized as native
. You got Version=v0.0
just because native platform isn't versioned. NuGet does support native C++ and it can't use any managed reference.
Also, as mentioned, the VS installed files work with a C# project without the error
Yes, because VS is using .NET Framework, so it's shipping the same edition of the dlls that would be picked from the NuGet package. Testing with C# project is irrelevant because C# project is always managed.
I also noticed that JsonDocument::Parse(astring) is not usable with c++/cli.
That's because C++/CLI doesn't support standard mechanism of default argument in .NET.
But why does Nuget see it as native, when .NET Target Framework Version is v4.7.2 which is supposedly supported by this library (and others that also have the same error).
If C++/CLI i s supported, library can easily handle default argumenting, to be consistent across languages. Seems like lazy programming.
It very irritating too that all these Nuget integrations are in dlls rather than obj files that can be linked.
But why does Nuget see it as native, when .NET Target Framework Version is v4.7.2 which is supposedly supported by this library (and others that also have the same error).
NuGet seems to see your project as native, not the package. You are probably not able to reference any other managed package or assembly either.
Well, there's clearly an issue with Nuget's method of detecting v4.7.2 framework. But, I can live with that, installing it manuallly... I just can't use System::Text::Json because of the issue with undefined class 'System::Buffers::ReadOnlySequence'.
At this point, I gave up and coded my own json parser... no libraries, tons less bloat, and well... life is short.
And yes, I realize Nuget is incorrectly detecting the project type. I am using WebView2 without issue. So the error doesn't have to do with my project type.
Tagging subscribers to this area: @dotnet/area-meta See info in area-owners.md if you want to be subscribed.
Description
With C++/CLI and 4.7.2 framework, I'm having an issue compiling using System::Text::Json. The following
String^ s = "some json text"; JsonDocument::Parse(s, JsonDocumentOptions());
Generates this compile error:
C2079 'System::Buffers::ReadOnlySequence::Enumerator::_sequence' uses undefined class 'System::Buffers::ReadOnlySequence'
I cannot add System::Text::Json using Nuget Package Manager in VS2022, as it errors: ... trying to install this package into a project that targets 'native,Version=v0.0'.
I tried downloading the package and referencing that. No go.
But I can add a reference to it and System::Memory from: C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\PublicAssemblies as apparently it's a part of the VS2022 install.
I tried creating a c# framework project and was able to compile that with the same references.
Reproduction Steps
Above.
Expected behavior
Successful compilation.
Actual behavior
Unsuccessful compilation.
Regression?
First time using.
Known Workarounds
No response
Configuration
VS2022. 4.7.2 framework. x86
Other information
No response