2

编辑:我已经将单声道(必须使用这些说明从源代码编译)更新到版本 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 在 Visual 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

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

4

1 回答 1

0

Mono 2.10 太老了,请升级。

于 2014-02-09T13:31:39.473 回答