編輯:我更新單聲道(必須從源使用these instructions編譯)到版本3.2.7。我不再抱怨容量超載的錯誤,現在我得到下面的錯誤。以前,當使用單聲道verison 2.1時,我能夠打開一個小文本文件作爲內存映射文件作爲測試。使用新版本的單聲道,無論我嘗試打開哪個文件/哪個過載參數提供或忽略,都會得到相同的錯誤。快速谷歌搜索沒有產生任何東西,所以我回頭看你,stackoverflow。我該怎麼辦?C#/單聲道 - 內存映射文件的問題
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使用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
我嘗試指定和不指定內存映射的容量以及作爲從幾兆字節到板上整個可用RAM的容量的許多不同值。任何人有從哪裏去的提示?
如果使用不帶容量參數的CreateFromFile方法,是否會發生相同的錯誤? – Dirk
是的。有趣的是(或不是?)我能夠打開一個不同的,更小的文件而沒有問題,所以我認爲它可能是關於/ dev/mem的。 – user3288736
我剛剛將Mono升級到了3.2.8,看看一個程序是否能夠更好地工作,不幸的是我還得到了'System.TypeInitializationException:Mono.Unix.Native.Syscall的類型初始值設定項引發了一個異常---> System .EntryPointNotFoundException:Mono_Posix_Syscall_get_at_fdcwd'錯誤,但我的原因是調用'MessageBox.Show()' – drew010