1

I'm using the Microsoft.CodeAnalysis.Emit to compile a Visual Basic project and generate .dll file with following compilation options.

VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel: OptimizationLevel.Debug);

Following error is thrown by the emitter for all VB projects I tried to compile. Please advice how to resolve this.

vstest.executionengine.x86.exe Error: 0 : xxxxx -, C:\Projects\xxxx\xxxxx\My Project\Settings.Designer.vb(67,48): error BC30002: Type 'Global.xxxx.xxxx.Console.VBTestApp.My.MySettings' is not defined.

Bandara
  • 780
  • 8
  • 29

1 Answers1

1

To compile the generated Settings.Designer.vb file correctly, you have to set the root namespace of the project to the same one the file was generated with. In your case, that seems to be xxxx.xxxx.Console.VBTestApp, so your options should be:

new VisualBasicCompilationOptions(
    OutputKind.DynamicallyLinkedLibrary,
    optimizationLevel: OptimizationLevel.Debug,
    rootNamespace: "xxxx.xxxx.Console.VBTestApp")
svick
  • 236,525
  • 50
  • 385
  • 514
  • I have tried this but didn't work, I have further described the issue in following http://stackoverflow.com/questions/43227185/compiler-issue-in-visual-basic-project-with-microsoft-codeanalysis-emit – Bandara Apr 05 '17 at 16:20
  • Does "didn't work" mean that it didn't solve the issue you asked about or that it didn't solve other issues you have? If my answer actually answered the issue you asked about, consider accepting it. – svick Apr 05 '17 at 16:47