Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Mono {new Bitmap("fileName");} Just hangs on OSX

When trying to load either a ".bmp", ".png" or ".jpg" on OSX 10.7.3 using mono's version of the System.Drawing.Bitmap object the applications just hangs. I get no error, the app just is stuck on the Bitmaps constructor...

When I run the same code on (Arch)Linux or Windows everything works fine.

public static void Main (string[] args)
{
    using (var bitmap = new Bitmap("/....../image.bmp"))
    {

    }

    Console.WriteLine ("Hello World!");// Never gets here...
}

If I pause the application in debug mode it opens the "disassembly" window and shows its stuck on this line:

call Status System.Drawing.GDIPlus:GdiplusStartup (UInt64, GdiplusStartupInput, GdiplusStartupOutput)

NOTE: After pausing the application in debug mode a couple of times it "Magically" started to work while writing this. I promis I did not change any code. Anybody know what can cause "System.Drawing.GDIPlus" to hang so I know how to avoid it?? Is there a mono codex setting file or something that could have bin messed up?

like image 281
zezba9000 Avatar asked Feb 24 '12 00:02

zezba9000


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.


2 Answers

The problem is just performance. It has nothing to do with you code; the image is just taking a longer time to load.
Mono's implementation of System.Drawing is just a C# wrapper and is kinda incomplete and does not (or incorrectly) provide all features in System.Drawing. It may function well in windows because it uses the native GDIPlus.dll but in may not function well in unix-based systems because it uses the Cairo engine. You can find more information here.

like image 196
Antony Thomas Avatar answered Sep 26 '22 21:09

Antony Thomas


Having the same problem with a new Mono 3.8 install on 10.10; but it went away, suspiciously after I broke during the hanging, seeing thread #4 in GdiplusStartup().

Maybe it's related to the break, or maybe GdiplusStartup just takes a long time on first launch on OS X, doing font caching or something.

like image 26
user2057660 Avatar answered Sep 26 '22 21:09

user2057660