带.NET Core GDI +的Heroku-18:无法加载DLL“ libgdiplus”:找不到指定的模块

时间:2019-10-01 17:44:17

标签: heroku .net-core

自从Heroku-16堆栈升级到Heroku-18堆栈后,引用System.Drawing.Common以使用GDI +的.NET Core 2.2应用程序抛出错误:

System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
--->System.DllNotFoundException: Unable to load DLL 'libgdiplus': The specified module could not be found.
at System.Runtime.InteropServices.FunctionWrapper `1.get_Delegate()
 at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
 at System.Drawing.SafeNativeMethods.Gdip..cctor()

这是因为未安装libc6-devsee this issue)。我正在使用heroku-buildpack-apt同时安装libgdipluslibc6-dev),但似乎该软件包不再可用,在运行时只能在Heroku-18上使用在构建时(see this page)。

从构建日志中:

remote: -----> Fetching .debs for libc6-dev
remote:        Reading package lists...
remote:        Building dependency tree...
remote:        Reinstallation of libc6-dev is not possible, it cannot be downloaded.
remote:        0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

恢复为Heroku-16即可解决此问题。

我该如何在Heroku-18堆栈上进行这项工作?有人找到方法了吗?

2 个答案:

答案 0 :(得分:0)

在Heroku支持下:

  

我真的很抱歉给您带来麻烦,但是在我看来这是不可能的。该软件包libc6-dev2.27-3ubuntu1意味着该软件包仅在构建时可用,而在运行时不可用。此外,如果您有一些要求,可以检查https://elements.heroku.com/buildpacks/eugeneotto/heroku-buildpack-secp256k1,但这不是官方支持的buildpack,我们对此不提供支持。

答案 1 :(得分:0)

.NET Core 3.x以及最新版本的System.Drawing.Common包含一些修复程序,这些修复程序消除了对libc6-dev的依赖。

如果无法安装libc6-dev,则可以尝试:

  • 升级到.NET Core 3.0
  • 升级到libgdiplus 4.6.0或更高版本(建议使用4.7.0)