Posts

Showing posts with the label .NET 5

Donate

Using OpenFileDialog Or MessageBox In .NET Core Class Library Project With WPF Application

Image
Good day Team! Given that you need to access the OpenFileDialog or MessageBox Dialog In Your .NET Core Class Library that is part of a solution that contains a WPF project, there's an easy hack provided by our Solutions Architect that is to hand hack the .csproj settings. First is to open the .csproj file using an editor. Inside Property Group node, add enable WPF by adding a UseWPF element with the value of true such as below. <Project Sdk= "Microsoft.NET.Sdk" > <PropertyGroup> <TargetFramework>net7.0-windows10.0.17763.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> <UseWPF>true</UseWPF> </PropertyGroup> <ItemGroup> <PackageReference Include= "Company.Utilities.CompanyLibNET7" Version= "1.0.0.3" /> <PackageReference Include= "Microsoft.Extensions.DependencyInjection" Version= "7.

Activate Or Show Windows Forms Missing Controls Including BindingNavigator In .NET 5 or .NET Core Winforms Application

Image
Gents Good Day! There was a question on forums on why the BindingNavigator control was either missing or grayed out in Visual Studio Toolbox of which the project's target framework is .NET 5. I decided to create a C# Windows Forms application using Visual Studio 2019 that targets the .NET 5 framework and infact, the BindingNavigator control is missing. After searching the net, I found an interesting link in StackOverflow Activate missing Winforms controls in .Net Core 3.1 which is applicable to .NET Core 3.1. I applied the steps stated in the post's answer to the Windows Forms project that I created and it works. Below are the steps to do that. 1. Comment Application.SetHighDpiMode(HighDpiMode.SystemAware); code in Program.cs file. static void Main() { //Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault( false ); Application.Run( new Form1()); }

Using Unity IoC Container Dependency Injection, Dapper ORM and SQL Server In Visual Basic .NET Core Or .NET 5 Application

Image
Hi All, This article is the VB.NET version of this post Getting Started With Unity IoC Container Dependency Injection In .NET Core Using Entity Framework Core ORM And SQL Server . We will create a .NET Core Console Application that will utilize the Unity IoC Container for Dependency Injection, SQL Server and Dapper ORM. Instead of using Entity Framework, I'm using Dapper ORM coz EF does not support reverse engineering in .NET Core. There are existing power tools or other solutions on how to reverse engineer a database table but for now I'll just use Dapper. I'll be using Microsoft's sample database called ContosoRetailsDw as the datasource of this tutorial. Project Setup 1. Start off by creating a Visual Basic .NET Core Console Application targetting the latest framework which is .NET 5.0 2. Add three new folders Models, Repository and UnitOfWork. These folders contain the model and DAL classes used in this project. 3. Add the following NuGet packages: Dapper O

How To Create Or Generate PDF Reports Or Files Using DinkToPDF in .NET 5 or .NET Core Console Application

Image
Good day! In this tutorial, I will demonstrate on how to create or generate PDF reports or files using DinkToPDF in .NET 5 or .NET Core Console Application. This library is a C# .NET Core wrapper for wkhtmltopdf library that uses the Webkit engine to convert HTML files or page to PDF and was developed by 'rdvojmoc Rok Dvojmoč' from Slovenia. To begin with lets start by establishing the project structure. Project Structure 1. Create a .NET 5 or .NET Core Console Application Project. 2. Add DinkToPDF and Unity packages using NuGet. 3. Copy the libwkhtmltox (dll, dylib and so) files from DinkToPDF and attach those files to your project. Make sure to set the Copy to Output Directory attribute of those files to Copy Always . Note that there are two versions for these files,32 and 64 bit. 4. Create three folders to the project and in each folder add the empty classes or interface shown in step #6. 5. Add an empty html file called ReportTemplate inside the project and set

Using Microsoft.Extensions.DependencyInjection In .NET 5 or .NET Core Console Application

Image
Team, Here's how to incorporate the Microsoft.Extensions.DependencyInjection namespace and it's ServiceProvider class in a .NET 5 or .NET Core Console Application project. If you're an ASP.NET Core MVC developer, you might recognize how it is applied in Startup.cs for Dependency Injection specifically ConfigureServices() method wherein the AddTransient() method is utilized to map an interface class and it's implementation type. To begin with, lets by creating a .NET 5 Console application project and follow the steps below. Project Setup 1. Add the Microsoft.Extensions.DependencyInjection package to your project via NuGet. 2. Create three folders, new classes and interfaces based from the image below. Models Add two model classes specifically Employee and Product with three properties for each class. Product.cs public class Product { public int ProductCode { get ; set ; } public string ProductName { get ; set ; } public double Prod

.NET 5 - CA1416: This call site is reachable on all platforms. is only supported on Windows 7.0 and later

Image
Hi All, Our software architect just recently upgraded our custom class library that contains common data access classes, custom utilities and functions for our day to day tasks from .NET Framework 4.7x to .NET 5. Since we are only deploying our applications to windows users, he set the TargetFramework value to net5.0-windows in .csproj file. <Project Sdk= "Microsoft.NET.Sdk" > <PropertyGroup Label= "Globals" > <SccProjectName>SAK</SccProjectName> <SccProvider>SAK</SccProvider> <SccAuxPath>SAK</SccAuxPath> <SccLocalPath>SAK</SccLocalPath> </PropertyGroup> <PropertyGroup> <TargetFramework>net5.0-windows</TargetFramework> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <UseWPF>true</UseWPF> <PackageId>Utilities.XYZLibNET</PackageId> <Version>1.0.0.3</Version> <Authors>Development Te

Getting Started With Unity IoC Container Dependency Injection In .NET Core Using Entity Framework Core ORM And SQL Server

Image
Hello Fellow Programmers! Visual Basic Version: Using Unity IoC Container Dependency Injection, Dapper ORM and SQL Server In Visual Basic .NET Core Or .NET 5 Application In this article, I'll demonstrate on how to incorporate the Unity IoC Container into a .NET Core Console Application using Entity Framework Core ORM and SQL Server.This will apply the constructor injection methodology of dependency injection where in dependencies are provided through a constructor. I've used this IoC Container several years ago and have not done any coding after that. So it's time to revisit this terrific tool again and create a simple application that will retrieve a single record from Microsoft's sample database called ContosoRetailsDw . Make sure the DB is installed on your machine. Once done, we may now proceed in creating the sample program by performing the steps below. Project Setup 1. Start off by creating a .NET Core Console Application targetting the latest framework wh

Donate