自定义字体的RDLC报告-调用COM组件返回错误HRESULT E_FAIL

本文关键字:错误 返回 HRESULT FAIL 组件 COM 字体 RDLC 报告 调用 自定义 | 更新日期: 2023-09-27 18:24:35

我有一个运行在Windows Azure Web角色上的ASP.NET MVC(Razor View Engine和C#)应用程序。

我使用RDLC本地报告创建带有可打印价格标签的pdf文件,并带有相应的条形码。

在使用启动任务安装条形码字体(TrueType)后,我在Azure上使用了它。最近,它停止了工作,我没有更改任何与此功能相关的内容。

我遇到了以下错误,到目前为止我还没有找到任何解决方案。我知道问题出在条形码字体上,因为pdf是用Arial这样的标准字体生成的。此外,当在我的电脑上本地运行应用程序时,它与条形码完美配合。

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& contentOffset) +768
   Microsoft.ReportingServices.Rendering.RichText.LineBreaker.Flow(TextBox textBox, Win32DCSafeHandle hdc, Single dpiX, FontCache fontCache, FlowContext flowContext, Boolean keepLines, Single& height) +617
   Microsoft.ReportingServices.Rendering.RichText.LineBreaker.Flow(TextBox textBox, Graphics g, FontCache fontCache, FlowContext flowContext, Boolean keepLines, Single& height) +182
   Microsoft.ReportingServices.Rendering.RichText.TextBox.MeasureFullHeight(TextBox textBox, Graphics g, FontCache fontCache, FlowContext flowContext, Single& 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& anyAncestorHasKT, Boolean hasUnpinnedAncestors) +35
   Microsoft.ReportingServices.Rendering.HPBProcessing.PageItem.CalculateVertical(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, PageItem[] siblings, List`1 ancestors, Boolean& 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& pageStructMemberCell, Boolean ignoreTotals, Boolean& 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& anyAncestorHasKT, Boolean hasUnpinnedAncestors) +662
   Microsoft.ReportingServices.Rendering.HPBProcessing.PageItem.CalculateVertical(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, PageItem[] siblings, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors, Nullable`1 sourceWidth) +977
   Microsoft.ReportingServices.Rendering.HPBProcessing.PageItemContainer.DetermineContentVerticalSize(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors, Boolean resolveState, Boolean resolveItem) +496
   Microsoft.ReportingServices.Rendering.HPBProcessing.PageItemContainer.DetermineVerticalSize(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors) +281
   Microsoft.ReportingServices.Rendering.HPBProcessing.PageItem.CalculateVertical(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, PageItem[] siblings, List`1 ancestors, Boolean& 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& 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& renderProperties, CreateAndRegisterStream createAndRegisterStream) +93

我的源代码:

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");

欢迎在这个问题上提供任何帮助,并对任何语法错误表示歉意。

提前谢谢。

自定义字体的RDLC报告-调用COM组件返回错误HRESULT E_FAIL

我能够通过远程桌面访问我的web角色的虚拟机并进行简单的REBOOT来解决我的问题。

致以最良好的问候。