开发者

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 quest开发者_如何学Cion is, how could I build a project with the VS 2010 IDE but VB9 compiler? Or to force the VB10 compiler into VB9 mode?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜