views:

118

answers:

2

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?

+8  A: 

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
JaredPar
Thanks for your complete response, I've set the target framework to 3.5, but unfortunately it didn't solve my issue.
jaraics
@jaraics, sorry wasn't thinking clearly when I typed my first answer. Updated.
JaredPar
Cool, that's working! Thanks! P.S. That <PropertyGroup> tag should be inserted after the Project element.
jaraics
+2  A: 

I think this question and answer might be relevant to your situation.

Vincent
Indeed, it's the same question.
jaraics