"Unable to resolve type" for simple UserControl #16049
-
I'm working on my first big Avalonia project, attempting to convert a small WPF app. Had some success, then brought in some more user controls and started getting dozens of errors, most of them understandable given how Avalonia does things a little differently and I had yet to switch to the new way in many places. I decided to see if I could create a whole new user control using Visual Studio 2022's "add new item" feature, instead of porting one in from the WPF app, and I made some changes to initialize it more like the other successful UCs. But like the failing ones, it gives me "Unable to resolve type MyProject.Views.TestUserControl", even though there's hardly anything in it:
Code behind:
Additionally, the design preview of every view including MainWindow has an exclamation point in a red circle and "Build Required...Could not find 'C:\Users\Me\source\repos\MyProject\obj\Debug\net8.0\ref\MyProject.dll'. Please build your project to enable previewing and Intellisense." And of course I can't build yet. Any ideas how to solve this? Thanks... |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
What new item did you add? Avalonia UC or WPF UC? |
Beta Was this translation helpful? Give feedback.
-
That AvaloniaXamlLoader.Load(this); looks a bit suspect to me. My UserControl derived controls have that replaced with InitializeComponent(); What version of the Avalonia packages are you using? Edit: Actually, also make sure your Visual Studio extension is up to date. |
Beta Was this translation helpful? Give feedback.
-
Well, I upgraded Visual Studio to v17.10.2 and this error pretty much disappeared. I worked through all my other errors (listed one at a time after each build, ugh) and now I have something that runs. Only two of my user controls have "Invalid Markup", one of which says it "Cannot find an event named PointerEnter on type StackPanel" for my EventTriggerBehavior, where my WPF app could have an EventTrigger with EventName="MouseEnter". The other control has the same error, probably because it's the parent control. New discussion, I guess... |
Beta Was this translation helpful? Give feedback.
Well, I upgraded Visual Studio to v17.10.2 and this error pretty much disappeared. I worked through all my other errors (listed one at a time after each build, ugh) and now I have something that runs. Only two of my user controls have "Invalid Markup", one of which says it "Cannot find an event named PointerEnter on type StackPanel" for my EventTriggerBehavior, where my WPF app could have an EventTrigger with EventName="MouseEnter". The other control has the same error, probably because it's the parent control. New discussion, I guess...