.net - 使用跨度在 C++/CLR 项目中
问题描述
我在 Visual Studio 2019 中有一个 C# 项目和一个 C++/CLR 项目。两者都针对 .NET 4.8。我正在尝试使用Span<byte>
从 C# 项目传递到 C++/CLR 项目的一个。
由于这两个程序集都以 .NET 4.8 为目标,因此我使用的是System.Memory (4.5.2)
NuGet 包及其依赖项 ( System.Buffers
, System.Numerics.Vectors
, System.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>'
这对我来说没有意义,因为我可以System.Span<T>
在 System.Memory.dll 中看到 C++/CLR 项目正在引用。
我确实发现了一个未解决的问题,但他们只收到警告,而不是错误: https ://developercommunity.visualstudio.com/content/problem/1017965/systemreadonlyspan-deprecated-warning-using-ccli.html
解决方案
推荐阅读
- java - 如何在带有动画的 JavaFX 应用程序中为字符创建老虎机?
- java - readUTF() 在 writeObject() 之后返回错误
- c# - 如何在 windows 窗体 c# 中对此类代码进行单元测试
- c++ - 为什么 MSVC++ 需要 std::setprecision 才能使用 std::hexfloat 启用全精度输出?
- python - 如何使用 DataFrame 限制列中字符串(字符/单词)的数量
- python - 使用 pyautogui 定位 opencv 检测
- tcl - 如何检测 Tcl 协程的完成?
- android - 使用 Service 将 New Child 添加到 Fire-base Database 的通知
- android - 当 ESLint 发出错误时,如何在 React Native 项目中使构建失败
- gatsby - 如何在网站范围内更改 Gatsby 帖子标题?