# VBParser LoadStream

**URL:** https://forum.alternetsoft.com/t/vbparser-loadstream/503
**Category:** AlterNET Studio Support
**Tags:** editor, windows-forms
**Created:** [July 24, 2025, 3:42pm UTC](https://forum.alternetsoft.com/t/vbparser-loadstream/503 "2025-07-24T15:42:57Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rob.panosh](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/r/606060/32.png) [@rob.panosh](https://forum.alternetsoft.com/u/rob.panosh)
#### Post date: [July 24, 2025, 3:42pm UTC](https://forum.alternetsoft.com/t/vbparser-loadstream/503/1 "2025-07-24T15:42:57Z")

</div>

Hi,

I need to load text into the VBParser synchronously. Below is the code I am using but is loading in background thread and code after is continuing.

Using sw As New StringWriter  
With Me.\_vbParser  
Using sr As New StringReader(sb.ToString)  
.LoadStream(sr)  
.Strings.SaveStream(sw)  
End Using  
End With  
End Using

I need it to wait here until text has been parsed, so errors get populated. Otherwise, my sub returns and Me.HasCompileErrors will be false when there are errors.

Me.\_vbParser.GetSyntaxErrors(errors)

Me.HasCompileErrors = errors.FindIndex(Function(x As ISyntaxError) x.ErrorType = SyntaxErrorType.Error) \> -1  
Me.HasCompileWarnings = errors.FindIndex(Function(x As ISyntaxError) x.ErrorType = SyntaxErrorType.Warning) \> -1

Thanks,  
Rob

---

<div class="post-metadata">

### Author: ![wknauf](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/w/606060/32.png) [@wknauf](https://forum.alternetsoft.com/u/wknauf)
#### Post date: [July 29, 2025, 7:27am UTC](https://forum.alternetsoft.com/t/vbparser-loadstream/503/2 "2025-07-29T07:27:06Z")

</div>

Hi,

first question: what is your environment? Do you use WinForms or WPF?

You might try this - hope that it also populates the errors collection:

```auto
Me._vbParser.ForceReparseText()

```

But I am not sure whether this helps. And we have observed that it might simply deadlock in WinForms environment - this is the reason for my initial question.

You might also try to register a notifier - hopefully it is called after text parsing is completed, and in “MyNotifier.Notification” you could check for errors:

```auto
Me._vbParser.AddNotifier(new MyNotifier())

```

But the doc is quite unclear on the functionality of this notifier.

Hope some of my suggestions helps - I am just a user of this component and thus don’t have deep knowledge.

Best regards

Wolfgang

---

<div class="post-metadata">

### Author: ![rob.panosh](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/r/606060/32.png) [@rob.panosh](https://forum.alternetsoft.com/u/rob.panosh)
#### Post date: [July 29, 2025, 2:13pm UTC](https://forum.alternetsoft.com/t/vbparser-loadstream/503/3 "2025-07-29T14:13:40Z")

</div>

Hi Wolfgang,

Method ForceReparse() didn’t work for me. I ended up writing the code below. The parser we are using is in our business object layer that validates a script. I don’t need to worry about deadlocks because the parser will never be connected to a SyntaxEdit control.

 ![image](https://forum.alternetsoft.com/uploads/default/original/1X/e5adc6e501cb915496598708957d398ecb2359d9.jpeg)

Rob

---

<div class="post-metadata">

### Author: ![wknauf](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/w/606060/32.png) [@wknauf](https://forum.alternetsoft.com/u/wknauf)
#### Post date: [July 30, 2025, 9:10am UTC](https://forum.alternetsoft.com/t/vbparser-loadstream/503/4 "2025-07-30T09:10:35Z")

</div>

So you don’t use a GUI for editing the scripts, and use use AlterNET only for compilation and executing of the script? Do you used a RoslynParser or the VbParser from the “Advanced” package?

If you alread use the RoslyParser: you could use Roslyn to compile scripts to a .NET assembly that can be called from your code.  
If using C# scripts, you could also use a script evaluation API: [roslyn/docs/wiki/Scripting-API-Samples.md at main · dotnet/roslyn · GitHub](https://github.com/dotnet/roslyn/blob/main/docs/wiki/Scripting-API-Samples.md)
