WPF - Using Windows Media Import - c#

I am trying to use the Windows Media Import API in a WPF Application I have added a reference to the Windows Runtime but still failing to get it to run. Any ideas what the missing references may be?

Your .csproj is targeting an ancient and unsupported version of .NET Framework, specifically: .NET Framework 4.0 which dates back to 2010, which is before the IReadOnly...<T> collection interface types were added to .NET in .NET Framework 4.5 in 2012.
As it's 2021, you should now be targeting either .NET Framework 4.8 - or .NET 5. As porting to .NET 5 is a large undertaking, just update to .NET 4.8:
So change this:
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
to this:
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>

Related

Project '..' targets 'net5.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.7.2'

I created my initial project that targets Framework version v4.7.2. I needed to add a class library in my project using visual studio 2022 Community. While doing so, VS2022 gave me only 4 options to choose from for setting Target Framework (.Net Standard 2.0, .Net Standard 1.0, .Net 5.0, .Net 6.0). This feature isn't there in VS2019 Community. I selected .NET 5.0
Now this class library cannot be referenced by my initial project. I think I need to update .NET Core SDK but don't know which version (if I am correct in my assumption).
Please help. Thanks
You should add a class library, which is supported .NET Framework.
In the one project, all classes are the same target output (.NET Core or .NET Framework)
Referred project and reference project are the same target output.
My case:
I created Winform Application(.NET Core), then add Junit Project(.NET Framework) referring to Winform Application and they are conflict due to different target.
My Solution:
I changed Winform Application from .NET Core to .NET Framework and they are working.
Hope to help you!!!

Visual State Manager in WPF not supported

I am creating an app which needs to use the Visual State Manager, but when I want to use it, I get the following error:
Visual State Manager is not supported in a WPF application.
I tried to use the code snippet from this question: VisualStateManager is not supported in a WPF project, but then it says, that the Visual State Manager is not in the namespace of System.Windows.
I am using .NET Framework 3.5 to use the app on Windows 7 as well...
Does somebody have an idea how to solve this?
Thanks!
If you want to use the VisualStateManager class in your WPF application, you must target the .NET Framework 4.0 or later.
Since the .NET Framework versions 4.5.2, 4.6, and 4.6.1 will reach end of support on April 26, 2022 and versions between 4.0 and 4.5.1 are already out of official support, any new application that you develop should target .NET Framework 4.6.2 or later.
.NET Framework 4.6.2 and later versions are fully compatible with Windows 7 SP1.

Upgrade from .NET 4.0 to .NET 4.7

We have some legacy apps (ASP.NET) that have been targeting the .NET 4 framework, which is out of support. Looking at some articles https://learn.microsoft.com/en-us/lifecycle/faq/dotnet-framework, it basically says we don't need to recompile our apps to target the newer version of the framework.
How do I make sure that our apps are running with the latest (.NET 4.7) framework?
Thanks.

Will .Net MAUI be comptabile with .NET Standard 2.0?

We currently just started to write class libraries in .NET Standard so we can use this for WPF, Winforms and .Net Core with Ubuntu Server (but then without GUI). .Net 5 does not support Winforms or WPF for our .NET 4.6.x applications.
My question is, will .NET MAUI be compatible with .NET Standard 2.0 class libraries?
When I look at the .NET Standard website its says compatibility with .NET 6.0, but I can't find if that also the .NET MAUI framework.
https://dotnet.microsoft.com/platform/dotnet-standard#versions
My question is, will .NET MAUI be compatible with .NET Standard 2.0 class libraries?
Yes, because, as it was mentioned in comments, .NET MAUI is just a library. You don't compile with MAUI, but rather with .NET 6.
All .NET Core versions starting from 2.0 can reference .NET Standard 2.0 libraries, and since .NET 6 is just a rename of what would be .NET Core 5, that is certainly possible.
The problem, however, is here:
We currently just started to write class libraries in .NET Standard so we can use this for WPF, Winforms and .Net Core with Ubuntu Server. .Net 5 does not support Winforms or WPF.
You can't use WPF nor Winforms in Linux/MacOS. You also can't use .NET MAUI in Linux as there is (currently) no target for that environment. The desktop environments supported are the same as for Xamarin: Windows and MacOS.
Notice that it was mentioned here that support for Linux is being considered for .NET 7, which should be released in around a year.

Are .NET Core projects referencing PCLs cross-platform?

I have a .NET Core (ASP.NET Core) project created using Visual Studio 2017 RC (MSBuild).
I also have an old F# project library (traditional .NET Framework Library) that compiles to a dll file. I want to use it in said ASP.NET Core project.
To do that, I added a project reference in the ASP.NET Core project, opened the namespace, and made a few function calls in my controllers; it works perfectly when running the ASP.NET Core server using ISS from VS.
My question is, will this arrangement work if I want to deploy to linux (Ubuntu)? Or does using external PCLs/dlls from .NET Core instantly make it windows-only?
Note that I didn't have to add .NET Framework as a target framework in my csproj (it's MSBuild Core), it just worked.
Since your F# project targets the .NET Framework it will not run cross platform. If you modify your F# project to target the .NET Standard library it will. Here is a video by Immo Landwerth explaining how the .NET Standard Library works.
You should be able to just to reference the .NET standard library and not have to change anything. However the current version, which is 1.6, is missing a lot of API's from .NET Framework. This is fixed in 2.0. Infact since your using .NET Core 1.1 I think you are already using 2.0, but I'm not certain. Here is another video by Immo explaining how it should work.
That being said, I'm not sure what the F# support is like with .NET Standard.

Categories