升级WPF应用到.NET 7时出现构建错误

huangapple go评论71阅读模式
英文:

Build error when upgrading WPF application to .NET 7

问题

我正在尝试将一个WPF应用程序从.NET 4.6.1升级到.NET 7。在解决了初始问题后,我遇到了一个构建错误。

MC1000 未知的构建错误,'在程序集'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\7.0.5\ref\net7.0\System.Web.dll'中找不到类型'System.Web.PreApplicationStartMethodAttribute'。

我不知道从哪里开始查找解决此问题的方法。有人知道如何解决吗?或者有任何可以开始的想法。

英文:

I'm trying to upgrade a WPF application from .NET 4.6.1 to .NET 7. After working out the initial issues, I'm left with a single build error.

MC1000	Unknown build error, 'Could not find type 'System.Web.PreApplicationStartMethodAttribute' in assembly 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref.0.5\ref\net7.0\System.Web.dll'.'

I have no idea where to start looking to fix this one. Does somebody know how to fix this? Or any idea where I can start.

答案1

得分: 0

你遇到的问题是预期的。

来自“.net framework”的System.Web.dll确实有以下类:

PreApplicationStartMethodAttribute Class

但在.NET 7中,它已被移除:

https://learn.microsoft.com/en-us/dotnet/api/system.web?view=net-7.0

因此,所有与此相关的代码需要重新检查,所有与此相关的代码需要重写。请检查您在哪一侧使用了PreApplicationStartMethodAttribute。

英文:

The issue you encountered is expected.

The System.Web.dll from '.net framwork' really has class:

PreApplicationStartMethodAttribute Class

But in .NET 7, it was been removed:

https://learn.microsoft.com/en-us/dotnet/api/system.web?view=net-7.0

So all the code that related to this need to be recheck, all of the code related to this need to be rewrite. Please check which side you used the PreApplicationStartMethodAttribute.

答案2

得分: 0

我通过卸载/安装一些NuGet包来实际解决了这个问题。也许其中一些仍然具有对System.Web命名空间的旧引用。

英文:

I actually fixed the issue by uninstalling/installing some nuget packages. Maybe some of them still had old references to the System.Web namespace.

huangapple
  • 本文由 发表于 2023年6月26日 22:09:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76557479.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定