Azure Function Targeting .NET Standard Showing Warning - asp.net-core

Just installed Visual Studio 15.5 Preview so that I can create an Azure Function targeting .NET Core. Without making any changes, I'm seeing a warning -- see below -- that reads:
Package Microsoft.AspNet.WebApi.Client 5.2.2 was restored using .NET
Framework version 4.6.1 instead of the project target framework .NET
Standard version 2.0. This package may not be fully compatible with
your project.
Any idea how to fix this or do I ignore this warning? As I said, this is a brand new Azure Function project I created with no changes at all.
Here's what the warning looks like:

You can pretty much ignore it, in this case.
Microsoft.AspNet.WebApi.Client targets "Portable Class Library (.NETFramework 4.5, Windows 0.0, WindowsPhone 8.0, WindowsPhone 8.1, WindowsPhoneApp 8.1)" (or net45+win8+win81 as it's the target framework moniker called), which means it's fully compatible with .NET Core and .NET Standard (>= 1.2).
The warning comes, because it do not target the netstandard1.x or netstandard2.x moniker specifically. It just tell you "this might not be compatible on .NET Core/.NET Standard".

Yes, you did nothing wrong: this is to be expected for now. Functions v2 are in beta now, so you'd have to live with this warning for a while. It should give you no functional issues.

Related

Is .NET 6 backwards compatible with applications developed with a target Framework of .NET Core 3.1

I've found loads of pages referencing this topic but none are clear or conclusive hence this question.
If I install a c# application built with a target Framework of .Net Core 3.1 onto a server which contains just .NET 6, will it still run without any changes?
If I upgrade the version of .NET on a Windows server from .Net Core 3.1 to .Net 6, will the applications already on that server, built with a target Framework of .Net Core 3.1, still run OK?
Thanks
Not necessarily - there are many breaking changes on every major release.
Those for .NET 5->6 are published here here. For .NET Core 3.1 -> .NET 5 see here.
Note also the distinction between binary incompatible and source incompatible
Binary incompatible - Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, or different run-time behavior.
Source incompatible - Source code may encounter a breaking change in behavior when targeting the new runtime or using the new SDK or
component. Behavior changes can include compile errors or different
run-time behavior.

How can I use VS2019 Files in VS2022 and vice versa?

In my school they use VS 2019. I installed the same because that was what was available at the time (community version for me, I think the same for my school).
I had a couple of issues with VS2019 so I uninstalled everything and installed 2022 version instead. I then began to use this for the last 2 weeks but when I tried to open my old files, I couldn't.
I did install framework 3.1 again and the code will enter runtime successfully, but I still can't see the code that I wrote. I don't want to re-install VS2019 because it kept on giving me issues with intellisense which I just couldn't fix.
Is there any way I will be able to open my old 2019 files in 2022? Also, will 2019 be able to open 2022 files?
The generic answer to this is mostly yes but maybe no depending on your specifics. That's not a helpful sentence, so let me explain.
For the most part, Visual Studio solutions and projects are cross-compatible1. This means that if you have a project from one version, you can usually open it in another version without issue. The major caveat to this is the range of frameworks supported by each VS version may be different. VS will often be able to open the project, but might not be able to build and run it.
(Because you tagged this with vb.net, I'm limiting this to .NET versions. The same concepts may apply for other platforms.)
For example, VS2019 supports:
.NET version 5 (Visual Studio 16.8 or later)
.NET Framework versions 4.8, 4.7.2, 4.7.1, 4.7, 4.6.2, 4.6.1, 4.6, 4.5.2, 4.5.1, 4.5, and 4.0
.NET Core 3.1, 3.0, 2.2, 2.1, and 1.1.
And VS2022 supports:
.NET Framework versions 4.8, 4.7.2, 4.7.1, 4.7, and 4.6.2
.NET Core 6.0 Preview, 5.0, 3.1, 3.0, 2.2, and 2.1.
Note how VS2022:
DOES NOT support .NET Framework versions 4.0-4.6.1, or .NET Core 1.1
DOES support .NET (Core) 6.0 - which VS2019 does not
It is reasonable to expect that the next version of VS will stop supporting some versions while it adds support for new ones again, so this compatibility range will change with each VS release.
1: Each different type of project requires a Project System to support it. Occasionally, these may be dropped out of support like with the frameworks described above, but with the more severe consequence that VS will not be able to open the project at all. Some examples over time: Silverlight and Windows Phone projects, Setup projects, DNX (early .NET Core) projects, etc.

Portable F# library references .NET 4.5 (but not 4.0)

I'm trying to create portable F# library but it needs to target .NET 4.0 (company policy is that all portable libraries need to be compatible with Windows XP).
When I create (Visual Studio 2013) new project there is an option "Portable Library (Legacy)" with description saying "A project for creating an F# library (.dll) that can run on .NET Framework 4.0 and higher, Windows Store and Silverlight 5".
The problem is, when the project is actually created. When I go to project's properties "Target Framework" is set to ".NET Portable Subset (.NET Framework 4.5, Silverlight 5, Windows 8)".
I tried changing F# runtime version from 3.1 to 3.0 but it does not change anything. "3.0" and "3.1" are the only options. What happened to "2.0"?
Am I missing something?
EDIT: It seems like Grzegorz is right. I've created this F# PCL which is saying ".NET 4.5" and referenced it from .NET 4.0 C# application. No problems were reported.
Then, to be sure, I also referenced it from 3.5 application and... no problems were reported during compilation either, but it was crashing on runtime. So to be sure, I ran the "potentially 4.0" application on XP and it worked, which may be interpreted as: "Yes, F# PCL does not depend on 4.5 even it it says so".
Make it an answer so I can tick it.
The template file for "Portable Library (Legacy)" has TargetFrameworkVersion hardcoded as v4.0. If You'll create a project with this template it'll in fact target 4.0 version.
Probably, there's a bug in UI that keeps displaying target framework as 4.5 while in reality it uses previous one.
To be strict, the issue is related to legacy Portable Library. The non-legacy version seems to work correctly in forcing framework to be in 4.5 version.
update:
I submitted an issue about this to Visual F# Tools team:
https://visualfsharp.codeplex.com/workitem/95

'Forms' is not a member of 'Windows'

I tried to change the Target Framework on my app recently from .NET Framework 4.5 to 4.5.2, but if I do I get the following error when trying to build: "'Forms' is not a member of 'Windows'" (that is, System.Windows.Forms). Changing to 4.5.1 works normally. I'm using Visual Studio 2013 Ultimate.
I had this error when changing to 4.5.2.
In my case the error was related to a MessageBox ... I replaced: "Windows.Forms.DialogResult.Yes" (which caused the same error message) with "System.Windows.Forms.DialogResult.Yes" which did the trick.
I had the same problem, me too with Windows.Forms.DialogResult enumeration values.
The project automatically imports System and System.Windows.Forms namespaces and worked fine up to 4.5.1.
In 4.5.2 I had to remove Windows.Forms. and just leave DialogResult.Ok (or whatever else) in my code, it seems to be a problem with namespaces resolution.
Make sure that you add System in front of the Windows.Form.
I ran into this with an application still targeted to .NET 4.0, where it failed on one (new) build server, but ran on my older ones.
I narrowed it down to the .NET 4.0 Targeting Pack only being installed on the old build servers. Targeting pack is included in Visual Studio, or the Windows 7.1 SDK. It is for some reason not distributed separately, and with support ending for .NET 4, 4.5 and 4.5.1, I don't suspect this is likely to change. Because my older servers have been around a couple years, they've gone through in-place upgrades and so had the targeting pack already.
When you install Windows 7.1 SDK on Server 2012R2, it complains something to the effect of "A pre-release version of .NET 4 is installed, please install the RTM version". As far as I can tell, it's simply because a newer version) is installed -- Server 2012R2 comes with 4.5.1. I tried to uninstall all newer versions, but was unable to get the SDK to install the targeting pack.
So to install:
Download the Windows 7.1 SDK ISO image
Unzip it
Run Setup\MTPack\netfx_dtp.msi EXTUI=1
You should now have a %programfiles(x86)%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\ folder with the 4.0 stuff.
(EXTUI=1 bypasses the restriction that it can't be installed separately).
This allowed me to compile projects still targeting 4.0 (or re-build old revisions/branches that were targeting it at the time).

TryParse is not a member of System.Enum error in VB.NET

I checked out http://msdn.microsoft.com/en-us/library/dd783499.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1. It should exist.
EDIT:
I tried it on vs2010 (different project, though), and it exists.
Enum.TryParse was added with .Net Framework 4.0.
You can easily tell this by looking at the Other Versions drop down menu in the documentation or the version Information:
.NET Framework
Supported in: 4.5, 4
.NET Framework Client Profile
Supported in: 4
Portable Class Library
Supported in: Portable Class Library
.NET for Windows Store apps
Supported in: Windows 8
So probably you're using an older .Net Framework version.
Do you have System Import?
Imports System
If you are in Visual Studio 2010, make sure you are targeting .NET Framework 4.0