Questions tagged [.net-core]
.NET Core is an open-source successor of the .NET Framework. It can be used in a wide variety of applications and verticals, ranging from servers and data centers to apps and devices. .NET Core is supported by Microsoft on Windows, Linux and macOS.
                                	
	.net-core
    
                            
                        
                    
            45,031
            questions
        
        
            145
            votes
        
        
            17
            answers
        
        
            159k
            views
        
    Is it possible to make desktop GUI application in .NET Core?
                I have been developing Windows Forms programs for few years. I am now looking into .NET Core (including ASP.NET Core MVC). I am searching for the new GUI desktop technology. In Visual Studio 2015 ...
            
        
       
    
            144
            votes
        
        
            17
            answers
        
        
            229k
            views
        
    Entity Framework Core: `SqlNullValueException: Data is Null.` How to troubleshoot?
                I am using Entity Framework Core in an ASP.NET Core application and Controller action and I haven't changed something to the working code nor to the database but I can't tell what is the query ...
            
        
       
    
            144
            votes
        
        
            5
            answers
        
        
            68k
            views
        
    How to consume a Scoped service from a Singleton?
                How should I inject (using .NET Core's built-in dependency injection library, MS.DI) a DbContext instance into a Singleton? In my specific case the singleton is an IHostedService?
What have I tried
I ...
            
        
       
    
            141
            votes
        
        
            11
            answers
        
        
            94k
            views
        
    How to mock IConfiguration.GetValue
                I tried in vain to mock a top-level (not part of any section) configuration value (.NET Core's IConfiguration).  For example, neither of these will work (using NSubstitute, but it would be the same ...
            
        
       
    
            141
            votes
        
        
            3
            answers
        
        
            83k
            views
        
    .NET Core doesn't know about Windows 1252, how to fix?
                This program works just fine when compiled for .NET 4 but does not when compiled for .NET Core. I understand the error about encoding not supported but not how to fix it.
Public Class Program
    ...
            
        
       
    
            140
            votes
        
        
            14
            answers
        
        
            138k
            views
        
    What replaces WCF in .Net Core?
                I am used to creating a .Net Framework console application and exposing a Add(int x, int y) function via a WCF service from scratch with Class Library (.Net Framework). I then use the console ...
            
        
       
    
            139
            votes
        
        
            6
            answers
        
        
            128k
            views
        
    How to extract a list from appsettings.json in .net core
                I have an appsettings.json file which looks like this:
{
    "someSetting": {
        "subSettings": [
            "one",
            "two",
            "three"
         ]
    }
}
When I build my ...
            
        
       
    
            138
            votes
        
        
            5
            answers
        
        
            231k
            views
        
    Where is NuGet.Config file located in Visual Studio project?
                I am wondering where is NuGet.Config file located in Visual Studio 2017 project? I tried to create my own NuGet.Config file in the root of the project, but I didn't find any new repositories (NuGet ...
            
        
       
    
            136
            votes
        
        
            5
            answers
        
        
            83k
            views
        
    Why does aspnet core start on port 80 from within Docker?
                TL;DR: Why does an aspnet core app run on port 80 from within a Docker image, but 5000 outside a docker image. 
Elaborate
I went through the aspnet core / docker tutorial found here:
https://learn....
            
        
       
    
            135
            votes
        
        
            3
            answers
        
        
            75k
            views
        
    How to call ThenInclude twice in EF Core?
                I'm creating an ASP.NET Core API app, and relying on EF Core. I have entities defined like this:
public class AppUser : IdentityUser
{
    public string FirstName { get; set; }
    public string ...
            
        
       
    
            134
            votes
        
        
            3
            answers
        
        
            64k
            views
        
    I'm lost. What happened to ASP.NET MVC 5?
                I've been keeping my head down working on various projects and apparently Microsoft has been busy making some big changes and it's confusing the hell out of me. ASP.NET Core first came onto my radar ...
            
        
       
    
            132
            votes
        
        
            11
            answers
        
        
            117k
            views
        
    Upload files and JSON in ASP.NET Core Web API
                How can I upload a list of files (images) and json data to ASP.NET Core Web API controller using multipart upload?
I can successfully receive a list of files, uploaded with multipart/form-data ...
            
        
       
    
            130
            votes
        
        
            12
            answers
        
        
            146k
            views
        
    dotnet: command not found in Mac
                So I downloaded NET Core 2.1 SDK for mac and installed it. But when I run the dotnet command from terminal it throws -bash: dotnet: command not found error. 
I am trying to use the dotnet new react ...
            
        
       
    
            130
            votes
        
        
            22
            answers
        
        
            154k
            views
        
    Detected package downgrade warning (dotnet core, vs 2017)
                I have just updated all my nuget packages for my solution (dotnet core 1.1 project).
I am now getting the following warnings and I don't really know what they mean.
Update: I am still getting ...
            
        
       
    
            130
            votes
        
        
            3
            answers
        
        
            49k
            views
        
    Are async console applications supported in .NET Core?
                At some point in time the CoreCLR supported async main entry points. See http://blog.stephencleary.com/2015/03/async-console-apps-on-net-coreclr.html
However both the following programs are not ...
            
        
       
    
            129
            votes
        
        
            19
            answers
        
        
            173k
            views
        
    Error NU1605 Detected package downgrade
                I am experiencing the following NU1605 dependency errors in my netcoreapp2.0 console application:
NU1605  Detected package downgrade: System.Diagnostics.Debug from 4.3.0 to 4.0.11. Reference the ...
            
        
       
    
            128
            votes
        
        
            26
            answers
        
        
            296k
            views
        
    How to change the port number for Asp.Net core app?
                I added the following section in project.json.
  "commands": {
    "run": "run server.urls=http://localhost:8082",
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --...
            
        
       
    
            127
            votes
        
        
            24
            answers
        
        
            175k
            views
        
    MSBUILD throws error: The SDK 'Microsoft.NET.Sdk' specified could not be found
                I'm trying to build a solution using msbuild command line and I keep getting this error:
error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.
The version of msbuild is the latest ...
            
        
       
    
            126
            votes
        
        
            7
            answers
        
        
            133k
            views
        
    Switch between dotnet core SDK versions
                I recently installed VS 2017 RC and then automatically my dotnet version pointed to 1.0.0-preview4-004233. Due to that whenever I create a new project using command dotnet new -t Console I cannot see ...
            
        
       
    
            126
            votes
        
        
            4
            answers
        
        
            104k
            views
        
    .NET Core IServiceScopeFactory.CreateScope() vs IServiceProvider.CreateScope() extension
                My understanding is that when using the built in the dependency injection, a .NET Core console app will require you to create and manage all scopes yourself whereas a ASP.NET Core app will create and ...
            
        
       
    
            125
            votes
        
        
            14
            answers
        
        
            122k
            views
        
    How to load appsetting.json section into Dictionary in .NET Core?
                I am familiar with loading an appsettings.json section into a strongly typed object in .NET Core Startup.cs. For example:
public class CustomSection 
{
   public int A {get;set;}
   public int B {get;...
            
        
       
    
            123
            votes
        
        
            3
            answers
        
        
            73k
            views
        
    'ConfigurationBuilder' does not contain a definition for 'AddJsonFile'
                I have the following error:
Program.cs(15,72): error CS1061: 'ConfigurationBuilder' does not contain a definition for 'AddJsonFile' and no accessible extension method 'AddJsonFile' accepting a first ...
            
        
       
    
            123
            votes
        
        
            6
            answers
        
        
            51k
            views
        
    No AppDomains in .NET Core! Why?
                Is there a strong reason why Microsoft chose not to support AppDomains in .NET Core?
AppDomains are particularly useful when building long running server apps, where we may want to update the ...
            
        
       
    
            122
            votes
        
        
            6
            answers
        
        
            168k
            views
        
    How to set json serializer settings in asp.net core 3?
                json serializer settings for legacy asp.net core applications were set by adding AddMvc().AddJsonOptions(), but I don't use AddMvc() in asp.net core 3. So how can I set global json serialization ...
            
        
       
    
            121
            votes
        
        
            3
            answers
        
        
            175k
            views
        
    How to use SqlClient in ASP.NET Core?
                I am trying to use SQLClient library in the ASP.net Core but cant seem to get it working.  I found this article online advising how to setup but its not working for me: http://blog.developers.ba/using-...
            
        
       
    
            121
            votes
        
        
            2
            answers
        
        
            20k
            views
        
    On IServiceProvider what are the differences between the GetRequiredService and GetService methods?
                What are the differences between IServiceProvider.GetRequiredService() and IServiceProvider.GetService()?
When is it a better idea to use GetRequiredService()?
            
        
       
    
            121
            votes
        
        
            7
            answers
        
        
            213k
            views
        
    How to get an instance of IServiceProvider in .NET Core?
                IServiceProvider is an interface with single method:
object GetService(Type serviceType);
It's used to create instances of types registered in .NET Core native DI container.
An instance of ...
            
        
       
    
            121
            votes
        
        
            25
            answers
        
        
            154k
            views
        
    The library hostpolicy.dll was not found
                I have a simple .NET Core project (console app) that I'm trying to compile and run. dotnet build succeeds, but I get the following error when I do dotnet run:
dotnet run
Project RazorPrecompiler (....
            
        
       
    
            119
            votes
        
        
            13
            answers
        
        
            455k
            views
        
    The SSL connection could not be established
                I am using a third party library (Splunk c# SDK ) in my ASP.NET core application.  I am trying to connect to my localhost Splunk service via this SDK, but I get an exception saying: 
  System.Net....
            
        
       
    
            119
            votes
        
        
            4
            answers
        
        
            139k
            views
        
    System.ServiceModel not found in .NET Core project
                I have a .NET Core xUnit project.  I'm trying to call a WCF service from it but get the following exception:
System.InvalidOperationException occurred
  HResult=0x80131509
  Message=An error occurred ...
            
        
       
    
            119
            votes
        
        
            2
            answers
        
        
            130k
            views
        
    Entity framework EF.Functions.Like vs string.Contains
                I was reading the announcement of entity framework core 2.0 https://blogs.msdn.microsoft.com/dotnet/2017/08/14/announcing-entity-framework-core-2-0/
It says that they added new Sql functions like EF....
            
        
       
    
            118
            votes
        
        
            4
            answers
        
        
            34k
            views
        
    "The project 'Web' must provide a value for Configuration" error after migrating to .NET Core 3
                I've migrated an ASP.NET Core 2.2 project to Core 3.0 and am getting the error: 
  The project [Project location] must provide a value for Configuration. 
There's not really a lot to go on with that ...
            
        
       
    
            118
            votes
        
        
            6
            answers
        
        
            85k
            views
        
    Dependency Injection with classes other than a Controller class
                At this point I'm injecting things into my Controllers with ease, in some cases building my own ResolverServices class. Life is good.
What I cannot figure out how to do is get the framework to ...
            
        
       
    
            117
            votes
        
        
            39
            answers
        
        
            259k
            views
        
    EF Core add-migration Build Failed
                I have a developer that is getting "Build failed." when running add-migration in a .NET Core EF project, with no explanation of why the build failed. How do you troubleshoot this error?
This is what ...
            
        
       
    
            116
            votes
        
        
            22
            answers
        
        
            165k
            views
        
    IIS: Handler "aspNetCore" has a bad module "AspNetCoreModuleV2" in its module list
                I used angular .net core 2.2 template to build an application. In localhost working fine, When I host to IIS I'm getting this error. I'm using IIS 10 to host the application.
Error,
HTTP Error 500.21 -...
            
        
       
    
            116
            votes
        
        
            1
            answer
        
        
            45k
            views
        
    .NET Core - When to use "dotnet new sln"
                I'm a bit confused - the majority of .NET Core tutorials I have been reading have not mentioned "dotnet new sln" - they always just create the projects separately without any solution file to link ...
            
        
       
    
            115
            votes
        
        
            14
            answers
        
        
            115k
            views
        
    Cannot find command 'dotnet ef'
                I am using .NET Core 2.0 on Arch Linux / Visual Studio Code and am trying to get EF tools to work, but I keep getting the error:
cannot find command dotnet ef
I've just about looked everywhere and ...
            
        
       
    
            115
            votes
        
        
            12
            answers
        
        
            97k
            views
        
    Return View as String in .NET Core
                I found some article how to return view to string in ASP.NET, but could not covert any to be able to run it with .NET Core
public static string RenderViewToString(this Controller controller, string ...
            
        
       
    
            115
            votes
        
        
            15
            answers
        
        
            104k
            views
        
    Configuration.GetSection always returns Value property null
                Every time I call Configuration.GetSection, the Value property of the returned object is always null.
My Startup constructor
public Startup(IHostingEnvironment env)
{
    var builder = new ...
            
        
       
    
            114
            votes
        
        
            7
            answers
        
        
            101k
            views
        
    How to fix "The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time" error
                I've already enabled CORS on the project in C# .net Core 
In startup.cs I've added lines
...
services.AddCors();
...
app.UseCors(builder => builder
    .AllowAnyOrigin()
    .AllowAnyMethod()
    ...
            
        
       
    
            113
            votes
        
        
            16
            answers
        
        
            198k
            views
        
    The configuration file 'appsettings.json' was not found and is not optional
                The Azure error is:
  .Net Core: Application startup exception:
  System.IO.FileNotFoundException: The configuration file
  'appsettings.json' was not found and is not optional.
So this is a bit ...
            
        
       
    
            113
            votes
        
        
            7
            answers
        
        
            110k
            views
        
    Startup.cs in a self-hosted .NET Core Console Application
                I have a self-hosted .NET Core Console Application.
The web shows examples for ASP.NET Core but I do not have a web server. Just a simple command line application.
Is it possible to do something like ...
            
        
       
    
            112
            votes
        
        
            32
            answers
        
        
            88k
            views
        
    Project file is incomplete. Expected imports are missing
                After format my computer I reinstalled Vs 2017 V 15.6.3
and install ASP.Net Core SDK from Microsoft 2.1.4
But when I create new asp core application VS failed with error
  "Project file is ...
            
        
       
    
            112
            votes
        
        
            1
            answer
        
        
            40k
            views
        
    How to override ASP.NET Core configuration array settings using environment variables
                TL;DR
In an ASP.NET Core app, I have an appsettings.json config file which uses a JSON array to configure a collection of settings.
How do I override a setting of one of the array objects using ...
            
        
       
    
            111
            votes
        
        
            6
            answers
        
        
            80k
            views
        
    .Net Core 2.0 Process.Start throws "The specified executable is not a valid application for this OS platform"
                I need to let a .reg file and a .msi file execute automatically using whatever executables these two file types associated with on user's Windows.
.NET Core 2.0 Process.Start(string fileName) docs ...
            
        
       
    
            111
            votes
        
        
            7
            answers
        
        
            79k
            views
        
    Populate IConfiguration for unit tests
                .NET Core configuration allows so many options to add values (environment variables, json files, command line args).
I just can't figure out and find an answer how to populate it via code.
I am ...
            
        
       
    
            110
            votes
        
        
            19
            answers
        
        
            178k
            views
        
    The current .NET SDK does not support targeting .NET Core 2.1. Either target .NET Core 2.0 or lower, or use a .NET SDK that supports .NET Core 2.1
                have tried upgrading to the professional version of visual studio 2017 v 15.6.0 (Preview 7.0)
and installed aspnetcore-runtime-2.1.0-preview1-final-win-x64 and .net core SDK 2.1.4.
When I created a ...
            
        
       
    
            109
            votes
        
        
            8
            answers
        
        
            99k
            views
        
    No service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]' has been registered
                What is the possible cause of this error:
  InvalidOperationException: No service for type 'Microsoft.AspNetCore.Identity.UserManager [Microsoft.AspNetCore.Identity.IdentityUser]' has been registered....
            
        
       
    
            108
            votes
        
        
            4
            answers
        
        
            68k
            views
        
    How do you multi-target a .NET Core class library with csproj?
                When .NET Core still used the project.json format, you could build a class library targeting multiple frameworks (e.g. net451, netcoreapp1.0).
Now that the official project format is csproj using ...
            
        
       
    
            108
            votes
        
        
            5
            answers
        
        
            148k
            views
        
    Command line to install/upgrade .NET Core
                Are there command line commands to install or upgrade .NET Core?
I checked to see if I had .NET Core was installed on my computer using dotnet --version only to notice that I still had the preview ...