Using Span<T> in a C++/CLR Project

Viewed 304

I have a C# project and a C++/CLR project in Visual Studio 2019. Both are targeting .NET 4.8. I'm trying to use a Span<byte> that gets passed from the C# project to the C++/CLR project.

Since both assemblies are targeting .NET 4.8, I'm using the System.Memory (4.5.2) NuGet package and its dependencies (System.Buffers, System.Numerics.Vectors, System.Runtime.CompilerServices.Unsafe). I have the same assemblies referenced in the C# project and the C++/CLR project.

In the C++/CLR project, I'm trying to access the span like so:
System::Span<unsigned char> span = pixelBuffer->Span;

I get this error on that line:
Foo.cpp(1544): error C2079: 'System::Span<unsigned char>::Enumerator::_span' uses undefined class 'System::Span<unsigned char>'

This doesn't make sense to me, since I can see System.Span<T> in the System.Memory.dll that the C++/CLR project is referencing.

I did find an open issue, but they are only getting warnings, not errors: https://developercommunity.visualstudio.com/content/problem/1017965/systemreadonlyspan-deprecated-warning-using-ccli.html

0 Answers
Related