I have a function that returns PrivateFontCollection:
Public Shared Function GetCustomFonts() As PrivateFontCollection Dim result = New PrivateFontCollection Dim customFontFiles = {"Garamond.TTF", "Garamond-Bold.TTF", "Garamond-Italic.TTF", "EurostileExtended-Roman-DTC.TTF"} For Each fontFile In customFontFiles result.AddFontFile(Hosting.HostingEnvironment.MapPath("/Includes/" & fontFile)) Next Return result End Function
Then I use the function as follows:
Using customFonts = Common.GetCustomFonts() ' Do some stuff here End Using
I would expect the files to be released, but they are still locked: I get the following error: "The action could not be completed because the file is open on the System. Close the file and try again. '
Disabling a website in IIS does not help; we must recycle the application pool for its release.
Can anyone advise how to use PrivateFontCollection so that the files are released between them?
source share