-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
System.Windows.Markup.XamlParseException in System.Runtime when published trimmed #4321
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
@danmoseley Why has this been moved to WPF repo? The WPF team has nothing to do with the trimming feature and the issue is that the trimming feature has removed assemblies it shouldn't. It should get reviewed by the developers who are responsible for the logic of the trimming feature |
My assumption was that this was due to WPF assemblies not supporting trimming because they have not been annotated ie they have linker warnings. @eerhardt thoughts? |
Here is the target I use to configure trimming in my WPF application:
You can copy/paste it in your main csproj and if you still have an exception, you can add the trimmed assembly in the condition using |
@danmoseley If I understood the trimming correctly, the WPF assemblies are not trimmed but the assemblies from the BCL can be trimmed. That's why the exception is for an assembly from the BCL. |
See my comment below |
Many of the dlls in your screenshot are only facades, they do not actually contain code. The code is in other assemblies, mostly System.Private.CoreLib. You can see it for yourself by peeking inside the content of a trimmed dll with a decompiler like dotPeek. |
I don't think it's officially supported (See the "in preview" part in the publish profile), though a WPF or .Net team member can correct me. I can say that I didn't really have any problem with trimming except for the target that I posted. Also, I think there is an effort to annotate the BCL and frameworks like WPF for trimming in .Net 6. See #3811. These annotations can help the linker see what is not required, even with reflection. Edit: I had success using MVVM, Bindings, Reflection, File IO and async Code using the linker. Even with |
I was wrong, I apologize. After adding your code the trimmed applications works perfectly fine (as far as I can tell). So yes there is a problem with detecting these 3(?) assemblies in the trimming logic only. |
This is a bug in the trimming tool. These assemblies should not be trimmed. I believe this issue should be moved to the https://github.com/mono/linker/ repo. Another interesting fact is that if you upgrade to
|
This issue was moved to dotnet/linker#1917 |
Description
Publishing a WPF application using the trim unused assemblies option (VS -> Build dialog) throws a System.Windows.Markup.XamlParseException on start of the application. Publishing untrimmed works fine.
Configuration
Other information
The trim feature has removed the following files, several of them sounds pretty much mandatory for EVERY app to me and shouldn't be trimmed:
The text was updated successfully, but these errors were encountered: