You just build a multi target library.
https://learn.microsoft.com/en-us/nuget/create-packages/multiple-target-frameworks-project-file
note: I think it’s a poor design for the library to know about calling back to the ui thread.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In WPF, in a class library, I use the Windows.Application.Current.Dispatcher.Invoke method to reference the window that contains the controls and my class.
To use this method, I added the PresentationFramework.dll and WindowsBase.dll references to the project.
It works perfectly.
The only problem, since these dlls are referenced to a folder related to the .net version, if I change the .net version, I have to change the dll references again.
Here is an example of the dlls folder for version .net 7.0.10 :
C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\7.0.10\ref\net7.0\PresentationFramework.dll.
Is there a solution to avoid this problem?
Is there another method in wpf to not use these dlls?
You just build a multi target library.
https://learn.microsoft.com/en-us/nuget/create-packages/multiple-target-frameworks-project-file
note: I think it’s a poor design for the library to know about calling back to the ui thread.