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

时间:2014-02-09 03:29:52

标签: c# mono arm beagleboneblack

编辑:我已将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 framework 4.0.30319编写和编译Visual Studio 2010中的代码,并使用带编译器版本2.10.8.1的mono在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

我已经尝试指定并且没有指定内存映射的容量以及许多不同的容量值,从容量从几兆字节到电路板上的整个可用内存。任何人都有从这里去哪里的提示?

1 个答案:

答案 0 :(得分:0)

单声道2.10非常老,请升级。