-
Notifications
You must be signed in to change notification settings - Fork 127
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 #1917
Comments
Issue moved from dotnet/wpf#4321
From @dotnet-issue-labeler[bot] on Tuesday, March 23, 2021 4:32:31 PM 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. |
Issue moved from dotnet/wpf#4321
From @Symbai on Wednesday, March 24, 2021 8:32:22 AM @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 |
Issue moved from dotnet/wpf#4321
From @danmoseley on Wednesday, March 24, 2021 8:41:04 AM 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? |
Issue moved from dotnet/wpf#4321
From @ThomasGoulet73 on Wednesday, March 24, 2021 12:55:05 PM 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 |
Issue moved from dotnet/wpf#4321
From @ThomasGoulet73 on Wednesday, March 24, 2021 1:04:46 PM @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. |
Issue moved from dotnet/wpf#4321
From @Symbai on Wednesday, March 24, 2021 2:02:31 PM
See my comment below |
Issue moved from dotnet/wpf#4321
From @ThomasGoulet73 on Wednesday, March 24, 2021 2:15:36 PM
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. |
Issue moved from dotnet/wpf#4321
From @ThomasGoulet73 on Wednesday, March 24, 2021 2:20:30 PM
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 dotnet/wpf#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 |
Issue moved from dotnet/wpf#4321
From @Symbai on Wednesday, March 24, 2021 2:28:22 PM 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. |
Issue moved from dotnet/wpf#4321
From @eerhardt on Wednesday, March 24, 2021 3:20:16 PM 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
|
There's a somewhat detailed analysis of what's going on here: dotnet/sdk#14261. The first issue (Sytem.Runtime) there is basically a need to add annotation to WPF code (or better change the pattern so that trimmer can recognize it). The second one (System.Runtime.Extensions) is C++/CLI assembly problem which trimmer has trouble with. See for example #676. There's work being done on this right now. The last one is probably also C++/CLI, but it's unclear yet. |
For the first one, @Symbai I am not are of plans for .NET 6 to add linker annotations to the WPF codebase (of course, you can ask that team who can say for sure). So that part may not get fixed - unless perhaps you are interested in contributing to that work. |
This issue dotnet/wpf#3811 might be related, though I don't think the WPF has confirmed when or if they will do it. Someone from the WPF team self-assigned this issue so maybe they plan on doing it. |
In .NET 6 we added explicit warning that trimming WPF apps is not supported (as described in the above discussion). I know it's not a solution to this issue, but it should at least set the right expectations. |
Issue moved from dotnet/wpf#4321
From @Symbai on Tuesday, March 23, 2021 4:32:28 PM
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: