title: Getting this Win32 Interop code to work under Mono?
body: <p>So i have this code in a .NET 2.0 console app:</p>
  
  <pre><code>[DllImport("kernel32.dll")]
  private static extern bool SetConsoleTextAttribute(IntPtr hConsoleOutput, 
      int wAttributes);
  
  [DllImport("kernel32.dll")]
  private  static extern IntPtr GetStdHandle(uint nStdHandle);
  
  private static readonly IntPtr hConsole;
  </code></pre>
  
  <p>And then in a method i have this:</p>
  
  <pre><code>const uint STD_OUTPUT_HANDLE = 0xfffffff5;
  hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  </code></pre>
  
  <p>And when i try to execute this app through Mono on a clean install of Ubuntu 8.10 i get this exception:</p>
  
  <pre><code>Unhandled Exception: System.TypeInitializationException: 
  An exception was thrown by the type initializer for 
      IMAPShell.Helpers.ColorConsole ---&gt; 
          System.EntryPointNotFoundException: GetStdHandle
    at (wrapper managed-to-native) IMAPShell.Helpers.ColorConsole:GetStdHandle (uint)
    at IMAPShell.Helpers.ColorConsole..cctor () [0x00000] --- End of inner exception stack trace ---
  
    at IMAPShell.Program.PrintWelcome () [0x00000] 
    at IMAPShell.Program.Main (System.String[] args) [0x00000]
  </code></pre>
  
  <p>Basically what i am doing is changing the color of the console output. I wrote this handy method that you can embed color codes into a string of text and it will parse out the codes and change the color of the output until it hits another color code. </p>
  
  <p>It works great on windows, and i would like it to work the same under Mono. Does anyone have any suggestions as to what i can try to get it to work under both OSes?</p>