Bug 18507 - Application crash when FontFamily.Dispose() is caled
Summary: Application crash when FontFamily.Dispose() is caled
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Drawing ()
Version: 3.2.x
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-03-21 10:08 UTC by James
Modified: 2014-03-21 10:39 UTC (History)
1 user (show)

Tags: System.Drawing FontFamily PrivateFontCollection
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 18507 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description James 2014-03-21 10:08:20 UTC
Description of Problem:

 I'm writing a library in C # that allows me to convert HTML to PDF. Obviously the idea is that it is cross-platform and why I'm doing with mono. To do this I have to load Seller fonts with System.Drawing.Text.PrivateFontCollection class. When the application finishes executing all the code, the application unexpectedly quits. After many tests, I realized that the problem is when it is called a combination of the Dispose method of System.Drawing.FontFamily and the Dispose method of System.Drawing.Text.PrivateFontCollection is called. This problem is in Windows (I have Windows 7 32 bit), in linux I have no problem. I will attach a sample code that causes this error.


using System;
using System.Drawing.Text;
using System.IO;
using System.Runtime.InteropServices;
using System.Drawing;

namespace FORM
{
	class MainClass
	{
		public static void Main (string[] args)
		{


			PrivateFontCollection pf = new PrivateFontCollection ();
			IntPtr fontBuffer = IntPtr.Zero;
			pf.AddFontFile ("C:\\Users\\James\\Downloads\\open sans\\open-sans.regular.ttf");
			var fe = pf.Families;
			Font f = new Font (fe[0],12,FontStyle.Regular);
		
			// Añadiendo este código se puede ver claramente que el problema está en estos métodos
			fe [0].Dispose ();
			pf.Dispose ();


			Console.WriteLine ("Hello World!");
			Console.ReadLine ();
		}
	}
}




Actual Results:
APPLICATION CRASH. 
Firma con problemas:
  Nombre del evento de problema:	APPCRASH
  Nombre de la aplicación:	mono.exe
  Versión de la aplicación:	0.0.0.0
  Marca de tiempo de la aplicación:	523560bb
  Nombre del módulo con errores:	StackHash_0a9e
  Versión del módulo con errores:	0.0.0.0
  Marca de tiempo del módulo con errores:	00000000
  Código de excepción:	c0000005
  Desplazamiento de excepción:	212134a6
  Versión del sistema operativo:	6.1.7601.2.1.0.256.1
  Id. de configuración regional:	9226
  Información adicional 1:	0a9e
  Información adicional 2:	0a9e372d3b4ad19135b953a78882e789
  Información adicional 3:	0a9e
  Información adicional 4:	0a9e372d3b4ad19135b953a78882e789



How often does this happen? 
Always