Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with WPF? #4

Open
jamesc-skyward opened this issue Nov 8, 2022 · 5 comments
Open

Issues with WPF? #4

jamesc-skyward opened this issue Nov 8, 2022 · 5 comments

Comments

@jamesc-skyward
Copy link

I have some Visual Studio extensions currently using WinForms for their UI. I was looking at changing them over to use WPF, but simply adding a WPF control to my project prevents it from building. I get errors that say The name 'VSCommandTable' does not exist in the current context and The name 'Vsix' does not exist in the current context. I tried some workarounds I found on GitHub, but they weren't working for me. I did come across this message where @reduckted seems to mention a similar issue: madskristensen/MarkdownEditor2022#10 (comment)

Is this a known issue? Or is there something I need to do to get the source generators working alongside WPF?

@jamesc-skyward
Copy link
Author

Huh. It seems to work fine if I add a window using the Extensibility Template Pack.

@reduckted
Copy link
Collaborator

I can reproduce this, but adding a window from the Extensibility Template Pack didn't fix it. Maybe there was something else that you changed in the project file?

I'm going to reopen this and see if we can find a solution.

@reduckted reduckted reopened this Nov 17, 2022
@jamesc-skyward
Copy link
Author

I can reproduce this, but adding a window from the Extensibility Template Pack didn't fix it. Maybe there was something else that you changed in the project file?

I'm going to reopen this and see if we can find a solution.

Nope. I changed nothing else. I just have an existing project I'm working with. When I add a new item, if I select "User Control (WPF)" it won't build. I can select "Async Tool Window (Community)" or "Dialog Window (Community)" and everything works fine. No other changes.

I played around with this a bit and I found a way to fix the issue, for me at least. The xaml file that gets created when adding a new WPF User Control has the line xmlns:local="clr-namespace:{Namespace.To.Xaml}". If I remove that line (VS tells me it's unnecessary), everything builds as expected.

@jamesc-skyward
Copy link
Author

Oh. I should clarify that adding a window with the Extensibility Template Pack doesn't fix things the "bad" one. I'm deleting the "bad" one and then adding a new one from the Extensibility Template Pack. If I have both side-by-side it won't compile.

@jamesc-skyward
Copy link
Author

So after avoiding using clr-namespace in my projects, I started looking into this a bit more. I found https://github.com/reduckted/ProjectFilter where the source generator and WPF are working together. Looking at the differences between my project and that one, I found it has something to do with the .csproj file. The ProjectFilter extension is using the newer SDK csproj format, and when I converted mine over it started working. So either there's something in the old .csproj breaking things that I wiped out in the conversion, or something in the new format itself is fixing things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants