根据一些阅读,安装VS2008似乎会自动提供.net 2.0 SP1,其中包含一些新的API,当您针对2.0运行时目标时,它将假定2.0 SP1。
但是,如果SP1尚未推出给我们的用户,这将导致运行时错误。
1. 是否有任何方法使VS针对dotnet 2.0(非SP1)进行目标设置? 2. 是否有其他解决方案以解决此问题,使开发人员不使用在本地编译和运行良好但在生产中出现问题的API?
我看到fxcop对此进行了检查,但必须有更加可靠的解决方案来解决此问题。
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="2.0.0.0"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="2.0.0.0"/> </dependentAssembly> ... 等等 ... </assemblyBinding> </runtime> </configuration>
顺便提一下,你在使用VS2008新建项目时可能会遇到一个名为"MSBuildToolsPath"的属性缺失问题,该属性必须被定义。如果你使用MSBuild,可以在命令行上进行定义,或者如果使用第二个选项,则可以通过编程方式进行指定。
engine.GlobalProperties.SetProperty( "MSBuildToolsPath", msbuildPath );