gpt4 book ai didi

C#/Mono - 内存映射文件问题

转载 作者:太空宇宙 更新时间:2023-11-03 16:00:33 26 4
gpt4 key购买 nike

编辑:我已经将 mono(必须使用 these instructions 从源代码编译)更新到版本 3.2.7。我不再收到提示容量过载参数的错误,现在我收到以下错误。以前,当使用 mono verison 2.1 时,我可以打开一个小文本文件作为内存映射文件作为测试。使用新版本的单声道,无论我试图打开什么文件/提供或遗漏哪个重载参数,我都会遇到同样的错误。快速谷歌搜索没有产生任何结果,所以我回到你身边,stackoverflow。我该怎么办?

Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for Mono.Unix.Native.Syscall ---> System.EntryPointNotFoundException: Mono_Posix_Syscall_get_at_fdcwd
at (wrapper managed-to-native) Mono.Unix.Native.Syscall:get_at_fdcwd ()
at Mono.Unix.Native.Syscall..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.IO.MemoryMappedFiles.MemoryMapImpl.Open (System.String path, FileMode mode, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in <filename unknown>:0
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, FileMode mode, System.String mapName, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in <filename unknown>:0
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path) [0x00000] in <filename unknown>:0
at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for Mono.Unix.Native.Syscall ---> System.EntryPointNotFoundException: Mono_Posix_Syscall_get_at_fdcwd
at (wrapper managed-to-native) Mono.Unix.Native.Syscall:get_at_fdcwd ()
at Mono.Unix.Native.Syscall..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.IO.MemoryMappedFiles.MemoryMapImpl.Open (System.String path, FileMode mode, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in <filename unknown>:0
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, FileMode mode, System.String mapName, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in <filename unknown>:0
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path) [0x00000] in <filename unknown>:0
at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

我正在从事一个涉及控制 beaglebone 上的 GPIO 引脚的项目。我正在尝试将一些 python 代码移植到 C#(一种我不太熟悉的语言)中,但在尝试打开位于/dev/mem 的板上的寄存器作为内存映射文件时遇到了问题,就像我在 python 中所做的那样.我正在使用 .Net 框架版本 4.0.30319 在 vi​​sual studio 2010 中编写和编译代码,并使用带有编译器版本 2.10.8.1 的单声道在 ubuntu 中运行它。

精简代码如下:

long offset = 0x4804c000;
long length = 0xfff;
using (var mm0 = MemoryMappedFile.CreateFromFile(@"/dev/mem", FileMode.Open,
"gpio1", capacity))
{
using (var accessor = mm0.CreateViewAccessor(offset, length))
{
do stuff
}
}

这会产生以下错误:

Unhandled Exception: System.ArgumentException: capacity
at System.IO.MemoryMappedFiles.MemoryMapImpl.Open (System.String path, FileMode mode, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in <filename unknown>:0
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, FileMode mode, System.String mapName, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in <filename unknown>:0
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, FileMode mode, System.String mapName, Int64 capacity) [0x00000] in <filename unknown>:0
at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: capacity
at System.IO.MemoryMappedFiles.MemoryMapImpl.Open (System.String path, FileMode mode, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in <filename unknown>:0
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, FileMode mode, System.String mapName, Int64 capacity, MemoryMappedFileAccess access) [0x00000] in <filename unknown>:0
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.String path, FileMode mode, System.String mapName, Int64 capacity) [0x00000] in <filename unknown>:0
at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

我试过指定和不指定内存映射的容量,以及许多不同的容量值,从几兆字节到板上的整个可用内存。有人知道从这里去哪里的提示吗?

最佳答案

Mono 2.10 非常旧,请升级。

关于C#/Mono - 内存映射文件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21654905/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com