0
  • Linux debian 10
  • Mono 6.12
  • .net framework 4.5

I runned a c# program on linux with mono. Now I want to add a function : change a file permission to 755 on linux. I add Mono.Unix from nuget to the project referrence and use Mono.Unix.Native.Syscall.chmod and compile and package successfully. I compile and package it on windows 7 and mono 4.8.1. But I run it on linux (debian 10 Mono 6.12) and get error:

System.TypeInitializtionException: The type initializer for 'Mono.Unix.Native.Syscall' threw an exception-->System.DllNotFoundException:Mono.Unix assembly:<unknown assembly> type:<unknown type> member:(null)
 at (wrapper managed-to-native) Mono.Unix.Native.Syscall.get_at_fdcwd()
 at Mono.Unix.Native.Syscall..cctor () [0x0000a] in <7e182e4a9ebf470ba0164bbdc84457af>:0

And there was /usr/lib/mono/4.5/Mono.Posix.dll on linux.

Robert
  • 39,162
  • 17
  • 99
  • 152
  • Based on the source code, `MonoPosixHelper` seems to be missing in your case, https://github.com/mono/mono/blob/a44926a5be1c648deec836e9cdda3c93e25f9a51/mcs/class/Mono.Posix/Mono.Unix.Native/Stdlib.cs#L388 But overall you should move away from Mono now. – Lex Li Aug 24 '23 at 03:54

0 Answers0