Vb.Net Roslyn Syntax Editor Error

Hi,

Any ideas why I am getting the attached error? I am using the Roslyn VB.Net parser.

(class ‘Report_Script’ and class ‘Report_Script’ conflict in name space ‘<Default’)

Thanks,
Rob

Hi Rob,

how do yo initialize the AlterNet environment (e.g. some “VbParser”)? I suspect that you use the parameterless constructor and thus a static “RoslynSolution” instance is used, which already contains your script when editing it the second time.
If this is true: create a new RoslynSolution as constructor parameter.

Best regards

Wolfgang

Hi Wolfgang,

I’m a newbie using Roslyn …I added the VBParser via the designer and you are correct there is nothing being passed to the constructor. I changed my code to this:
Me.RoslynSolution = New RoslynSolution()
Me.VbParser = New VbParser(Me.RoslynSolution)

Then I get the following error, VBParser.Repository is Nothing.

I have one script/class … what should I pass to the constructor of VBParser?

Rob

I have also tried this initializing RoslynSolution like this with no luck
Me.RoslynSolution = New RoslynSolution(Microsoft.CodeAnalysis.SourceCodeKind.Script)
Me.RoslynSolution = New RoslynSolution(Microsoft.CodeAnalysis.SourceCodeKind.Regular)

I was getting the previous error due to a dumb mistake. Ok, got a bit further.

With this code:
image

I am getting this when my script control opens (hos is null). I wondering if this is a VB issue?

Rob

Hi Rob,

Could you try changing your code:
Me.RoslynSolution = new RoslynSolution()

to

Me.RoslynSolution = new VbSolution()

RoslynSolution is a base class and is not supposed to be instantiated.

Regards,
Dmitry

My bad - I should have written “VbSolution” in my previous reply. Sorry for the confusion!

Best regards

Wolfgang

That did the trick!

Cheers,
Rob

No worries Wolfgang … cheers, Rob