InitializeComponent() does not exist - multi-targeted project (4.6.1 & 5)

Viewed 123

I have a v4.6.1 class library project that contains some XAML functionality including some user controls. I've converted this project to .Net 5 then modified it to target both frameworks like so:

<TargetFrameworks>net5.0-windows;net461</TargetFrameworks>

The project nearly builds, apart from two XAML user controls that throw up the following error:

The name 'InitializeComponent' does not exist in the current context

For some reason it's only affecting target framework "net461", but I'm struggling to solve this one. Any thoughts? It's not the usual suspects (BuildAction is "Page", same namespace in XAML and code-behind) as I see the problem when I add a new XAML user control to the project.

enter image description here

0 Answers
Related