0

我无权访问 IIS 服务器,但我被告知该站点已配置为使用 .NET Framework 1.1 版运行。当我使用 Telerik JustDecompile 时,我看到以下内容。

在此处输入图像描述

“NET 1”似乎表明这 2 个 dll 是针对 FW 的 1.1 版编译的。网站 dll“GLSS”旁边的“ANY”是否表明该站点可以针对安装在 Web 服务器上的任何版本的 .NET FW 运行?

在为升级到 2.0 做准备时,我已经要求 Web 管理员将站点配置更改为固件的 2.0 版本,令我惊讶的是,我认为运行 1.1 代码的站点仍然可以运行。我应该感到惊讶吗?

这只是向后兼容的一个简单示例,并且站点可以配置为使用框架的任何版本,只要它等于或高于编译代码使用的版本吗?

当我查看解决方案中项目的属性页时,令我惊讶的是,仅对于网站项目,我无法找到设置要编译的固件版本的位置。我能够为引用的项目找到它。

您能否帮助我更好地了解配置站点的固件版本与编译程序集的版本之间的关系?

4

1 回答 1

1

You should not be surprised, .NET was always backward compatible in a sense that assemblies compiled against a version of the runtime are supposed to run against a newer version of the runtime.

There are of course subtle issues where things are not backward compatible, starting from subtle semantic differences and ending with changes at the object contract level (where the expected method/class just does not exists anymore) but in general these problems depend on the complexity of your application. It is safe to assume that simple applications should just work with no issues.

The number of the runtime the assembly has been complied against is a part of the assembly's metadata, it can be read with reflection. Thus, at runtime, you have at least two possible versions of the runtime - the one the assembly has been compiled against and the current version of the runtime which executes your code.

于 2013-03-12T14:20:41.597 回答