How to force an application to use .NET 3.5 or above?

前端 未结 4 970
天命终不由人
天命终不由人 2020-12-09 05:01

Our application is built with VS 2008, uses Linq and has Target Framework set to .NET Framework3.5.

It works OK when only .NET 3.5 or 4 is installed on the machine.<

4条回答
  •  佛祖请我去吃肉
    2020-12-09 06:01

    Forming the question led me to the answer. As mentioned in the Element documentation,

    When multiple versions of the runtime are supported, the first element should specify the most preferred version of the runtime, and the last element should specify the least preferred version.

    So the way to achieve the second option ("CLR 4 if it is installed, and CLR 2 is CLR 4 is not installed") is to reverse the order of the elements in app.config:

    
    
        
            
            
        
    
    

    This way, .NET 4 will be loaded if it is installed, and an earlier version will be loaded if not.

提交回复
热议问题