Closed Nikoshi closed 5 years ago
I was unable to recreate this issue, can you post some additional details (perhaps some of your code) so that I can get a better idea of what is causing this issue?
I've created the textbox with the following properties and the only thing I do besides this is getting and setting the text.
Me.tbSQLCode.AutoCompleteBracketsList = New Char() {Global.Microsoft.VisualBasic.ChrW(40), Global.Microsoft.VisualBasic.ChrW(41), Global.Microsoft.VisualBasic.ChrW(123), Global.Microsoft.VisualBasic.ChrW(125), Global.Microsoft.VisualBasic.ChrW(91), Global.Microsoft.VisualBasic.ChrW(93), Global.Microsoft.VisualBasic.ChrW(34), Global.Microsoft.VisualBasic.ChrW(34), Global.Microsoft.VisualBasic.ChrW(39), Global.Microsoft.VisualBasic.ChrW(39)}
Me.tbSQLCode.AutoIndentCharsPatterns = ""
Me.tbSQLCode.AutoScrollMinSize = New System.Drawing.Size(27, 14)
Me.tbSQLCode.BackBrush = Nothing
Me.tbSQLCode.BackColor = System.Drawing.SystemColors.Control
Me.tbSQLCode.CharHeight = 14
Me.tbSQLCode.CharWidth = 8
Me.tbSQLCode.CommentPrefix = "--"
Me.tbSQLCode.Cursor = System.Windows.Forms.Cursors.IBeam
Me.tbSQLCode.DisabledColor = System.Drawing.Color.FromArgb(CType(CType(100, Byte), Integer), CType(CType(180, Byte), Integer), CType(CType(180, Byte), Integer), CType(CType(180, Byte), Integer))
Me.tbSQLCode.Dock = System.Windows.Forms.DockStyle.Fill
Me.tbSQLCode.IsReplaceMode = False
Me.tbSQLCode.LeftBracket = Global.Microsoft.VisualBasic.ChrW(40)
Me.tbSQLCode.Location = New System.Drawing.Point(0, 0)
Me.tbSQLCode.Name = "tbSQLCode"
Me.tbSQLCode.Paddings = New System.Windows.Forms.Padding(0)
Me.tbSQLCode.RightBracket = Global.Microsoft.VisualBasic.ChrW(41)
Me.tbSQLCode.SelectionColor = System.Drawing.Color.FromArgb(CType(CType(60, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(255, Byte), Integer))
Me.tbSQLCode.ServiceColors = Nothing
Me.tbSQLCode.Size = New System.Drawing.Size(537, 517)
Me.tbSQLCode.TabIndex = 40
Me.tbSQLCode.Zoom = 100
From your error, it appears as though something is null and an NPE is being thrown but not handled anywhere. Do you happen to know what line is causing the exception to be thrown?
Visual Studio is only showing the stacktrace which I have attached. It looks like the exception is thrown in FastColoredTextBox.DrawMarkers
Alright, is this project hosted on your github account? I am unable to recreate this issue on the latest version of the component.
Sorry the project is not hosted online, because it's an internal project.
Gotcha, makes sense lol, sorry I asked, I'll have a look at the function and see what's getting nulled out.
Well actually there's not a ton of info in that stack trace, do you happen to know what is null? Or do you know any line number information?
Actually I don't know more than what the stack trace told me, but I've looked in the function where the exception was thrown
private void DrawMarkers(PaintEventArgs e, Pen servicePen)
{
foreach (VisualMarker m in visibleMarkers)
{
if(m is CollapseFoldingMarker)
using(var bk = new SolidBrush(ServiceColors.CollapseMarkerBackColor))
using(var fore = new Pen(ServiceColors.CollapseMarkerForeColor))
using(var border = new Pen(ServiceColors.CollapseMarkerBorderColor))
(m as CollapseFoldingMarker).Draw(e.Graphics, border, bk, fore);
else if (m is ExpandFoldingMarker)
using (var bk = new SolidBrush(ServiceColors.ExpandMarkerBackColor))
using (var fore = new Pen(ServiceColors.ExpandMarkerForeColor))
using (var border = new Pen(ServiceColors.ExpandMarkerBorderColor))
(m as ExpandFoldingMarker).Draw(e.Graphics, border, bk, fore);
else
m.Draw(e.Graphics, servicePen);
}
}
I could try to debug the dll, maybe I get a line number or something else telling me where the exception happended
I made progess 😄. ServiceColors.CollapseMarker*
is null
. After looking again through my properties I saw that (I don't know why) ServiceColors
is set to null
.
I will fix it in my code, but it might be a good idea to check if ServiceColors
is set to null
.
If you look at the code you posted before, you are setting the servicecolors to null. This is what is causing the exception. The following line should be removed from your code:
Me.tbSQLCode.ServiceColors = Nothing
That's what I said, but I can't tell how that instruction ended up there, because this was generated by the vs gui builder and I didn't toch this
That code was generated by the vs gui builder? What version of vs are you using?
Visual Studio 2015
Try updating to visual studio 2019, I've always compiled the application on vs 2017 and it still worked fine, could be an issue with the way 2015 handles component initialization.
We're currently switching to 2019, I will try this^^ I guess the issue can be closed for now
Sounds good, if the issue persists, feel free to reopen.
Thanks for your help ^^
Environment:
Steps to reproduce:
Expected result:
Actual result: