[Mono-bugs] [Bug 71643][Cri] New - System.DllNotFoundException: gdiplus.dll
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sun, 23 Jan 2005 16:37:40 -0500 (EST)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by andreas.weiss@de.bp.com.
http://bugzilla.ximian.com/show_bug.cgi?id=71643
--- shadow/71643 2005-01-23 16:37:40.000000000 -0500
+++ shadow/71643.tmp.3118 2005-01-23 16:37:40.000000000 -0500
@@ -0,0 +1,684 @@
+Bug#: 71643
+Product: Mono: Class Libraries
+Version: 1.0
+OS: SUSE 9.1
+OS Details:
+Status: NEW
+Resolution:
+Severity: 080 Two weeks
+Priority: Critical
+Component: Sys.Drawing.
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: andreas.weiss@de.bp.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Summary: System.DllNotFoundException: gdiplus.dll
+
+Please fill in this template when reporting a bug, unless you know what
+you are doing.
+Description of Problem:
+the gdiplus.dll exists and the program runs a time and then it throws this
+exception.
+System.DllNotFoundException: gdiplus.dll
+
+Steps to reproduce the problem:
+1. Try to understand the attached code or give me a chance to upload or
+email the Visual Studio Project
+2. Run the HttpWebRequest code on a SuSe 9.1 machine against a WebServer
+(IIS in my case)
+3. The exception will be thrown after some hundred loops
+
+Actual Results:
+...
+Start: 20050123_211336_3095 #(that is fine)
+Finish: 20050123_211336_4438 #(that is fine)
+Start: 20050123_211337_4494 #(that is fine)
+23. Januar 2005 21:13:38 http://10.38.25.115/webcam/cam_1.jpg?camera=1
+Problem beim Empfang der Daten von der WebCam:
+http://10.38.25.115/webcam/cam_1.jpg?camera=1 ,Fehlermeldung = The request
+timed out #(a catched WebRequest timeout)
+
+Unhandled Exception: System.TypeInitializationException: An exception was
+thrown by the type initializer for System.Drawing.GDIPlus --->
+System.DllNotFoundException: gdiplus.dll
+in <0x00053> (wrapper managed-to-native)
+System.Drawing.GDIPlus:GdiplusStartup
+(ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOu
+tput&)
+in <0x00068> System.Drawing.GDIPlus:.cctor ()
+--- End of inner exception stack trace ---
+
+in (unmanaged) System.Drawing.Bitmap:.ctor
+(int,int,System.Drawing.Imaging.PixelFormat)
+in <0x00059> System.Drawing.Bitmap:.ctor
+(int,int,System.Drawing.Imaging.PixelFormat)
+in <0x00015> System.Drawing.Bitmap:.ctor (int,int)
+in <0x00061> (wrapper remoting-invoke-with-check)
+System.Drawing.Bitmap:.ctor (int,int)
+in <0x00073> Webcam.Threadhelper:CreateBitmap (string,string,string)
+in <0x00dda> Webcam.Threadhelper:Process ()
+in <0x00053> (wrapper delegate-invoke)
+System.MulticastDelegate:invoke_void ()
+
+webcam_usr@10:~/bin/webcam/bin/Debug>
+
+
+Expected Results:
+It should not thrown an DllNotFoundException.
+
+How often does this happen?
+Every time
+
+
+Additional Information:
+
+a code snippet
+
+using System;
+using System.Drawing;
+using System.IO;
+using System.Net;
+using System.Threading;
+
+namespace Webcam
+{
+ /// <summary>
+ /// Zusammenfassung für ThreadHelper.
+ /// </summary>
+ public class Threadhelper
+ {
+ public Threadhelper()
+ {
+ //
+ // TODO: Fügen Sie hier die Konstruktorlogik hinzu
+ //
+ }
+
+ Thread tt;
+
+ private string Messageid;
+
+ private System.Uri _Url;
+ public System.Uri Url
+ {
+ get
+ {
+ return _Url;
+ }
+ set
+ {
+ _Url = value;
+ }
+ }
+
+ private string _User;
+ public string User
+ {
+ get
+ {
+ return _User;
+ }
+ set
+ {
+ _User = value;
+ }
+ }
+
+ private string _Password;
+ public string Password
+ {
+ get
+ {
+ return _Password;
+ }
+ set
+ {
+ _Password = value;
+ }
+ }
+
+ private string _Pathwebcamonline;
+ public string Pathwebcamonline
+ {
+ get
+ {
+ return _Pathwebcamonline;
+ }
+ set
+ {
+ _Pathwebcamonline = value;
+ }
+ }
+
+ private string _Pathwebcamarchive;
+ public string Pathwebcamarchive
+ {
+ get
+ {
+ return _Pathwebcamarchive;
+ }
+ set
+ {
+ _Pathwebcamarchive = value;
+ }
+ }
+
+ private string _Filename;
+ public string Filename
+ {
+ get
+ {
+ return _Filename;
+ }
+ set
+ {
+ _Filename = value;
+ }
+ }
+
+ private int _Timeout;
+ public int Timeout
+ {
+ get
+ {
+ return _Timeout;
+ }
+ set
+ {
+ _Timeout = value;
+ }
+ }
+
+ private int _Timeintervall;
+ public int Timeintervall
+ {
+ get
+ {
+ return _Timeintervall;
+ }
+ set
+ {
+ _Timeintervall = value;
+ }
+ }
+
+ private int _Delaybeforestart;
+ public int Delaybeforestart
+ {
+ get
+ {
+ return _Delaybeforestart;
+ }
+ set
+ {
+ _Delaybeforestart = value;
+ }
+ }
+
+ public void Threadhelperinitialize()
+ {
+ tt = new Thread(new ThreadStart(this.Process));
+
+ }
+ public void Start() { tt.Start(); }
+ public void End() { tt.Abort(); }
+ private void Process()
+ {
+ string strMsg;
+ string strPathFile;
+ string strPathfiletarget;
+ Stream objStream = null;
+ System.Net.HttpWebRequest req;
+ System.Net.HttpWebResponse rsp;
+ char chrDirectorySeparatorChar =
+System.IO.Path.DirectorySeparatorChar;
+ strPathFile = _Pathwebcamonline + _Filename;
+
+ //Um die Ueberlastung der http-Server durch
+gleichzeitige Anfragen
+ //an mehrere Kameras zu vermeiden, wurde dieser
+sleep eingebaut
+ //TODO: _Delaybeforestart dokumentieren
+ Thread.Sleep(_Delaybeforestart);
+ do
+ {
+ Console.WriteLine("Start: " +
+System.DateTime.Now.ToString("yyyyMMdd_HHmmss_ffff"));
+ try
+ {
+ req = (HttpWebRequest)
+System.Net.HttpWebRequest.Create(_Url);
+ req.Credentials = new
+NetworkCredential(_User, _Password);
+ req.Method = "GET";
+ req.Timeout = _Timeout;
+ rsp = (HttpWebResponse)
+req.GetResponse();
+ objStream = rsp.GetResponseStream
+();
+ try
+ {
+ if (objStream != null)
+ {
+ // Der
+auskommentierte Code hier funktioniert nicht!
+ // Dim Bm As
+Bitmap = New Bitmap(MyStream)
+ //byte[] bt = new
+byte[objStream.Length];
+ //objStream.Read
+(bt, 0, Convert.ToInt32(objStream.Length));
+ //fs =
+File.OpenWrite("myFile.jpg");
+ //fs.Write(bt, 0,
+bt.Length);
+ //fs.Close();
+ int intbytesRead =
+1;
+ BinaryReader
+bReader;
+ FileStream
+myfilestream = new FileStream(strPathFile, FileMode.Create);
+ try
+ {
+ bReader =
+new BinaryReader(objStream); //besser vielleicht den Webresponse statt
+objStream nehmen
+
+ BinaryWriter bWriter = new BinaryWriter(myfilestream);
+ byte[] bt
+= new byte[4096];
+ //Datei
+blockweise downloaden und lokal speichern
+ //Es
+funktioniert nicht jede block-size!
+// do
+// {
+//
+ //intbytesRead = bReader.Read(bt, 0, 4096);
+//
+ intbytesRead = objStream.Read(bt, 0, 4096);
+//
+ bWriter.Write(bt, 0, intbytesRead);
+//
+ //ProgressBar1.Value += bytesRead
+//
+ //ProgressBar1.Update()
+// }
+// while
+(intbytesRead == 0);
+ while
+(intbytesRead > 0)
+ {
+
+ intbytesRead = bReader.Read(bt, 0, 4096);
+
+ //intbytesRead = objStream.Read(bt, 0, 4096);
+
+ bWriter.Write(bt, 0, intbytesRead);
+
+ //ProgressBar1.Value += bytesRead
+
+ //ProgressBar1.Update()
+ }
+
+
+ bWriter.Close();
+
+ bReader.Close();
+
+ myfilestream.Close();
+
+ objStream.Close();
+ if (!
+(rsp.ContentLength == 0))
+ {
+
+ rsp.Close();
+ }
+
+ }
+ catch
+(System.ArgumentException e)
+ {
+ //
+ //Stream
+was not readable.
+ //TODO:
+Hier dann wieder ans Ende der Schleife springenl
+
+ Console.WriteLine("Process: Problem: " + e.Message);
+ }
+
+
+ strPathfiletarget
+= Createpathname(_Pathwebcamarchive, chrDirectorySeparatorChar,_Filename);
+ Filecopytoarchive
+(strPathFile, strPathfiletarget);
+ }
+ }
+ catch (System.IO.IOException e)
+ {
+ Messageid =
+System.DateTime.Now.ToLongDateString() + " " +
+System.DateTime.Now.ToLongTimeString() + " " + Url.ToString();
+ Console.WriteLine
+(Messageid + " Fehler beim Datei abspeichern: " + e.Message);
+ Console.WriteLine
+(Messageid + " Pfad: " + strPathFile);
+ Console.WriteLine
+(Messageid + " WebCam: " + Url.ToString());
+ //return strPathFile;
+ }
+
+ }
+ // Im folgenden nehme ich einfach
+an, das nur WebExceptions und keine
+ // anderen Exceptions auftreten
+koennen!
+ catch (System.Net.WebException e)
+ {
+ strMsg = e.Message;
+ Messageid =
+System.DateTime.Now.ToLongDateString() + " " +
+System.DateTime.Now.ToLongTimeString() + " " + _Url.ToString();
+ Console.WriteLine(Messageid + "
+Problem beim Empfang der Daten von der WebCam: " + _Url.ToString()
++ " ,Fehlermeldung = "+ strMsg);
+ //Zeilenumbruch einfuegen, um das
+Bild nicht zu breit werden zu lassen
+
+ if (strMsg.Length >= 35)
+ {
+ int intPosLeerzeichen =
+strMsg.IndexOf(" ",29);
+ if (intPosLeerzeichen < 40
+&& intPosLeerzeichen > 28)
+ {
+ strMsg =
+strMsg.Insert(intPosLeerzeichen, "\n");
+ }
+ else
+ {
+ strMsg =
+strMsg.Insert(29, "\n");
+ }
+ }
+ int Timeout_s = _Timeout/1000;
+ strMsg = _Url.ToString() + "\n"
++ "Timeout(konfiguriert)=" + Timeout_s.ToString() + "\n" + strMsg;
+ CreateBitmap(strMsg, strPathFile,
+_Url.ToString());
+ strPathfiletarget = Createpathname
+(_Pathwebcamarchive, chrDirectorySeparatorChar,_Filename);
+ Console.WriteLine("Pfad zum
+Archiv: " + strPathfiletarget);
+ Filecopytoarchive(strPathFile,
+strPathfiletarget);
+
+ //TODO: Wie kann man von hier
+wieder an den Anfang der Schleife springen oder die weitere
+Programmabarbeitung vermeiden?
+ //break oder so
+ //return strPathFile;
+ } //catch (System.Net.WebException e)
+
+// Console.WriteLine(strPathFile); // Was
+macht mein Thread gerade?
+ Console.WriteLine("Finish: " +
+System.DateTime.Now.ToString("yyyyMMdd_HHmmss_ffff"));
+ Thread.Sleep(_Timeintervall);
+ }
+ while (true); //Endlosschleife
+ //return strPathFile;
+ } //private void process()
+
+
+ static void CreateBitmap(string strText, string
+strPathFile, string strUrl)
+ {
+ string Messageid;
+ const float fResolution = 300;
+ Bitmap _bitmap;
+
+ //Eine nicht behandelte Ausnahme des
+Typs 'System.ArgumentException' ist in mscorlib.dll aufgetreten.
+ //Zusaetzliche Informationen: The path is not of a
+legal form.
+ //Es kam vor, das strPathFile = "" war
+ if (strPathFile.Length == 0)
+ {
+ //TODO: Fehlerhandling anpassen
+ Console.WriteLine("Problem:
+Schwerwiegender Programmierfehler: Die Variable strPathFile ist leer.");
+ }
+ else
+ {
+ try
+ {
+ _bitmap = new Bitmap(1, 1);
+ _bitmap.SetResolution(fResolution,
+fResolution);
+ Graphics grfx = Graphics.FromImage
+(_bitmap);
+ Font font = new Font("Times
+New Roman", 6); //Arial, Times New Roman
+ Size size = grfx.MeasureString
+(strText, font).ToSize();
+ //Size size = new Size(300,
+300);
+ _bitmap = new Bitmap(_bitmap,
+size);
+ _bitmap.SetResolution(fResolution,
+fResolution);
+ grfx = Graphics.FromImage(_bitmap);
+ grfx.Clear(Color.White);
+ grfx.DrawString(strText, font,
+Brushes.Black, 0, 0);
+
+ //TODO: Pruefen auf Recht zur
+Dateiablage
+ try
+ {
+ //Die untenstehende
+Exception kann ausgeloest werden,
+ //wenn waehrend des
+Dateidownloads ein Fehler auftritt.
+ //Eine nicht behandelte
+Ausnahme des Typs 'System.Runtime.InteropServices.ExternalException' ist
+in system.drawing.dll aufgetreten.
+ //A generic error occurred
+in GDI+.
+ _bitmap.Save(strPathFile,
+System.Drawing.Imaging.ImageFormat.Jpeg);
+ }
+ catch
+(System.Runtime.InteropServices.ExternalException e)
+ {
+ //TODO: Fehlerhandling
+sinnvoller gestalten. z. B. eine Muster-Datei abspeichern
+ Messageid =
+System.DateTime.Now.ToLongDateString() + " " +
+System.DateTime.Now.ToLongTimeString() + " " + strUrl + " " + strPathFile;
+ Console.WriteLine
+(Messageid + " CreateBitmap: Problem beim Abspeichern der Bilddatei: " +
+e.Message);
+ }
+ _bitmap.Dispose();
+ //grfx.Dispose(); //TODO:
+Klaeren Dispose ist anscheinend nicht erlaubt(?)
+ }
+ catch (System.IO.IOException e)
+ {
+ //TODO: Fehlerhandling sinnvoller
+gestalten. Was soll passieren wenn???
+ Messageid =
+System.DateTime.Now.ToLongDateString() + " " +
+System.DateTime.Now.ToLongTimeString() + " " + strUrl + " " + strPathFile;
+ Console.WriteLine(Messageid + "
+CreateBitmap: Problem beim Abspeichern der Bilddatei: " + e.Message);
+ }
+ } //if (strPathFile.Length = 0)
+ } //CreateBitmap()
+
+
+ static string Createpathname(string strPathinitial, char
+chrDirectorySeparatorChar, string strFilename)
+ {
+ //returns a generated pathname
+ //example: //server/directory/YYYY-MM-
+DD/hh/YYYYMMDD_hhmmss_server_camera_urlParameter
+ // "//server/directory" are defined in the
+webcam.ini-file
+ // "server, camera, url" are defined in the url
+
+ //TODO: Ueberpruefen der Gueltigkeit von strPathini
+ //TODO: Namen fuer das Verzeichnis und die Dateien
+ist nicht kongruent; Kein Programmier sondern ein Anwenderproblem
+ DateTime datetime1 = System.DateTime.Now;
+
+ string strDir = datetime1.ToString("yyyy-MM-dd");
+ string strDir2 = datetime1.ToString("HH");
+ string strFilenameheader = datetime1.ToString
+("yyyyMMdd_HHmmss");
+ string Pathname = strPathinitial + strDir +
+chrDirectorySeparatorChar + strDir2
+ + chrDirectorySeparatorChar + strFilenameheader
++ "_" + strFilename;
+
+ return Pathname;
+ } //static string Createpathname()
+
+
+ static bool Checkpathname(string strPathfile)
+ {
+ try
+ {
+ System.IO.FileInfo fi = new
+System.IO.FileInfo(strPathfile);
+ if (fi.Directory.Exists)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch (System.IO.IOException e)
+ {
+ string Messageid =
+System.DateTime.Now.ToLongDateString() + " " +
+System.DateTime.Now.ToLongTimeString();
+ Console.WriteLine(Messageid + " Problem
+bei der Verzeichnisabfrage (" + strPathfile + ") Checkpathname: " +
+e.Message);
+ return false;
+ }
+ } //private bool Checkpathname
+
+
+ static bool Createpath(string strDirectory)
+ {
+ //TODO: Mehrere Threads koennten theoretisch
+gleichzeitig versuchen ein Directory zu erstellen(?)
+ try
+ {
+ Directory.CreateDirectory(strDirectory);
+ return true;
+ }
+ catch (System.IO.IOException e)
+ {
+ //TODO: Abfangen, wenn Verzeichnis durch
+einen anderen Thread erstellt wurde
+ string Messageid =
+System.DateTime.Now.ToLongDateString() + " " +
+System.DateTime.Now.ToLongTimeString();
+ Console.WriteLine(Messageid + " Problem
+bei der Verzeichniserstellung (" + strDirectory + ") Createpath: " +
+e.Message);
+ return false;
+ }
+
+ } //private bool Createpath
+
+
+ private static void Filecopytoarchive(string
+strPathfilesource, string strPathfilenametarget)
+ {
+ string Messageid;
+ //Programmcode fuer die Archivierung der Webcam-
+Bilder
+ //TODO: Archivierungscode in eine separate Methode
+auslagern
+ bool bolPathexists = Checkpathname
+(strPathfilenametarget);
+
+ if (strPathfilesource.Length == 0)
+ {
+ //TODO: Fehlerhandling strPathfilesource
+== 0 Was tun?
+ Console.WriteLine("Problem:
+Schwerwiegender Programmierfehler: strPathfilesource == 0");
+ return;
+ }
+ if (!bolPathexists)
+ {
+ System.IO.FileInfo fi = new FileInfo
+(strPathfilenametarget);
+ string strPathname = fi.DirectoryName;
+ bolPathexists = Createpath(strPathname);
+ }
+ if (bolPathexists)
+ {
+ try
+ {
+ System.IO.FileInfo fi = new
+FileInfo(strPathfilesource);
+ fi.CopyTo(strPathfilenametarget);
+ }
+ catch (System.IO.IOException e)
+ {
+ Messageid =
+System.DateTime.Now.ToLongDateString() + " " +
+System.DateTime.Now.ToLongTimeString();
+ Console.WriteLine(Messageid + "
+Fehler beim Datei archivieren: " + e.Message);
+ Console.WriteLine(Messageid + "
+Pfad fuer die Quelldatei: " + strPathfilesource);
+ Console.WriteLine(Messageid + "
+Pfad fuer die Zieldatei: " + strPathfilenametarget);
+ Console.WriteLine(Messageid + "
+Bitte ueberpruefen Sie in diesem Zusammenhang auch die Konfiguration ihrer
+ini-Datei.");
+
+ }
+ }
+ else
+ {
+ //TODO: Fehlerhandling -> Einen zentralen
+Fehlerhandler bauen mit log-file-size Ueberwachung
+ Console.WriteLine("Datei kann nicht
+archiviert werden: " + strPathfilesource + " weil der Pfad nicht
+existiert");
+ }
+ } //Filecopytoarchive
+
+ } //class Threadhelper
+} //namespace
+
+
+the config data/parameter
+
+[COMMON]
+Path_Archive=/data/webcam/archive/
+Path_WebCam==/data/webcam/online/
+
+[WebCam 15]
+Url=http://webserver/webcam/cam_1.jpg?camera=1
+User=USER
+Pwd=user
+Filename=cam01_1_halfsize.jpg
+TimeInterval=1
+http_timeout=1