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

.net 5 trimming causes crash on copying text #3903

Open
CarbonNeuron opened this issue Dec 11, 2020 · 13 comments
Open

.net 5 trimming causes crash on copying text #3903

CarbonNeuron opened this issue Dec 11, 2020 · 13 comments
Labels
Bug Product bug (most likely)
Milestone

Comments

@CarbonNeuron
Copy link

  • .NET Core Version: 5.0.101
  • Windows version: 20H2
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: No
  • Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No
  • Security issues and bugs should be reported privately, learn more via our responsible disclosure guidelines.

Problem description: I am building a self-contained trimmed publish release of a project using .net 5, and using trimming. If you try to copy from the Text boxes in the GUI it will crash. This only happens with trimming.

Actual behavior:
Faulting application name: TestWPF.exe, version: 1.0.0.0, time stamp: 0x5fbf1139 Faulting module name: ntdll.dll, version: 10.0.19041.662, time stamp: 0x5f641e44 Exception code: 0xc0000409 Fault offset: 0x00087160 Faulting process id: 0x342c Faulting application start time: 0x01d6cfff6daa978a Faulting application path: C:\Users\Carbon\source\repos\TestWPF\TestWPF\bin\Release\net5.0-windows\publish\TestWPF.exe Faulting module path: C:\Windows\SYSTEM32\ntdll.dll Report Id: e5c5c421-412f-4a5f-aa52-d412120410da Faulting package full name: Faulting package-relative application ID:

Expected behavior: it copies the text to clipboard.

Minimal repro: https://github.com/CarbonNeuron/WPFCopyCrash make sure to run the published file and not the debug one.

@daisyTian0517
Copy link

I checked your .csproj file and add <PublishTrimmed>true</PublishTrimmed> to PropertyGroup, then published the app refer to the steps in Publish a single file app - Visual Studio. There is no problem for copies of the text to clipboard or copies of the text from clipboard with trimming.

@CarbonNeuron
Copy link
Author

CarbonNeuron commented Dec 15, 2020

But there is already publish trimmed in the publish profile.
Could you please fork my repo and show the changes you made?

@daisyTian0517
Copy link

daisyTian0517 commented Dec 15, 2020

I didn't see <PublishTrimmed>true</PublishTrimmed> in your csproj and update csproj as below:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net5.0-windows</TargetFramework> <UseWPF>true</UseWPF> <TrimMode>link</TrimMode> <PublishTrimmed>true</PublishTrimmed> <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract> </PropertyGroup> <ItemGroup> <TrimmerRootAssembly Include="System.Runtime" /> <TrimmerRootAssembly Include="System.Runtime.Extensions" /> </ItemGroup> </Project>

CarbonNeuron added a commit to CarbonNeuron/WPFCopyCrash that referenced this issue Dec 15, 2020
@CarbonNeuron
Copy link
Author

I have updated my repo to show the code you have shown. After publishing and running the file it has the same issue.

@CarbonNeuron
Copy link
Author

TestWPF.zip
This is the assembly that is built when trimming. Please upload your assembly if it works.

@daisyTian0517
Copy link

Did you clean and rebuild your project after the update?Did you try to publish your project in other device?By the way, my visual studio version is 16.8.1.Here is my file.

@CarbonNeuron
Copy link
Author

CarbonNeuron commented Dec 15, 2020

Your file is 142MB, which is not trimmed. My file is 70MB. Make sure you are using the publish profile and not just building.

But yes, if you don't trim, it will work fine. But this is not the issue.

@daisyTian0517
Copy link

I get the exe in the publish folder like below shown,please point out if I misunderstand.
Capture

@CarbonNeuron
Copy link
Author

The csproj does not matter. Make sure you are publishing it using the publish profile. You should get console output while building that says you are trimming. And it should take abnormally long to "build"

@daisyTian0517
Copy link

The Member-Level Trimming part points out: Member-level trimming(<TrimMode>Link</TrimMode>) has more risk than assembly level trimming, and so is being released as an experimental feature, that is not yet ready for mainstream adoption.

@CarbonNeuron
Copy link
Author

While true, should we not still report these bugs somewhere?

@ryalanms
Copy link
Member

ryalanms commented Jan 4, 2021

@CarbonNeuron: Thank you for the report. WPF has not done any work to support trimming yet.

Please continue reporting any issues. All of this feedback is taken in to account during planning for the next release.

@ryalanms ryalanms added this to the Future milestone Jan 7, 2021
@ryalanms ryalanms added the Bug Product bug (most likely) label Jan 7, 2021
@ThomasGoulet73
Copy link
Contributor

I just reproduced this error in .Net 5.0.3. This only occurs with <TrimMode>Link</TrimMode>.

I fixed it by including <TrimmerRootAssembly Include="System.Runtime.InteropServices" /> in my csproj.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Product bug (most likely)
Projects
None yet
Development

No branches or pull requests

4 participants