CommunityToolkit / CommunityToolkit/dotnet

'Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0' in plugin environment (.NET Framework)

Open
#1,050 1 comment 0 reactions 0 assignees View on GitHub
bug :bug:
Dominant language
C#
Stars
3.8k
Forks
400
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

Using `ObservableValidator` in a .NET Framework application plugin leads to `System.IO.FileNotFoundException`: Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

The referenced System.ComponentModel.Annotations 5.0.0 package brings System.ComponentModel.Annotations 4.6.26515.6 dll.
But CommunityToolkit.Mvvm 8.4.0 dll references System.ComponentModel.Annotations 4.2 dll.

### Regression

_No response_

### Steps to reproduce

Please see attached minimal repro. Build solution and run _AppWithPlugin_.

[AppWithPlugin.zip](https://github.com/user-attachments/files/18905292/AppWithPlugin.zip)

### Expected behavior

System.ComponentModel.Annotations should be resolved.

### Screenshots

_No response_

### IDE and version

VS 2022

### IDE version

17.12.5

### Nuget packages

- [ ] CommunityToolkit.Common
- [ ] CommunityToolkit.Diagnostics
- [ ] CommunityToolkit.HighPerformance
- [x] CommunityToolkit.Mvvm (aka MVVM Toolkit)

### Nuget package version(s)

8.4.0

### Additional context

Why don't you add target framework net472 and reference only the framework provided System.ComponentModel.DataAnnotations and not the annotations nuget package?

### Help us help you

Yes, I'd like to be assigned to work on this item

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.