Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Core basic issue

I am new to this area. I already upgraded my VS2015 with update 3. So now I have: .Net Core 1.0.0 with preview tool 2 installed.

Then I use VS2015 to create a new .Net Source project (class library). I have copied some existing .net 4.6.1 code to the new place and compiled error as expected. Then I use "porting analyzer tool"(https://learn.microsoft.com/en-us/dotnet/articles/core/porting/index) to compare and it did give some suggestion how to use the new way in .Net Core.

But there are still few class missing and cannot compile, like 'TypeDescriptor' or 'NullableConverter' etc. Then I googled and someone from Github say they already added these feature but I still not sure why I still get compilation error.

I also noticed that my class libary project has a project.json file as:

"frameworks": {
    "netstandard1.6": {
        "imports": "dnxcore50"
    }
}

I foundn if I remove the 'netstandard1.6' one but change to:

"frameworks": {
    "net461": {}
}

All the compilation error gone, but I could guess it's NOT .Net core project anymore, and more likely as a standard .Net 4.6.1 project.

So basically I'd like to ask:

  1. Why developer from Github saying that is fixed already but I still couldn't find/compile those classes in my project (e.g. TypeDescriptor : https://github.com/dotnet/corefx/issues/8262)?

  2. Some sample also puts both 'net461' & 'netstard1.6' or 'netcoreapp1.0' under 'frameworks' in project.json file. What's the purpose for that?

  3. If I just use 'net461' for the only framework, there seems no difference to traditional .Net Framework 4.6.1 project. Am I correct?

Thanks a lot!

like image 845
Samuel Avatar asked Mar 11 '23 13:03

Samuel


1 Answers

  1. Install package System.ComponentModel.TypeConverter and you are good to go with .NET Core project.
  2. For building different output (binaries) each of which targeting different platform. net461 for applications which should run on (full) .NET Framework (under Windows or Mono). netcoreapp1.0 used for app which should be run under .NET Core. netstandard1.6 (avoid using netstandard1.5 and netstandard1.6 by the way - use previous versions) used for portable class libraries, which are supposed to run under different platforms: (full) .NET Framework, .NET Core, Xamarin, Universal Windows App, etc. You may read more about here and here.
  3. Absolutely.
like image 115
Deilan Avatar answered Mar 20 '23 04:03

Deilan