栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > .Net

.NET Core使用System.Drawing.Common时找不到libgdiplus的问题

.Net 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

.NET Core使用System.Drawing.Common时找不到libgdiplus的问题

 

问题:.NET Core使用System.Drawing.Common时找不到libgdiplus的问题

Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]

An unhandled exception has occurred while executing the request.

System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.

---> System.DllNotFoundException: Unable to load shared library 'libgdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibgdiplus: cannot open shared object file: No such file or directory

at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)

at System.Drawing.SafeNativeMethods.Gdip..cctor()

--- End of inner exception stack trace ---

at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, Int32 format, HandleRef scan0, IntPtr& bitmap)

at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)

at CS.FTX.Web.Common.Extions.GetSecurityCode(String& code) in E:SourceDotNetCoreCS.FTXCS.FTX.WebCommonExtions.cs:line 56

at CS.FTX.Web.Controllers.AccountController.SecurityCode() in E:SourceDotNetCoreCS.FTXCS.FTX.WebControllersAccountController.cs:line 201

at lambda_method(Closure , Object , Object[] )

at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)

at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()

at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()

--- End of stack trace from previous location where exception was thrown ---

at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)

at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()

--- End of stack trace from previous location where exception was thrown ---

at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)

at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()

--- End of stack trace from previous location where exception was thrown ---

at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)

at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)

at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)

at CS.FTX.Web.Common.RequiredAdminMiddleware.InvokeAsync(HttpContext context, IHttpContextAccessor httpContextAccessor) in E:SourceDotNetCoreCS.FTXCS.FTX.WebCommonRequiredAdminMiddleware.cs:line 54

at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)

at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)

at IdentityServer4.Hosting.MutualTlsTokenEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes)

at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)

at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)

at Marvin.Cache.Headers.HttpCacheHeadersMiddleware.Invoke(HttpContext httpContext, IValidatorValueInvalidator validatorValueInvalidator)

at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)

at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)

at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

 

 

 

 

解决:

https://q.cnblogs.com/q/109061/

 

除了安装 libgdiplus 还要安装 libc6-dev

 

apt-get update

apt-get install -y --no-install-recommends libgdiplus libc6-dev ‘

 

 

 

分析:

为什么会找不到 libdl (libdl.so.2) 呢?

是因为 System.Drawing.Common 是在 /usr/lib/x86_64-linux-gnu/ 这个路径中找的,而容器中 libdl.so.2 存在于 /lib/x86_64-linux-gnu/ 目录中,

安装 libc6-dev 之后 /lib/x86_64-linux-gnu/ 中就有了 libdl.so.2 ,问题就解决了。

现在不需要 ln -s libgdiplus.so gdiplus.dll ,System.Drawing.Common 已经改了代码,直接加载 libgdiplus.so 

 

 

声明:本问为坑的记录,参考资料如下

https://q.cnblogs.com/q/109061/

 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/908278.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号