title: RDLC Reports with Custom Font - Error HRESULT E_FAIL has been returned from a call to a COM component
body: <p>I got an ASP.NET MVC (Razor View Engine and C#) application running on a Windows Azure Web Role.</p>
  
  <p>I use RDLC local reports to create pdf files with printable price tags with respective barcodes.</p>
  
  <p>I got it working on Azure after installing the barcode font (TrueType) using a start-up task. Recently, it stopped working without me changing anything related to this functionality.</p>
  
  <p>I'm getting the following error and so far I didn't find any solution. I know the problem is the barcode font because the pdf is generated well with a standard font like Arial. Also, it works perfectly with barcodes when running the app locally on my computer. </p>
  
  <pre><code>Error HRESULT E_FAIL has been returned from a call to a COM component.
  
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
  Exception Details: System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
  
  Source Error: 
  
  An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
  
  Stack Trace:     
  
  [COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.]
     System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) +0
     Microsoft.ReportingServices.Rendering.RichText.TextRun.ShapeAndPlace(Win32DCSafeHandle hdc, FontCache fontCache) +1450
     Microsoft.ReportingServices.Rendering.RichText.TextRun.GetWidth(Win32DCSafeHandle hdc, FontCache fontCache, Boolean isAtLineEnd) +30
     Microsoft.ReportingServices.Rendering.RichText.LineBreaker.GetLine(Paragraph paragraph, TextLine line, Win32DCSafeHandle hdc, FontCache fontCache, FlowContext flowContext, Single left, Single right, Single height, Stack`1 lineRunsIndex, Stack`1 lineRunsCharIndex, Int32 lineIndents) +266
     Microsoft.ReportingServices.Rendering.RichText.LineBreaker.FlowParagraph(Paragraph paragraph, Directions direction, Win32DCSafeHandle hdc, Single dpiX, FontCache fontCache, FlowContext flowContext, Boolean keepLines, SizeF flowContextSize, Int32&amp; contentOffset) +768
     Microsoft.ReportingServices.Rendering.RichText.LineBreaker.Flow(TextBox textBox, Win32DCSafeHandle hdc, Single dpiX, FontCache fontCache, FlowContext flowContext, Boolean keepLines, Single&amp; height) +617
     Microsoft.ReportingServices.Rendering.RichText.LineBreaker.Flow(TextBox textBox, Graphics g, FontCache fontCache, FlowContext flowContext, Boolean keepLines, Single&amp; height) +182
     Microsoft.ReportingServices.Rendering.RichText.TextBox.MeasureFullHeight(TextBox textBox, Graphics g, FontCache fontCache, FlowContext flowContext, Single&amp; contentHeight) +759
     Microsoft.ReportingServices.Rendering.HPBProcessing.TextBox.CalculateVerticalSize(PageContext pageContext) +467
     Microsoft.ReportingServices.Rendering.HPBProcessing.TextBox.DetermineVerticalSize(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, List`1 ancestors, Boolean&amp; anyAncestorHasKT, Boolean hasUnpinnedAncestors) +35
     Microsoft.ReportingServices.Rendering.HPBProcessing.PageItem.CalculateVertical(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, PageItem[] siblings, List`1 ancestors, Boolean&amp; anyAncestorHasKT, Boolean hasUnpinnedAncestors, Nullable`1 sourceWidth) +977
     Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.AddRowMember(TablixMember rowMember, Int32 colIndex, Int32 rowSpan, Int32 colSpan, LevelInfo childInfo, PageContext pageContext, Double updateWidth) +1104
     Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.CreateRowMemberChildren(Tablix tablix, TablixMember rowMemberParent, Int32 defTreeLevel, Boolean parentBorderHeader, Int32 parentRowIndex, Int32 parentColIndex, Int32 sourceIndex, Boolean resetContext, Boolean parentHasFooters, LevelInfo parentLevelInfo, PageContext pageContext) +4255
     Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.CreateRowMemberChildren(Tablix tablix, TablixMember rowMemberParent, Int32 defTreeLevel, Boolean parentBorderHeader, Int32 parentRowIndex, Int32 parentColIndex, Int32 sourceIndex, Boolean resetContext, Boolean parentHasFooters, LevelInfo parentLevelInfo, PageContext pageContext) +3657
     Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.CreateTablixRows(Tablix tablix, TablixMember rowMemberParent, Int32 defTreeLevel, Boolean parentBorderHeader, Int32 parentRowIndex, Int32 parentColIndex, List`1&amp; pageStructMemberCell, Boolean ignoreTotals, Boolean&amp; finishLevel, Boolean parentHasFooters, CreateItemsContext createItems, Double startInTablix, Double endInTablix, PageContext pageContext) +4341
     Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.CreateTablixItems(Tablix tablix, PageContext pageContext, CreateItemsContext createItems, Double startInTablix, Double endInTablix) +239
     Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.CreateVertically(PageContext pageContext, CreateItemsContext createItems, Double startInTablix, Double endInTablix, Double topInParentSystem) +374
     Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.DetermineVerticalSize(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, List`1 ancestors, Boolean&amp; anyAncestorHasKT, Boolean hasUnpinnedAncestors) +662
     Microsoft.ReportingServices.Rendering.HPBProcessing.PageItem.CalculateVertical(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, PageItem[] siblings, List`1 ancestors, Boolean&amp; anyAncestorHasKT, Boolean hasUnpinnedAncestors, Nullable`1 sourceWidth) +977
     Microsoft.ReportingServices.Rendering.HPBProcessing.PageItemContainer.DetermineContentVerticalSize(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, List`1 ancestors, Boolean&amp; anyAncestorHasKT, Boolean hasUnpinnedAncestors, Boolean resolveState, Boolean resolveItem) +496
     Microsoft.ReportingServices.Rendering.HPBProcessing.PageItemContainer.DetermineVerticalSize(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, List`1 ancestors, Boolean&amp; anyAncestorHasKT, Boolean hasUnpinnedAncestors) +281
     Microsoft.ReportingServices.Rendering.HPBProcessing.PageItem.CalculateVertical(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, PageItem[] siblings, List`1 ancestors, Boolean&amp; anyAncestorHasKT, Boolean hasUnpinnedAncestors, Nullable`1 sourceWidth) +977
     Microsoft.ReportingServices.Rendering.HPBProcessing.ReportSection.NextPage(RPLWriter rplWriter, Int32 pageNumber, Int32 totalPages, Double top, Double availableHeight, ReportSection nextSection, Boolean isFirstSectionOnPage) +1382
     Microsoft.ReportingServices.Rendering.HPBProcessing.Report.NextPage(RPLWriter rplWriter, Int32 totalPages) +384
     Microsoft.ReportingServices.Rendering.HPBProcessing.HPBProcessing.GetNextPage(RPLReport&amp; rplReport) +437
     Microsoft.ReportingServices.Rendering.ImageRenderer.PDFRenderer.Render(Report report, NameValueCollection deviceInfo, Hashtable renderProperties, CreateAndRegisterStream createAndRegisterStream) +1021
     Microsoft.ReportingServices.Rendering.ImageRenderer.RendererBase.Render(Report report, NameValueCollection reportServerParameters, NameValueCollection deviceInfo, NameValueCollection clientCapabilities, Hashtable&amp; renderProperties, CreateAndRegisterStream createAndRegisterStream) +93
  </code></pre>
  
  <p>My source code:</p>
  
  <pre><code>LocalReport report = new LocalReport();
  // Rdlc file path
  report.ReportPath = Server.MapPath("~/Reports/PriceTags.rdlc");
  
  // Data source
  report.DataSources.Add(new ReportDataSource("productsDataSet", dataset1));
  
  // Some parameters
  ReportParameterCollection reportParameters = new ReportParameterCollection();   
  reportParameters.Add(new ReportParameter("currency", "EUR"));
  reportParameters.Add(new ReportParameter("precision", 2));
  report.SetParameters(reportParameters);
  
  // FileContentResult GenPdf(LocalReport report, string filename)
  return GenPdf(report, "Price Tags");
  </code></pre>
  
  <p>Any help on this issue would be welcome and sorry for any grammar mistakes.</p>
  
  <p>Thanks in advance.</p>