[Mono-dev] Bug in Screen.GetBounds and missing ld-config file after mono 2.10.1 installation from source
quandary82 at hailmail.net
Sun Mar 6 18:17:21 EST 2011
I'm writing a fully managed remote-desktop clone.
I encountered a problem:
I wanted to take a screenshot in managed code, as described here:
(first comment for proper code)
Which gets me this on mono 2.6.7 and 2.10.1 (upgraded to 2.10.1 after it
didn't work in 2.6.7):
System.InvalidOperationException: XGetImage returned NULL when asked to
for a 5120x800 region block
If I add (uncomment it, see code at the bottom of this mail)
rectScreenBounds = new System.Drawing.Rectangle(0,0,100,100);
then it works...
So the result of the System.Windows.Forms.Screen.GetBounds rectangle is
(It works fine on Windows).
I've got a 1024x768 resolution, 15 inch laptop monitor...
You can get the proper screen bounds in C by getting DisplayHeight and
DisplayWidth from DefaultScreen via X11 with this code:
char *display_name = NULL;
/* open the connection to the display "simey:0". */
display = XOpenDisplay(display_name);// display = XOpenDisplay("simey:0");
if (display == NULL)
fprintf(stderr, "Cannot connect to X server %s\n", "simey:0");
int screen_height = DisplayHeight(display, DefaultScreen(display));
int screen_width = DisplayWidth(display, DefaultScreen(display));
printf("This screen is (%d,%d)\n", screen_width, screen_height);
XCloseDisplay( display )
Furthermore, since I already am writing an email, after compiling the
entire mono 2.10.1 suite:
When starting MonoDevelop, I get:
---> System.DllNotFoundException: gtksharpglue-2
But libgtksharpglue-2.so is present in
This error occurs because libgtksharpglue-2.so is in a subfolder of
/usr/lib, so this path is NOT in the ld-config paths.
One needs to create a glib.conf file in /etc/ld.so.conf.d/:
And then add this text to it
# Mono needs you
And afterwards updating the ld-library paths
This needs to be included in the installing subroutine (well, without
using gedit, you know what I mean)
Here my screenshot code:
(Note: it gets called from a timer every 1000/24 = 41 milliseconds)
protected System.Drawing.Rectangle rectScreenBounds =
protected System.Drawing.Bitmap bmpScreenshot = new
private void GetScreenshot()
// Do I need to dispose the PictureBox.Image as well ?
if (this.pictureBox1.Image != null)
//rectScreenBounds = new System.Drawing.Rectangle(0,0,100,100);
bmpScreenshot = new
using (System.Drawing.Graphics g =
} // End Using g
this.pictureBox1.Image = bmpScreenshot;
} // End Sub GetScreenshot
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-devel-list