【发布时间】:2021-12-28 05:13:11
【问题描述】:
使用 Linux 在 Premium Elastic Plan 上运行 C# Azure Functions 应用程序,利用一些有助于操作 MS Office 文件和 PDF 的 DevExpress 库,这些库显然依赖于 gdiplus,我似乎无法解决这个问题。
我们通过 Azure Portal for the Function App -> Configuration -> General settings -> Stack settings -> Startup Command 输入以下内容:
sudo apt-get update && sudo apt-get install -y 软件属性-common && sudo add-apt-repository 'deb http://deb.debian.org/debianbulseye main' && sudo apt-get update && sudo apt-get install -y libc6-dev && sudo apt-get install -y libgdiplus && sudo apt-get install -y libicu-dev && sudo apt-get install -y libharfbuzz0b && sudo apt-get install -y libfontconfig1 && sudo apt-get install -y libfreetype6 && sudo apt-get install -y libpango-1.0-0 && sudo apt-get install -y libpangocairo-1.0 && dotnet MyFunctionApp.dll
- 用sudo和不用sudo都试过了,没区别,还是得到下面的异常
- 尝试输入上面的内容,用双引号括起来并以 -c 为前缀以防万一(因为它被传递给 docker run 命令),没有区别
"Message":"发生错误。","ExceptionMessage":"类型 'DevExpress.Text.Fonts.GDIFontSubstitutionEngine' 的初始化程序 扔了一个 异常。","ExceptionType":"System.TypeInitializationException","StackTrace":" 在 DevExpress.Pdf.ContentGeneration.PdfExportFontManager.GetMatchingFont(PdfSetTextFontCommand setTextFontCommand)\n 在 DevExpress.Pdf.PdfInteractiveFormField.GetFontInfo(IPdfExportFontProvider 字体搜索)\n 在 DevExpress.Pdf.Native.PdfTextBasedFormFieldAppearanceBuilder`1..ctor(PdfWidgetAnnotation 小部件,T formField,IPdfExportFontProvider fontSearch,PdfRgbaColor 背景颜色)\n 在 DevExpress.Pdf.Native.PdfWidgetAppearanceBuilderFactory.DevExpress.Pdf.Native.IPdfInteractiveFormFieldVisitor.Visit(PdfTextFormField 表单域)\n 在 DevExpress.Pdf.PdfWidgetAnnotation.CreateAppearanceBuilder(IPdfExportFontProvider 字体搜索)\n 在 DevExpress.Pdf.PdfAnnotation.EnsureAppearance(PdfAnnotationAppearanceState 外观状态,PdfDocumentStateBase 文档状态,PdfForm 表单)\n
在 DevExpress.Pdf.PdfWidgetAnnotation.EnsureAppearance(PdfDocumentStateBase 文档状态)\n 在 DevExpress.Pdf.Native.PdfDocumentStateBase.CreateFormData(PdfInteractiveFormField 字段)\n 在 DevExpress.Pdf.Native.PdfDocumentStateBase.CreateFormData()\n,"InnerException":{"Message":"出现错误 发生。","ExceptionMessage":"'Gdip' 的类型初始化程序抛出 一个 异常。","ExceptionType":"System.TypeInitializationException","StackTrace":" 在 System.Drawing.SafeNativeMethods.Gdip.GdipNewInstalledFontCollection(IntPtr& fontCollection)\n 在 DevExpress.Text.Fonts.GDIFontSubstitutionEngine.CreateFromGDIPlus()\n 在 DevExpress.Text.Fonts.GDIFontSubstitutionEngine..cctor()","InnerException":{"Message":"An 发生错误。","ExceptionMessage":"U无法加载共享库 'libgdiplus' 或其依赖项之一。 为了帮助诊断 加载问题,考虑设置 LD_DEBUG 环境变量: liblibgdiplus:无法打开共享对象文件:没有这样的文件或 目录","ExceptionType":"System.DllNotFoundException","StackTrace":" 在 System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& 令牌, StartupInput& 输入,StartupOutput& 输出)\n at System.Drawing.SafeNativeMethods.Gdip..cctor()"}}}
有什么想法吗?我也无法在这台机器上安装 WSL 进行本地调试。感谢任何提示。
【问题讨论】:
-
您应该使用 Open XML SDK 来处理 Office 文件,并寻找与 .NET Core 兼容的 PDF 库/sdk。
-
对不起@AnandSowmithiran 这是一个非常无知的评论;处理 Office 文件有很多不错的选择,我们正在使用的 DevExpress 当然是兼容 .Net Core 和跨平台的。问题是在 Linux 上,需要一个额外的依赖项,我无法在 Azure Functions 环境中安装它。 docs.devexpress.com/XtraReports/401730/web-reporting/…
标签: linux pdf azure-functions cross-platform gdi