在C ++ / CLR项目中使用Span <T>

问题描述

我在Visual Studio 2019中有一个C#项目和一个C ++ / CLR项目。两者都针对.NET 4.8。我正在尝试使用从C#项目传递到C ++ / CLR项目的Span<byte>

由于两个程序集都面向.NET 4.8,因此我使用的是System.Memory (4.5.2) NuGet包及其依赖项(System.BuffersSystem.Numerics.VectorsSystem.Runtime.CompilerServices.Unsafe)。我在C#项目和C ++ / CLR项目中引用了相同的程序集。

在C ++ / CLR项目中,我试图像这样访问范围:
System::Span<unsigned char> span = pixelBuffer->Span;

我在该行收到此错误:
Foo.cpp(1544): error C2079: 'System::Span<unsigned char>::Enumerator::_span' uses undefined class 'System::Span<unsigned char>'

这对我来说没有意义,因为我可以在C ++ / CLR项目所引用的System.Memory.dll中看到System.Span<T>

我确实发现了一个未解决的问题,但是他们只得到警告,而不是错误: https://developercommunity.visualstudio.com/content/problem/1017965/systemreadonlyspan-deprecated-warning-using-ccli.html

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...