I am currently working on a .NET project, and I'm encountering an issue while attempting to perform an IIS reset. Every time I try to execute the reset, I receive an error that hinders the deployment process. The specific error message I'm facing is as follows:
Failed to deploy web package to IIS website.
Error Code: ERROR_FILE_IN_USE
More Information: Web Deploy cannot modify the file 'Lato-Bold.ttf' on the destination because it is locked by an external process. In order to allow the publish operation to succeed, you may need to either restart your application to release the lock or use the AppOffline rule handler for .NET applications on your next publish attempt. For further information, please visit: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.
Error count: 1.
I have explored the iText5 library to address this issue but couldn't find a direct method to release the font resource after usage. Below is a snippet from the class where I create fonts for PDF generation:
protected static BaseFont bf = BaseFont.CreateFont(HttpContext.Current.Server.MapPath("/assetsui/Fonts/Lato/") + "Lato-Regular.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
protected static BaseFont bfBold = BaseFont.CreateFont(HttpContext.Current.Server.MapPath("/assetsui/Fonts/Lato/") + "Lato-Bold.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
It seems that the 'Lato-Bold.ttf' font file is being locked by an external process, which is preventing successful deployment. I would appreciate any suggestions or guidance on how to resolve this issue. Thank you in advance for your assistance.