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

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

Open
1 of 4 tasks
astuy opened this issue Feb 21, 2025 · 1 comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior

Comments

@astuy
Copy link

astuy commented Feb 21, 2025

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

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
  • 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

@astuy astuy added the bug 🐛 An unexpected issue that highlights incorrect behavior label Feb 21, 2025
@astuy
Copy link
Author

astuy commented Feb 21, 2025

If have digged a bit deeper and created also my own library referencing System.ComponentModel.Annotations. Please see attached solution:

  • You can switch the executed command in AppWithPlugin \ Properties \ launchSettings.json \ commandLineArgs. Valid values are annotate and community.
  • Building AnnotationReference with TargetFramework net48 everything works fine. Building AnnotationReference with TargetFramework netstandard2.0 triggers the FileNotFoundException.

AppWithPlugin.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior
Projects
None yet
Development

No branches or pull requests

1 participant