app.config“强制” (?) 在.net 4.0 上..需要吗?
似乎在VS 2010 Beta 2中将项目升级到.net 4.0时, 生成一个 app.config 文件,大致如下所示:
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
如果我想要仅 .NET 4.0 可执行文件,是否需要此文件? 注意:有趣的是,这只发生在 c# 中,而不是 f# 项目中。
我已成功删除它,没有任何明显的(到目前为止)副作用。
谁能详细说明它的重要性(如果有的话)
It seems that when upgrading a project to .net 4.0 in VS 2010 Beta 2,
a app.config file is generated, which roughly looks like this:
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
Is this file needed in case I want to have a .NET 4.0 only executable?
NOTE: Interestingly enough, this only happens in c# as opposed to f# projects.
I have successfully removed it without any visible (so far) side effects.
Can anyone elaborate on it's importance (if at all)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
重要的不是应用程序在您的计算机上的行为方式,而是它在其他计算机上的行为方式,或者当您在计算机上安装更新的 dotnet 运行时时的行为方式。
基本上,如果您不包含此内容,则将使用最新版本的 dotnet 运行时来运行您的应用程序。这听起来可能是一件好事,直到您依赖的某些功能被弃用或者您没有意识到自己所依赖的错误得到修复。
更有用的是,当您最初构建一个应用程序来使用旧版本的 dotnet 框架时,您可以在使用较新版本对其进行测试后使用此功能,以断言,是的,它确实可以与最新版本一起使用。
以下是来自 MSDN 的马口文字:
It's not so much about how the app behaves on your computer, but how it will behave on other computers, or when you install an updated dotnet runtime on your machine.
Basically, if you don't include this, the latest version of the dotnet runtime will be used to run your app. That might sound like a good thing, until some feature that you depend on becomes deprecated or a bug that you don't realize you're depending on gets fixed.
More usefully, when you have originally built an app to work with an older version of the dotnet framework, you can use this feature after you've tested it with newer versions to assert that, yes, it does work with the latest version.
Here's the horse's mouth text from MSDN: