Posts

ASPNETCORE_ENVIRONMENT in Published Project

Typical Program.cs         public Startup(IHostingEnvironment env)         {             // https://blog.elmah.io/config-transformations-in-aspnetcore/             // https://andrewlock.net/how-to-set-the-hosting-environment-in-asp-net-core/             // https://github.com/aspnet/Hosting/issues/863             // For dev, please remove or rename appsettings.production.json, so that it's not used             var builder = new ConfigurationBuilder()                 .SetBasePath(env.ContentRootPath)                 .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)                 .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true,...

Errors in Net Core Add-Migration

Visual Studio 2017 version 15.5.2, Net Core 2. Add-Migration error: Exception calling "SetData" with "2" argument(s): "Type  'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in  assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=15.0.0.0,  Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable." At C:\Users\wanj\.nuget\packages\entityframework\6.2.0\tools\EntityFramework.psm1:720 char:5 +     $domain.SetData('project', $project) +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException     + FullyQualifiedErrorId : SerializationException Exception calling "SetData" with "2" argument(s): "Type  'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in  assembly 'Microsoft.VisualStudio.ProjectSystem...

Set up Visual Studio 2017 for .Net Core Application Development

Image
The Default Profile setting in LibPrograms/Properties/LaunchSettings.json {   "iisSettings": {     "windowsAuthentication": true,     "anonymousAuthentication": true,     "iis": {       "applicationUrl": "http://localhost:8000",       "sslPort": 0     },     "iisExpress": {       "applicationUrl": "http://localhost:49497/",       "sslPort": 0     }   },   "profiles": {     "IIS": {       "commandName": "IIS",       "launchBrowser": true,       "environmentVariables": {         "ASPNETCORE_ENVIRONMENT": "Development"       }     },     "IISExpress": {       "commandName": "IIS",       "launchBrowser": true,       "environmentVariables": {   ...

Use Windows Authentication in Net Core 2.0

This link has everything we need:  Configure Windows authentication in an ASP.NET Core app About the launchsetting.json file See What is launchsetting.json in ASP.NET Core Windows Authentication and Anonymous Authentication can be set through IIS Authorization or launchsetting.json. However launchsetting.json only affects  development time (running through IIS profile) . Once deployed,  it's determined by IIS Authorization setting only. If Windows Authentication is enabled but Anonymous is disabled When Windows authentication is enabled and anonymous access is disabled, the [Authorize] and [AllowAnonymous] attributes have no effect. The above description in  Configure Windows authentication in an ASP.NET Core app  is somehow wrong. In contrast, in a Intranet app where anonymous is disabled, there is no problem to still use [Authorize] to control access based on Windows groups. This pattern is common in real world. Be a...

Import SQL Server 2016 and Excel Data into SQL Server 2008 R2

Background Development    SQL Server 2016 (“2016”) Database: LibDB     Branch table: (prod data)     Category table: (prod data)     Program table: (fake data) Production SQL Server 2008 R2 (“R2”) Excel Sheet: needs to be imported into Production’s Program table Import 2016 Database into R2 Please note: R2 doesn’t recognized the database backup generated by 2016 Script to Create Database Schema (DB and All Table Structures) 2016 SMS/ LibDB/Tasks/Generate Scripts/ Next /Script entire database and all database objects/ Next /Advanced:     Script for Server Version: SQL Server 2008 R2     Types of data to script: Schema only /OK Run the script on R2 There will be errors in database creation when running this script on R2. Please replace the error lines with similar database creation statements that are generated on R2 itself. Script to Insert Data for Branch and Category Table 2016 SMS/ LibDB...

TF30063: You are not authorized to access Team Foundation Server

Andrew Beier   SOLVED: I ran into the same issue of TF 30063 on v15.3.5 right after changing my network AD password (enterprise policy). Previously you would be prompted to updated your user credentials for on-prem TFS, however at some point in one of the recent VS patches this appears to have stopped being the case. Even after deleting the connection, closing VS, and going back in and trying to add again the credentials wouldn't change. The issue was that my previous credentials were cached by the Windows OS for the TFS server. While some people might have had success wiping out the AppData temp folders, that is not required. You need to update the credentials through Control Panel on the Windows OS. For me on Windows 10: Close VS. Go to Control Panel (with small icon view)-->User Accounts-->Manage your credentials (on the left column)-->Select "Windows Credentials"-->Scroll down to the "Generic Credentials" section and look for your TFS serv...

Use GnuPG Tools or C# Code for PGP Encryption and Signature

For PGP encryption and signature, usually we use PGP command line tools for test purpose and finally use C# application for production. Mine is a Net Core 2.0 console application using NuGet package PgpCore,  https://github.com/mattosaurus/PgpCore. PgpCore is based on BouncyCastle.NetCore which supports the standard OpenPGP keys. Here w use the popular GnuPG (GPG) tools to generate OpenPGP key pair. Download and Install GPG for Windows Download from  https://gpg4win.org/download.html . By default the installation will create two folders (here we use command line tools only): Gpg4Win UI (Kleopatra): C:\Program Files (x86)\Gpg4win Command line tools: C:\Program Files (x86)\GnuPG\bin Generate a GPG Key Pair For GnuPG 2.2.1 and above:     C:\Program Files (x86)\GnuPG\bin> gpg --full-generate-key For old versions of GnuPG:     C:\Program Files (x86)\GnuPG\bin> gpg --gen-key Common GPG Commands List public keys: gpg --lis...