dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.08k stars 1.17k forks source link

WPF app crashes with KeyNotFoundException #2152

Closed DenSmoke closed 4 years ago

DenSmoke commented 5 years ago
vatsan-madhavan commented 5 years ago

@DenSmoke Do you have a crash-dump or a self-contained repro we can take a look at?

DenSmoke commented 5 years ago

@vatsan-madhavan Unfortunately I can't catch these crashes. I only get error reports from clients sometimes. I kept app running for 2 days with debugger but error didn't occur. I suspect app crashes with that exception on Windows 7 machines. I can't post code because of an NDA and can't create repro code because I don't know what causes it. But I can say that app uses no-codebehind design and almost every thing is written in XAML by a lot of Styles, DataTemplates, ControlTemplates.

If only I could get information what page or window gets this exception...

mgnslndh commented 5 years ago

I've had this crash on my app as well. This was on .NET Framework 4.7.2. I also compared the source code of .NET 4.7.2 and 4.8 and found the Contains check in .NET 4.8. I've upgraded my app so it is no longer a problem.

As far as why the key was missing I do not know. The app i'm writing is using touch (and tabtip.exe) other than that no UI automation is used.

https://stackoverflow.com/questions/58656290/how-can-itempeersstorage-throw-exception-when-getting-value-from-weakdictionary

DenSmoke commented 5 years ago

@vatsan-madhavan I remembered that app uses Microsoft.Maps.MapControl.WPF package which uses .NET Framework 4.0. I suppose this package uses .NET Framework installed on client's PC. So that's why error is more distributed among Win7 users because they don't have .NET Framework 4.8 by default. Is my assumption true?

DenSmoke commented 4 years ago

It seems my recommendation for clients to upgrade .NET Framework to 4.8 on their PCs resolved this problem