ASP.NET开发服务器不愿意升级到.NET 3.5

发布于 2024-08-04 00:29:17 字数 772 浏览 1 评论 0原文

我有一个 ASP.NET 2.0 Web 项目。工作得很好。我决定将网站升级到3.5。升级效果很好。我添加了一个 IHttpHandler,需要在 web.config 中包含以下行:

<add verb="GET,POST" path="MyOperation.asmx" type="MyClass"/>

web.config 中的这一行生成以下错误:“解析器错误消息:无法加载类型“MyClass”。 ” 这听起来像是类名中的典型拼写错误。但看起来不是,我检查了1000遍。然而,奇怪的是,在“黄屏死机”页面的底部却写着:

版本信息:Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET版本:2.0.50727.3082

这确实很奇怪。该项目设置为3.5。唯一使用 3.5 功能的代码是 IHttpHandler 实现。 Web 项目的所有其余部分均与 2.0 兼容,如果我从 web.config 中排除该行,则可以正常工作。 这是为什么呢?

[我没有尝试使用 IIS。我使用 ASP.NET 开发服务器。]

[编辑]我必须道歉,正如我在第一轮中预期的那样,这是愚蠢的拼写问题。我的 IHttpHandler 实现位于嵌套类中,正确的类名称是“OuterClass+NestedClass”,而不是我在配置文件中使用的 OuterClass.NestedClass。不过,我感谢所有做出贡献的人,因为我学到了有关 CLR 版本控制的新知识!

I had an ASP.NET 2.0 web project. Worked fine. I decided to upgrade the site to 3.5. The upgrade worked fine. I have added a IHttpHandler that required to include the following line in the web.config:

<add verb="GET,POST" path="MyOperation.asmx" type="MyClass"/>

This line in the web.config generates the following error: "Parser Error Message: Could not load type 'MyClass'."
This sounds like a typical spelling error in the class name. But it looks not, I checked it 1000 times. However, what is really strange that on the bottom of the "yellow-screen-of-death" page it says:

Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082

This is really strange. The project is set to 3.5. The only piece of code that use 3.5 features are the IHttpHandler implementation. All the rest of the web project are 2.0 compatible and works without problem if I exclude the line from the web.config.
Why is this?

[I did not try with IIS. I use ASP.NET development server.]

[EDIT] I have to apologize, it was stupid spelling issue as I expected in the first round. My IHttpHandler implementation was in a nested class and the proper class name is "OuterClass+NestedClass" vs OuterClass.NestedClass that I used in my config file. However, I thank to all who contributed because I learned new things on CLR versioning!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

何以笙箫默 2024-08-11 00:29:17

我认为您需要使用完全限定的类型名称。

像:

<add verb="GET,POST" path="MyOperation.asmx" type="Your.Namespace.MyClass, assembly.name"/>

包含 2 版本信息的错误是正常的,因为 3 和 3.5 的 CLR 没有改变。唯一的变化是额外的单独程序集和语法糖(例如自动属性是编译器的功能而不是运行时的功能)“.net 4”将附带新的 CLR。

I think you need to use the fully qualified type name.

Like:

<add verb="GET,POST" path="MyOperation.asmx" type="Your.Namespace.MyClass, assembly.name"/>

and the error containing the version information of 2 is normall since the CLR hasn't changed for 3 and 3.5. the only changes were additional sepperate assemblies and syntactic suggar (like automated properties are a feature of the compiler not the runtime) ".net 4" will come with a new CLR.

凶凌 2024-08-11 00:29:17

版本不是问题(我认为)。 .net 2 到 3.5 sp1 使用相同的运行时。较新的只是新的库和编译器。所以从 asp.net 的角度来看并没有太大的改变。

The version is not an issue ( I think). .net 2 to 3.5 sp1 use the same run time. The newer ones are just new libraries and compilers. So from the asp.net point of view not much has changed.

司马昭之心 2024-08-11 00:29:17

ASP.NET 3.5 实际上是带有额外扩展的 2.0。因此,只要服务器安装了 3.5,那么显示您指向 2.0 框架的消息就确认您已正确设置它。

问题可能是 olle 所建议的,您需要完整的类名、程序集名称。

另请确认您的 /bin 文件夹中有该 dll,并且如果您不是从站点的根目录工作,则该 dll 已被标记为应用程序。

ASP.NET 3.5 is really 2.0 with extra extensions. So, as long as the server has 3.5 installed, then the message that shows that you're pointing to the 2.0 framework confirms that you have it setup correctly.

The issue is likely what olle suggested, that you need the full class name, assembly name.

Also confirm that you have the dll in your /bin folder and that it's marked as an application if you're not working from the root of your site.

南…巷孤猫 2024-08-11 00:29:17

转到项目属性。选择应用程序选项卡。如果您尚未将目标框架更改为 .Net Framework 3.5,则将其更改为 .Net Framework 3.5。

Go to the project properties. Choose the Application tab. Change the Target Framework to .Net Framework 3.5 if you haven't done that already.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文