Could not find type 'System.Web.UI.TagPrefixAttribute' after migrating class library to .NET 5
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
I used [Upgrade-Assistant](https://dotnet.microsoft.com/platform/upgrade-assistant/) to migrate a .NET Framework 4.5.2 class library to .NET 5.0.300 and am a few days into trying to fix a subsequent build error:
_C:\Program Files\dotnet\sdk\5.0.300\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(240,9): error MC1000: Unknown build error, 'Could not find type 'System.Web.UI.TagPrefixAttribute' in assembly 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Web.dll'.' [redacted.csproj] 0 Warning(s) 1 Error(s)_
Double-clicking on the error in Visual Studio takes me to this location in Microsoft.WinFX.Targets file:

According to the documentation, "The MarkupCompilePass1 task converts non-localizable XAML project files to compiled binary format" (I'm not convinced this is a WPF problem so I don't know if this the correct place for the issue, but given the location of the error it seemed like a good start). The class library contains both WinForms and WPF Controls. There are no explicit instances of "TagPrefixAttribute" in the code (or even System.Web). There could be a usage of "TagPrefixAttribute" in a dependency, but I'm not sure how to check this (if this is the case and the build system is aware of it, it would be nice to know what dependency). According to the documentation, the TagPrefixAttribute "defines the tag prefix used in a Web page to identify custom controls." - this DLL is referenced by Windows desktop apps.
I created a binary log and examined it with the MSBuild Structured Log Viewer, but didn't gain any more information ( I don't see any obvious cause, but I am also not looking with a trained eye):

There is an issue related to TagPrefixAttribute and migrating to .NET Core on StackOverflow, but the problem was obvious (they were referencing code that used libraries/methods not available in Core). I don't *believe* I am given that I ran the [The .NET Portability Analyzer](https://docs.microsoft.com/en-us/dotnet/standard/analyzers/portability-analyzer) and it reported 98.67% compatibility, and none of the incompatible types were in System.Web.
[How to fix error MC1000 Unknown build error, 'Could not find type 'System.Web.UI.TagPrefixAttribute'](https://stackoverflow.com/questions/60512973/how-to-fix-error-mc1000unknown-build-error-could-not-find-type-system-web-ui)
I've been putting off this much-needed push to .NET Core and would appreciate any help!
Contributor guide
Assessment
This issue has not been assessed yet.