core icon indicating copy to clipboard operation
core copied to clipboard

System.IO.FileNotFoundException: 'System.Drawing.Primitives Error - occures after .netCore Web app has run for some time correctly

Open ralfbalzer opened this issue 2 years ago • 1 comments

I have .netcore MVC application with one MVC and two blazor projects. The app uses Select.HtmlToPdf.NetCore (22.2.0) to generate PDF files. This works fine (sometimes for a week, sometimes only for one day) and than, just of a sudden, I get the following error:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Drawing.Primitives, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. File name: 'System.Drawing.Primitives, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

The app is on version 7.0.5 and deployed (framework independent) on a windows server using IIS.

This was working fine up to verison 7.0.0 and started sometime after I updated the security updates. Any idea what could cause this´? projectFile.txt

ralfbalzer avatar Apr 21 '23 07:04 ralfbalzer

I have the same issues with the following assemblies:

System.IO.Pipes System.Security.AccessControl System.IO.Compression; System.Drawing;

Running locally works fine (dotnet run), however, when I publish my app (ASP.NET Core 7.0.5) I get the same exception (System.IO.FileNotFoundException: Could not load file or assembly) for the assemblies mentioned above.

As workaround, I do the following on Program.cs: var pipesAssembly = typeof(System.IO.Pipes.PipeStream).Assembly; var accessControlAssembly = typeof(System.Security.AccessControl.AccessRule).Assembly; var compressionAssembly = typeof(System.IO.Compression.ZipArchive).Assembly; var drawingAssembly = typeof(System.Drawing.Bitmap).Assembly;

Please note my project references different projects (around 10), most of them also net7.0. Only 2 are netstandard2.0, not sure if that might be root of the issue, however, I cannot change other projects using netstandard2.0.

When I deploy the mode I use is Self-contained

fromberg100 avatar May 26 '23 04:05 fromberg100