Microsoft.VisualStudio.Web.CodeGeneration.Design 6.0.6 and 6.0.7 breaks ClosedXml
- Dominant language
- C#
- Stars
- 818
- Forks
- 260
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 10
Description
I have an ASP.NET Core 6 Application. Using Closed XML 0.96 (problem is also on 0.95.4), with that I generate some Excel files.
Suddenly I've got this exception (it's an API, sorry for the JSON format).
```
{"type":"TypeInitializationException","title":"The type initializer for 'Gdip' threw an exception.","status":500,"detail":" at System.Drawing.SafeNativeMethods.Gdip.GdipGetGenericFontFamilySansSerif(IntPtr& fontfamily)\
at System.Drawing.FontFamily.GetGdipGenericSansSerif()\n at System.Drawing.FontFamily.get_GenericSansSerif()
at System.Drawing.Font.CreateFont(String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte charSet, Boolean isVertical)
at System.Drawing.Font..ctor(String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont)
at System.Drawing.Font..ctor(String familyName, Single emSize, FontStyle style)
at ClosedXML.Excel.FontBaseExtensions.GetCachedFont(IXLFontBase fontBase, Dictionary`2 fontCache)
at ClosedXML.Excel.FontBaseExtensions.GetWidth(IXLFontBase fontBase, String text, Dictionary`2 fontCache)
at ClosedXML.Excel.XLColumn.AdjustToContents(Int32 startRow, Int32 endRow, Double minWidth, Double maxWidth)
at ClosedXML.Excel.XLColumn.AdjustToContents(Int32 startRow, Int32 endRow)
at ClosedXML.Excel.XLColumn.AdjustToContents(Int32 startRow)
/// .... rest is application stackstrace. not relevant. .. //
```
I develop on macOS and the Application is running on Linux, happens on both systems. The libgdiplus “workarounds” are installed. And it worked without greater difficulties. But suddenly the above error happened.
On tracking down the issue, I saw that I bumped the Version Number of `Microsoft.VisualStudio.Web.CodeGeneration.Design` from 6.0.3 to 6.0.7. And that was the issue. Going back to 6.0.3 the Application was functional again. After some more Versions, I found out that 6.0.6 introduces this issue.
I have no Idea what some scaffolding NuGet has to do with that, but there must be something. I also filed an Issue on https://github.com/ClosedXML/ClosedXML/issues/1840
Contributor guide
Assessment
This issue has not been assessed yet.