title: Executing .Net Application using Mono on CentOS or Linux
body: <p>I have develop a Test Application using WinForm in C# .Net on Visual Studio 2010. Now, I want to run this under Linux using Mono on CentOS. So I tried below command sequence - </p>
  
  <pre><code>[root@localhost TestLinux]# /usr/bin/mono ./Test.exe
  </code></pre>
  
  <p>I hit an exception </p>
  
  <pre><code>Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.XplatUI ---&gt; System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---&gt; System.DllNotFoundException: gdiplus.dll
    at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&amp;,System.Drawing.GdiplusStartupInput&amp;,System.Drawing.GdiplusStartupOutput&amp;)
    at System.Drawing.GDIPlus..cctor () [0x00000] --- End of inner exception stack trace ---
  
    at &lt;0x00000&gt; &lt;unknown method&gt;
    at System.Drawing.Graphics.FromHdcInternal (IntPtr hdc) [0x00000] 
    at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) [0x00000] 
    at System.Windows.Forms.XplatUIX11..ctor () [0x00000] 
    at System.Windows.Forms.XplatUIX11.GetInstance () [0x00000] 
    at System.Windows.Forms.XplatUI..cctor () [0x00000] --- End of inner exception stack trace ---
  
    at &lt;0x00000&gt; &lt;unknown method&gt;
    at System.Windows.Forms.Application.EnableVisualStyles () [0x00000] 
    at Test.Program.Main () [0x00000] 
  </code></pre>
  
  <p>While doing some research I found that this is due to linking between gdiplus.dll and its counter part libgdiplus.so.0 on linux, need to put its entry in ldconfig cache.</p>
  
  <pre><code>[root@localhost TestLinux]# ldconfig -p | grep libgdiplus
      libgdiplus.so.0 (libc6) =&gt; /usr/lib/libgdiplus.so.0
  </code></pre>
  
  <p>The output clearly shows that libgdiplus.so.0 is there in ldconfig cache but still the program is not working. I also tried to add DllMap entry in application configuration as below</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
  &lt;startup&gt;
    &lt;supportedRuntime version="v2.0.50727"/&gt;
  &lt;/startup&gt;  
      &lt;dllmap dll="gdiplus.dll" target="libgdiplus.so.0"/&gt;  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Please let me know if anybody stumbled upon this in past. </p>