You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot use source generator code in xaml file #8128
Cannot use generated code from analyzers in xaml file, it reported missing assembly or reference.
Reproduction Steps
Steps
Create a WPF project with .net6.0-windows
Add <IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation> in csproj
Reference Aigamo.ResXGenerator to generate designer file of resx manually.
Add Resources.resx file, remove Custom Tool of it, add HelloWorld key into resx.
Add textblock to use this string in xaml, <TextBlock Text="{x:Static res:Resources.HelloWorld}" />
Build the project
Error
Target CoreCompile:
1> xxx\WpfApp2\WpfApp2\obj\Debug\net6.0-windows\MainWindow.g.cs(34,15,34,25): error CS0234: The type or namespace name 'Properties' does not exist in the namespace 'WpfApp2' (are you missing an assembly reference?)
@ye4241 - I attempted to recreate the problem using the sample application you provided, but I encountered different errors as shown in the image here:
Would you be able to verify if the sample application is functioning as intended while I continue my investigation?
@Kuldeep-MS You may need to remove the default Custom Tool for .resx files in .csproj file, as it might have been accidentally added when reopening the project.
Or just delete below codes to make sure there is no generator of resx file.
Activity
Kuldeep-MS commentedon Aug 28, 2023
@ye4241 - I attempted to recreate the problem using the sample application you provided, but I encountered different errors as shown in the image here:

Would you be able to verify if the sample application is functioning as intended while I continue my investigation?
ye4241 commentedon Aug 28, 2023
@Kuldeep-MS You may need to remove the default Custom Tool for .resx files in .csproj file, as it might have been accidentally added when reopening the project.
Or just delete below codes to make sure there is no generator of resx file.
Errors:
