Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Basic 9 (or C# 3) with Visual Studio 2010

I'm working on a project started in VB9 (VS 2008) and now I've migrated to VS2010 (VB10) but on the production server the IDE is still VS 2008. On my developement enviroment the code compiles fine, but sometimes, - let's say - I forget an _ at the end of the line which causes the VB9 compiler to throw an error.

So the question is, how could I build a project with the VS 2010 IDE but VB9 compiler? Or to force the VB10 compiler into VB9 mode?

like image 509
jaraics Avatar asked Jan 21 '23 23:01

jaraics


1 Answers

Unfortunately no there is not a way to accomplish this. When compiling in Visual Studio you aren't actually using the command line compiler. Instead you use the inproc hosted compiler (true for both VB.Net and C#). This compiler, while capable of outputting completely valid IL for down targeted platforms, is the version tied to Visual Studio (in this case 10.0).

There is no general way to shell out to a different version of the compiler or to the command line and get the behavior you're looking for.

What you can do though is set the language version of the compiler to be 9. This will issue warnings for a subset of parse level constructs which are not supported in VB9. This cannot be done from the IDE but can by editing the project file directly and inserting the following

 <PropertyGroup> 
    <LangVersion>9</LangVersion> 
  </PropertyGroup> 

Original Answer: Valid for targeting 3.5 but not this question

What you want to do is have your VB project target the 3.5 framework. This will cause the compiler to issue warnings on items that are not valid like _'s.

This can be done from the project properties page.

  • Right Click on the project and select properties
  • Go to the compile tab
  • Set the target to 3.5
like image 161
JaredPar Avatar answered Feb 04 '23 17:02

JaredPar