TryParse is not a member of System.Enum error in VB.NET - 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

Related

How do I use a .NET standard 2.0 library with Framework 4.5?

I have found a library that I would like to use in VB.NET with Framework 4.8.
The github says that is is a .NET 4.5 library, but it also says that it is a .NET Standard 2.0 library.
When I when to import it in my VB.NET Framework 4.5 project, it says:
The package "SimpleWifi.netstandard 2.0.0" could not be installed. You are trying to install this package in a project that references ".NETFramework,version=v4.5", but the package does not contain assembly references or content files that are compatible with this framework. Contact the package creator for more information.
What could I try next?
Thank you!
SimpleWifi is said to be used with .NET Fragmework 4.6 or later.
If you want to install in SimpleWifi .net 4.5, change your project to .net 4.8, install SimpleWifi, and then change 4.5 again. However, other errors may occur.

Azure Function Targeting .NET Standard Showing Warning

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.

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

ASP.NET MVC 4.0 RC and Newsoft.Json

I just installed the ASP.NET MVC 4.0 RC build on top of a Visual Studio 2010 SP1. My project that used to compile and work with the beta version of ASP.NET MVC 4.0, raises an error when I access the site saying that the Newtonsoft.Json assembly version 4.5 can not be found.
As I did not use this third party library in my current project, I configured Fusion Log to try to isolate the assembly that was relying on Newtonsoft.Json assembly.
And the guilty assembly is System.Net.Http.Formatting.dll which references Newtonsoft.Json version 4.5.
The beta build referenced System.Json.dll and not the Newtonsoft assembly.
I can hardly believe that Microsoft is starting to rely on external assemblies even if they publish more and more code in open source.
Does anyone have an explanation of what happened?
They are actually relying in third-party software (just like they ship MVC with JQuery and knockout.js). Scott Guthrie announced that MVC 4 will be shipped with JSON.NET (Newtonsoft). See below:
Json.NET: We plan to use the community developed Json.NET
serialization stack in our default JSON formatter in ASP.NET Web API.
Json.NET provides the flexibility and performance required for a
modern web framework.
http://aspnet.codeplex.com/wikipage?title=ASP.NET%20MVC%204%20RoadMap
You can keep the System.Json.dll btw, I've got them both. If you have any problems with JSON.NET, just reinstall it :)

Is there a portable class library profile which supports System.Xml.Linq and System.Windows for .NET 4.0

I've been working with the Portable Class Libaries using the Visual Studio 11 Beta release.
I've had quite a lot of success getting WP7, Silverlight and .Net 4.5 working together within "Profile104".
However, I've not found a way to get .Net 4 supported within the same or similar profile. In particular, I'm looking for a profile where System.Xml.Linq and System.Windows.Input.ICommand are available?
Is there any way to do this? Either by using a standard profile, or by creating my own profile and then adding type forwarding?
Thanks
Stuart
No, ICommand (as well as INotifyCollectionChanged and ObservableCollection) is not available in a portable library that targets a version of .NET before 4.0. We had to make some changes in .NET to support it (mainly adding System.Windows.dll with type forwards), which aren't available on earlier versions.
I believe System.Xml.Linq is available for portable libraries on .NET 4.0.3 and above.