Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
596 views
in Technique[技术] by (71.8m points)

.net 3.5 application on .net 4.0 runtime

If I have an application built to target .net 3.5, will it run if all the user has installed is .net 4.0? A link to official msdn documentation stating this would put my worries to rest.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes, it can. You can say that you support .NET 4 in your app.config file:

<configuration>
  <startup>
    <supportedRuntime version="v4.0" /> 
  </startup>
</configuration>

Note that changes in the framework may break your app. For details, see MSDN's list of .NET 4 migration issues, which includes recommended changes.

If you still want to support users with only .NET 3.5 installed, you also need to add a <supportedRuntime version="v2.0.50727" /> element:

<configuration>
  <startup>
    <supportedRuntime version="v4.0" /> 
    <supportedRuntime version="v2.0.50727" /> 
  </startup>
</configuration>

Note that the above configuration prefers .NET 4.0 if that is installed. Changing the order above makes the application prefer .NET 3.5 if that is installed. A complete table of possible configurations and effects can be found in MSDN's how-to on configuring your app to support .NET 4.0 or 4.5.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...