On vb.net error on system.drawing.fontFamily.GetName 'Parameter is not valid'

64 Views Asked by At

My application fails while trying to paint a dataGridView object. There are a dataTable object that collect the information from a MySQL database and that object inserts to a dataGridView object with dgvTable.source = dataTable method

That dataGridView is in tab0 of a tabControl that has 2 more tabs with a dataGridView fed with same method each one. When application starts, all apparently runs correct, but when changing to tab1 and returning to tab0 again, application returns that error recovered from immediate window:

19/06/2023 11:25:34 | Solution:247CP  Project:247CP  Config:Debug
Excepción producida: 'System.IO.IOException' en System.dll
System.Transactions Critical: 0 : \<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"\>\<TraceIdentifier\>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled\</TraceIdentifier\>\<Description\>Unhandled exception\</Description\>\<AppDomain\>247CP.exe\</AppDomain\>\<Exception\>\<ExceptionType\>System.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\</ExceptionType\>\<Message\>Parameter is not valid.\</Message\>\<StackTrace\>   at System.Drawing.FontFamily.GetName(Int32 language)
at System.Drawing.FontFamily.get_Name()
at System.Windows.Forms.Internal.WindowsFont.FromFont(Font font, WindowsFontQuality fontQuality)
at System.Windows.Forms.Internal.WindowsGraphicsCacheManager.GetWindowsFont(Font font, WindowsFontQuality fontQuality)
at System.Windows.Forms.TextRenderer.MeasureText(String text, Font font, Size proposedSize, TextFormatFlags flags)
at System.Windows.Forms.DataGridViewCell.MeasureTextHeight(Graphics graphics, String text, Font font, Int32 maxWidth, TextFormatFlags flags, Boolean&amp; widthTruncated)
at System.Windows.Forms.DataGridViewCell.GetPreferredTextHeight(Graphics g, Boolean rightToLeft, String text, DataGridViewCellStyle cellStyle, Int32 maxWidth, Boolean&amp; widthTruncated)
at System.Windows.Forms.DataGridViewColumnHeaderCell.PaintPrivate(Graphics g, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates dataGridViewElementState, Object formattedValue, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts, Boolean paint)
at System.Windows.Forms.DataGridViewColumnHeaderCell.GetContentBounds(Graphics graphics, DataGridViewCellStyle cellStyle, Int32 rowIndex)
at System.Windows.Forms.DataGridViewCell.OnCellDataAreaMouseEnterInternal(Int32 rowIndex)
at System.Windows.Forms.DataGridViewCell.OnMouseMoveInternal(DataGridViewCellMouseEventArgs e)
at System.Windows.Forms.DataGridView.OnCellMouseMove(DataGridViewCellMouseEventArgs e)
at System.Windows.Forms.DataGridView.UpdateMouseEnteredCell(HitTestInfo hti, MouseEventArgs e)
at System.Windows.Forms.DataGridView.OnMouseMove(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseMove(Message&amp; m)
at System.Windows.Forms.Control.WndProc(Message&amp; m)
at System.Windows.Forms.DataGridView.WndProc(Message&amp; m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String\[\] commandLine)
at ROBSVCOM.My.MyApplication.Main(String\[\] Args) in :line 83\</StackTrace\>\<ExceptionString\>System.ArgumentException: Parameter is not valid.
at System.Drawing.FontFamily.GetName(Int32 language)
at System.Drawing.FontFamily.get_Name()
at System.Windows.Forms.Internal.WindowsFont.FromFont(Font font, WindowsFontQuality fontQuality)
at System.Windows.Forms.Internal.WindowsGraphicsCacheManager.GetWindowsFont(Font font, WindowsFontQuality fontQuality)
at System.Windows.Forms.TextRenderer.MeasureText(String text, Font font, Size proposedSize, TextFormatFlags flags)
at System.Windows.Forms.DataGridViewCell.MeasureTextHeight(Graphics graphics, String text, Font font, Int32 maxWidth, TextFormatFlags flags, Boolean&amp; widthTruncated)
at System.Windows.Forms.DataGridViewCell.GetPreferredTextHeight(Graphics g, Boolean rightToLeft, String text, DataGridViewCellStyle cellStyle, Int32 maxWidth, Boolean&amp; widthTruncated)
at System.Windows.Forms.DataGridViewColumnHeaderCell.PaintPrivate(Graphics g, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates dataGridViewElementState, Object formattedValue, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts, Boolean paint)
at System.Windows.Forms.DataGridViewColumnHeaderCell.GetContentBounds(Graphics graphics, DataGridViewCellStyle cellStyle, Int32 rowIndex)
at System.Windows.Forms.DataGridViewCell.OnCellDataAreaMouseEnterInternal(Int32 rowIndex)
at System.Windows.Forms.DataGridViewCell.OnMouseMoveInternal(DataGridViewCellMouseEventArgs e)
at System.Windows.Forms.DataGridView.OnCellMouseMove(DataGridViewCellMouseEventArgs e)
at System.Windows.Forms.DataGridView.UpdateMouseEnteredCell(HitTestInfo hti, MouseEventArgs e)
at System.Windows.Forms.DataGridView.OnMouseMove(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseMove(Message&amp; m)
at System.Windows.Forms.Control.WndProc(Message&amp; m)
at System.Windows.Forms.DataGridView.WndProc(Message&amp; m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String\[\] commandLine)
at ROBSVCOM.My.MyApplication.Main(String\[\] Args) in :line 83\</ExceptionString\>\</Exception\>\</TraceRecord\>

Unhandled Exception: System.ArgumentException: Parameter is not valid.
at System.Drawing.FontFamily.GetName(Int32 language)
at System.Drawing.FontFamily.get_Name()
at System.Windows.Forms.Internal.WindowsFont.FromFont(Font font, WindowsFontQuality fontQuality)
at System.Windows.Forms.Internal.WindowsGraphicsCacheManager.GetWindowsFont(Font font, WindowsFontQuality fontQuality)
at System.Windows.Forms.TextRenderer.MeasureText(String text, Font font, Size proposedSize, TextFormatFlags flags)
at System.Windows.Forms.DataGridViewCell.MeasureTextHeight(Graphics graphics, String text, Font font, Int32 maxWidth, TextFormatFlags flags, Boolean& widthTruncated)
at System.Windows.Forms.DataGridViewCell.GetPreferredTextHeight(Graphics g, Boolean rightToLeft, String text, DataGridViewCellStyle cellStyle, Int32 maxWidth, Boolean& widthTruncated)
at System.Windows.Forms.DataGridViewColumnHeaderCell.PaintPrivate(Graphics g, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates dataGridViewElementState, Object formattedValue, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts, Boolean paint)
at System.Windows.Forms.DataGridViewColumnHeaderCell.GetContentBounds(Graphics graphics, DataGridViewCellStyle cellStyle, Int32 rowIndex)
at System.Windows.Forms.DataGridViewCell.OnCellDataAreaMouseEnterInternal(Int32 rowIndex)
at System.Windows.Forms.DataGridViewCell.OnMouseMoveInternal(DataGridViewCellMouseEventArgs e)
at System.Windows.Forms.DataGridView.OnCellMouseMove(DataGridViewCellMouseEventArgs e)
at System.Windows.Forms.DataGridView.UpdateMouseEnteredCell(HitTestInfo hti, MouseEventArgs e)
at System.Windows.Forms.DataGridView.OnMouseMove(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseMove(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DataGridView.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String\[\] commandLine)
at ROBSVCOM.My.MyApplication.Main(String\[\] Args) in :line 83

I'm trying to discover which line of my code causes this Error

Thanks for help

1

There are 1 best solutions below

0
On

I would say your error is there :

OBSVCOM.My.MyApplication.Main(String\[\] Args) in :line 83\</StackTrace\>\<ExceptionString\>System.ArgumentException: Parameter is not valid.

On line 83 (main). But without your code, I can't tell more.