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

False-positive errors in XAML preview when Windows is not selected as target #8774

Closed
sigmarsson opened this issue May 14, 2022 · 18 comments · Fixed by #13376
Closed

False-positive errors in XAML preview when Windows is not selected as target #8774

sigmarsson opened this issue May 14, 2022 · 18 comments · Fixed by #13376
Labels
area/vswin Categorizes an issue or PR as relevant to Visual Studio for Windows difficulty/challenging 🤯 Categorizes an issue for which the difficulty level is reachable with internals understanding kind/bug Something isn't working kind/papercut Issue that is especially relevant to users beginning to use Uno

Comments

@sigmarsson
Copy link

Current behavior

  1. Created a page for tab navigation.
  2. Set Page Background as Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
  3. Encountering a compilation error on Wasm as

image

Expected behavior

It ought to work like on Windows Desktop.

How to reproduce it (as minimally and precisely as possible)

No response

Workaround

No response

Works on UWP/WinUI

Yes

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia, Uno.UI.RemoteControl / Uno.WinUI.RemoteControl

NuGet package version(s)

    <ItemGroup>
      <PackageReference Include="DryIoc.dll" Version="4.8.8" />
      <PackageReference Include="LiveChartsCore.SkiaSharpView.Uno" Version="2.0.0-beta.220" />
      <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
      <PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
      <PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.3.0" />
      <PackageReference Include="Uno.WinUI.WebAssembly" Version="4.2.6" />
      <PackageReference Include="Uno.WinUI.RemoteControl" Version="4.2.6" Condition="'$(Configuration)'=='Debug'" />
      <PackageReference Include="Uno.Wasm.Bootstrap" Version="3.3.1" />
      <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="3.3.1" />
    </ItemGroup>

Affected platforms

WebAssembly

IDE

No response

IDE version

Version 17.2.0

Relevant plugins

No response

Anything else we need to know?

No response

@sigmarsson sigmarsson added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels May 14, 2022
@jeromelaban
Copy link
Member

Note that the repro cannot work, since LiveChartsCore.SkiaSharpView.Uno references Uno.UI, not Uno.WinUI. LiveCharts can't yet be updated until mono/SkiaSharp#1787 is fixed.

Make sure to validate with Uno.UI first.

@jeromelaban jeromelaban added the triage/needs-information Indicates an issue needs more information in order to work on it. label May 16, 2022
@jeromelaban jeromelaban removed the triage/untriaged Indicates an issue requires triaging or verification label Dec 2, 2022
@fsol11
Copy link

fsol11 commented Jan 12, 2023

This happens for me as well. The project compiles. It is an Intellisense error only. Looks like there are some issues in Uno libraries that make Intellisense not work correctly. Lots of this type of errors happen.

@jeromelaban
Copy link
Member

@lotrasoft that's correct, it's a Visual Studio issue that we've working with Microsoft to improve. If you select the Windows project in the top left selector in the XAML editor, this error should go away.

@fsol11
Copy link

fsol11 commented Jan 12, 2023

Thanks, but there is no selector on XAML editor:

image

@jeromelaban
Copy link
Member

This is curious. Where is the file located in your solution? In which project, specifically?

@fsol11
Copy link

fsol11 commented Jan 12, 2023

@jeromelaban The Xaml file is located in the Shared project. And note that the WYSIWYG editor for XAML is also not available.

@jeromelaban
Copy link
Member

It is expected that the designer is not available microsoft/microsoft-ui-xaml#5917, but the curious part is the missing top level bar. Can you try closing all the editor files, then close visual studio, then reopen the solution?

@fsol11
Copy link

fsol11 commented Jan 12, 2023

I have done that 10000 times. Does not help. Note that with Uno, a few internal components of Visual Studio crash. Here is an example (look at the brown bars):

image

@jeromelaban
Copy link
Member

Thanks for the update. Two things:

  • Can you try unloading all projects except the shared project and the windows project and see if it helps?
  • Can you attach here the two "Show stack trace" in blue that VS is showing at the top?

@fsol11
Copy link

fsol11 commented Jan 12, 2023

I just installed Visual Studio update 17.4.4, and looks like the problem has been solved. The XAML toolbar now shows up and the ThemeResource error is gone.

image

@muhammetozeski
Copy link

I have same error.
image
Mostly same with lotrasoft but my vs is that "Microsoft Visual Studio Community 2022 (64-bit) - Preview
Version 17.5.0 Preview 3.0"
Using libraries are like this:
image

@jeromelaban
Copy link
Member

@muhammet484 make sure to select the .Windows project in the top left selector.

@muhammetozeski
Copy link

muhammetozeski commented Jan 23, 2023

@muhammet484 make sure to select the .Windows project in the top left selector.

do you mean this? I selected the windows already
image
you can also check my screen:
image

@jeromelaban
Copy link
Member

@muhammet484 this selector, specifically:
image

@muhammetozeski
Copy link

thanks it solved the problem.

@dallyh
Copy link

dallyh commented Jun 25, 2023

@muhammet484 this selector, specifically: image

I would like to address this issue a little more. Let's say I'd like to build apps only for mobile platforms (Android/iOS) because I'm not interested in developing an app for other platforms. When I generate a new project from template using custom settings (just Android and iOS or just one of them as platforms), then this workaround doesn't work, because i cannot select "Windows" nor "UWP" from the projects dropdown. Is there anything known I can do with this? Every issue I've found pointed me to selecting "Windows" from the dropdown menu, which works if I generate a project also targetting that platform.

image
image

@MartinZikmund
Copy link
Member

@dallyh This is unfortunately true, we are using built-in XAML intellisense provided by Microsoft, which is only compatible with the Windows target. this causes the underlines in other cases. We were able to avoid these problems by implementing a custom IntelliSense provider in Visual Studio Code, but on VS 2022 this is a much more complex task. For now the recommendation is to include the Windows project there even if it is not going to be used as a production environment - it is useful for IntelliSense and even debugging.

@MartinZikmund MartinZikmund removed triage/needs-information Indicates an issue needs more information in order to work on it. difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Jul 25, 2023
@MartinZikmund MartinZikmund added area/vswin Categorizes an issue or PR as relevant to Visual Studio for Windows difficulty/challenging 🤯 Categorizes an issue for which the difficulty level is reachable with internals understanding kind/papercut Issue that is especially relevant to users beginning to use Uno labels Jul 25, 2023
@MartinZikmund MartinZikmund changed the title The type 'ThemeResource' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built False-positive errors in XAML preview when Windows is not selected as target Jul 25, 2023
@MartinZikmund
Copy link
Member

It would be useful if we could automatically detect that non-Windows target is selected when a .xaml file is opened and switch it for the user, but it does not resolve the situation when the Windows target is not selected in the Wizard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vswin Categorizes an issue or PR as relevant to Visual Studio for Windows difficulty/challenging 🤯 Categorizes an issue for which the difficulty level is reachable with internals understanding kind/bug Something isn't working kind/papercut Issue that is especially relevant to users beginning to use Uno
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants