1
[DllImport("kernel32.dll")]
static extern bool SetConsoleCtrlHandler(ControlEventHandler e, bool add);

I use this to catch and manage console interrupts, specifically Ctrl. + C.
It works well under Windows 7 with .NET, however I want to port this to mono on arch-linux.
When running it (regardless if built on Windows or directly on the linux machine with xbuild) I get

System.EntryPointNotFoundException: SetCtrlHandler
at (wrapper managed-to-native) rzs_slim.consoleControl:SetConsoleCtrlHandler (rzs_slim.ControlEventHandler, bool) //rzs_slim is the project, consoleControl the class
at [ctor of consoleControl]
at [Main]

How can I use this call to native code in mono? Can I reference the .dll in mono?

EDIT:
Actually, since this is a console-application I was able to achive the desired effect by subscribing my cleanup-function to the Console.CancelKeyPress-Event

Mark
  • 419
  • 1
  • 6
  • 21
  • 1
    This may help http://stackoverflow.com/questions/13825985/setconsolectrlhandler-equivalent-for-unix-linux-c. You need to search for the alternative in OS which you use it. – Sriram Sakthivel Aug 04 '14 at 12:14
  • @SriramSakthivel I even saw that when researching before asking, but thought my usage of .Net and mono might change the rules a bit. – Mark Aug 04 '14 at 12:21

0 Answers0