Posts

Showing posts from October, 2023

Donate

Entity Framework Core Scaffold-DbContext Error - The certificate chain was issued by an authority that is not trusted.

Image
Hello, I was converting a .NET core 2.2 console application into a .NET 7 project that will reverse engineer a sample database from Microsoft called ContosoRetailDW as the data source for my Entity Framework Core project. Upon running the Scaffold-DbContext command in Nuget Package Manager Console, an error occured was shown on the window with the specific message "A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)" Scaffold-DbContext "Server=Your_Server;Database=ContosoRetailDW;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models After reading through the forums, the solution that worked form me was to add a TrustServerCertifcate setting with a value to true or Encrypt setting set to false. The latter is the recommended one based from the forum answers. Option

Visual Studio 2022 Error - There was a problem adding your GitHub account. Your default web browser might be using HSTS for localhost.

Image
Good day! I was about to publish one of my .NET 7 console application to GitHub using Visual Studio 2022. And when adding my account, an error occured which states that "There was a problem adding your GitHub account. Your default web browser might be using HSTS for localhost.". After doing some research, I found this post Disabling HSTS for localhost on Chromium-based browsers which fixed the problem for MS Edge or Google Chrome Browsers. First you need to type in the browser url " about://net-internals/#hsts " command to open the Domain Security Page of your browser where you can clear the HSTS. Under " Delete domain security policies " domain textbox, type in localhost and click the delete button. After that, I have successfully added my GitHub account in Visual Studio 2022 and was able to publish my project. Cheers!

Accessing WebView2 Control And It's properties In A C# Class Library

Image
Team, In a situation wherein you need to access a WebView2 control properties in a class library and that the WebView2 control is added in a WPF project, all you need to do is to reference the Microsoft.Web.WebView2.Wpf.dll and Microsoft.Web.WebView2.Core.dll from the WPF project into the class library. The sample code below is a utility class located in a class library project which has a WebView2 control object that performs navigation to a url that is set from the WPF project. public static class WebBrowserUtility { public static readonly DependencyProperty BindableSourceProperty = DependencyProperty.RegisterAttached( "BindableSource" , typeof ( string ), typeof (WebBrowserUtility), new UIPropertyMetadata( null , BindableSourcePropertyChanged)); public static string GetBindableSource(DependencyObject obj) { return ( string )obj.GetValue(BindableSourcePr

How To Set Overlay On Top Of A WPF WebBrowser Or WebView2 Control

Image
Good day! A common scenario to our projects is to use the Overlay concept that is, show a nearly transparent modal on top of our form. I have been using the code below to create an Overlay using just a Border and a TextBlock but to no avail, it just won't sit right on top of the WebBrowser control. In the picture right next to the Border control snippet, only the input controls are covered by the overlay and ignoring the WebBrowser control. <Border BorderBrush= "Black" BorderThickness= "1" Background= "#80000000" Visibility= "{Binding Path=IsBusy, Converter={StaticResource BoolToVisibilityConverter}}" Grid.RowSpan= "4" Grid.ColumnSpan= "3" > <Grid> <TextBlock TextAlignment= "Center" Margin= "0" TextWrapping= "Wrap" Width= "500" Text= "{Binding Path=OverlayMessage}" HorizontalAlignment= "Center" VerticalAlignment= "

WPF WebBrowser Control Not Rendering External HTML Content Properly

Image
Good day Team, I'm currently working on a project to show some information about settings to a WPF WebBrowser control. The project also has the ability to produce a report in an .html file that can be viewed through the browser by the clients. Upon comparing the results from both the .html file and the file rendered to the webbrowser, I noticed that the html file is broke when rendered. Some of the borders are missing and some of the colors are not reflecting. Upon doing some research, I found a solution that is to change the meta tag to use the MS edge engine. When I verified my code to dynamically generate the html file, I noticed that the code to set the meta tag uses plain text/html content such as the code below. private void WriteOpenMainTags( string prevFile, string currFile, ref StringBuilder openMaintags) { openMaintags.AppendLine( "<!DOCTYPE HTML>" ); openMaintags.AppendLine( "<html>" ); openMaintags.AppendLine( "&

Using MahApps.Metro.IconPacks In WPF Application

Image
Good day! Ever wonder how to style your WPF application controls or window with icons where you can choose from several hundreds of icons in a package? Well, nothing to worry about since there's an awesome Nuget Package that provides icons to suit your needs. It's called MahApps.Metro.IconPacks . The cool thing is, it's even grouped into several categories and that each category containes hundreds of icons. To use this awesome library of icons in your WPF project, install the Nuget Package specifically MahApps.Metro.IconPacks. In your XAML view, reference the MahApps.Metro.IconPacks namespace first. xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" To use them like applying icons to your menu items, call the iconsPacks namespace and select PackIconMaterial. Then set the Kind property with the icon of your liking. <iconPacks:PackIconMaterial VerticalAlignment= "Center" HorizontalAlignment= "Center"

Donate