.net-core-2.0

Published .Net Core 2 application does not read appsettings.json file

蓝咒 提交于 2019-12-02 09:04:36
I have 2 apps, one console one web api both .net core v2.0 . Both has the same problem. I used to run my application thru source files. I was building and running them on a linux machine. Everything was good, everything was great, but now i'm running the same app thru publish output. Now it doesn't work as it suppose to, because the app can't read appsettings.json. configuration["Settings:Port"] != null ? int.Parse(configuration["Settings:Port"]) //i should be getting this - 1234 : default(int) //but instead i got this - 0 I have corrupted the appsettings.json file and i was expecting to see

Reference .netstandard 2.0 project in core 2.0 Runtime loading error when GenerateAssemblyInfo = false

ⅰ亾dé卋堺 提交于 2019-12-02 03:36:08
When we add the reference, we are able to use the .netstandard libs classes in our .net core console project (in Visual Studio), and it compiles. When we run the app, it immediately crashes with this error in the output window: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. Could not load file or assembly 'MyNetStandard20Assembly, Version=0.1.0.0, Culture=en-us, PublicKeyToken=null'. The system cannot find the file specified. Update / Cause (still looking for reason) So we use AssemblyInfo files in our projects and in order to make these work with

.NET Core 2 Console App Dependencies Issue on Azure

北慕城南 提交于 2019-12-02 00:55:34
Short version of the problem: I'm having difficulties including the assemblies my .NET Core Console App depends on. Initially, the assemblies from NuGet packages were not included in the bin folder even though I could run the app in Debug mode without any problems. Found an article that suggested that I should add <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> in the myapp.csproj file which I did. Doing so included the dll files for the NuGet packages in the bin folder BUT after I copied my console app to Azure to run as a WebJob, I got an error telling me that System.Data

Error message “CS5001 Program does not contain a static 'Main' method suitable for an entry point”

廉价感情. 提交于 2019-11-30 06:20:18
问题 Unable to execute the following code error CS5001 Program does not contain a static 'Main' method suitable for an entry point What does this error message mean? class Program { static async Task MainAsync(string[] args) { Account.accountTest accountTest = new Account.accountTest(); bool result = await accountTest.CreateAccountAsync(); } } 回答1: It means that you don't have a suitable entry point for your application at the moment. That code will nearly work with C# 7.1, but you do need to

VSTS build: Packages failed to restore - Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'

懵懂的女人 提交于 2019-11-30 01:47:04
I'm getting Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'. in VSTS build using Hosted2017 build agent after I upgraded my aspnetcore app to netcoreapp2.0 and my libraries to use netstandard2.0 . Works fine locally. I've edited my build definition to use .net core build task v2.* preview : here is the build log: Current agent version: '2.120.2' Download all required tasks. Downloading task: DotNetCoreCLI Starting: Get Sources Syncing repository: Liero/vyvojari-sk (GitHub) ...details ommited HEAD is now at e448a25... Upgraded to .NET Core 2.0 Finishing: Get

ASP.NET Core 2 Seed Database [duplicate]

江枫思渺然 提交于 2019-11-30 00:00:30
This question already has an answer here: How to seed in Entity Framework Core 2? 7 answers I've seen some of the similar examples on SO regarding this but I don't know enough about the language just yet to see what I'm doing wrong. I've cobbled together a demo to learn more but I'm having trouble seeding my database. I receive the following error: InvalidOperationException: Cannot resolve scoped service 'demoApp.Models.AppDbContext' from root provider. Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateResolution(Type serviceType, ServiceProvider serviceProvider)

Error message “CS5001 Program does not contain a static 'Main' method suitable for an entry point”

本小妞迷上赌 提交于 2019-11-29 22:05:08
Unable to execute the following code error CS5001 Program does not contain a static 'Main' method suitable for an entry point What does this error message mean? class Program { static async Task MainAsync(string[] args) { Account.accountTest accountTest = new Account.accountTest(); bool result = await accountTest.CreateAccountAsync(); } } It means that you don't have a suitable entry point for your application at the moment. That code will nearly work with C# 7.1, but you do need to explicitly enable C# 7.1 in your project file: <LangVersion>7.1</LangVersion> or more generally: <LangVersion

Unable to load DLL 'libdl' when using System.Drawing.Common NuGet package on AWS Lambda

倖福魔咒の 提交于 2019-11-29 11:55:45
问题 We have a thumbnail generator lambda function which I'm trying to update to .NET Core 2.0, but I've encountered the following error when using Microsoft's System.Drawing.Common NuGet package: TypeInitializationException The type initializer for 'Gdip' threw an exception. at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, Int32 format, HandleRef scan0, IntPtr& bitmap) at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat

VSTS build: Packages failed to restore - Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'

烂漫一生 提交于 2019-11-28 22:37:23
问题 I'm getting Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'. in VSTS build using Hosted2017 build agent after I upgraded my aspnetcore app to netcoreapp2.0 and my libraries to use netstandard2.0 . Works fine locally. I've edited my build definition to use .net core build task v2.* preview : here is the build log: Current agent version: '2.120.2' Download all required tasks. Downloading task: DotNetCoreCLI Starting: Get Sources Syncing repository: Liero

.NET Core 2.0 missing from my Visual Studio

偶尔善良 提交于 2019-11-28 13:16:31
So I've installed the official .NET Core 2.0 SDK and when I'm in Visual Studio i get heaps of errors and the target framework is not listed :( It's like .NET Core 2.0 isn't installed. and here's the .csproj file: <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp2.0</TargetFramework> </PropertyGroup> <ItemGroup> <Folder Include="wwwroot\" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> </ItemGroup> </Project> also, dotnet --version returns 2.0.0 so .. is there some install tooling I'm missing? EDIT/UPDATE: Here