dotnet / dotnet/wpf

wpf application crashes immediately (System.Windows.Threading.DispatcherObject, WindowsBase)

Open
#5,873 20 comments 0 reactions 1 assignee Claimed by @gurpreet-wpf View on GitHub
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: 3.1.416
* Windows version: Version 20H2 (OS Build 19042.1415)
* Does the bug reproduce also in WPF for .NET Framework 4.8?: n/a



**Problem description:**
when publishing the project the wrong WindowsBase.dll gets copied.


**Actual behavior:**
Application: sds.master.exe
CoreCLR Version: 4.700.21.56803
.NET Core Version: 3.1.22
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeLoadException: Could not load type 'System.Windows.Threading.DispatcherObject' from assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

**Expected behavior:**
The wpf application should not crash.

**Minimal repro:**
1. create new solution
2. add wpf project
3. add asp.net core project or class library
4. publish project: dotnet publish -o --self-contained true -r win10-x64 --force
5. start the wpf application -> crash
![Capture](https://user-images.githubusercontent.com/43644640/147262124-6ed29237-9c63-4333-b12e-d277182b6b5a.JPG)

**NOTE**
With NET Core Version 3.0.100 everything is working as expected.

[WpfApp2.zip](https://github.com/dotnet/wpf/files/7781027/WpfApp2.zip)

JSON ZIP:
[json.zip](https://github.com/dotnet/wpf/files/7814305/json.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.