Thứ Hai, 27 tháng 9, 2021

Fix Visual Studio 2019 freezing (crashing) while loading solution

 Fix Visual Studio freezing (crashing) while loading solution

===================

https://stackoverflow.com/questions/39703475/visual-studio-freezing-crashing-while-loading-solution


The issue reappeared after a few days, so I located the user settings for Visual Studio 2019:

%USERPROFILE%\AppData\Roaming\Microsoft\VisualStudio\16.0_f124b472

and deleting the following files seemed to have reset VS to a normal state:

Delete only: User.vsk

It works!!


 // Current.vsk

 // ObjBrowEx.dat


Please close all your solutions before deleting the files

Thứ Năm, 9 tháng 9, 2021

Tạo CRC-8 với giá trị hexadecimal (hệ 16) value dựa trên Poly trong C#

 using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace ReadEpubHtml

{

    public class CrcCalculator

    {

        /// <summary>

        /// Get CRC-8

        /// </summary>

        /// <param name="input"></param>

        /// <returns></returns>

        public static string GetValue(string input)

        {

            return ComputeChecksum(Encoding.ASCII.GetBytes(input)).ToString("X2");

        }


        //Tạo Table dựa trên poly (https://crccalc.com/)

        private static byte poly = 0x07; //0xd5;

        static byte[] table = new byte[256];

        private static byte[] Crc8Table()

        {

            for (int i = 0; i < 256; ++i)

            {

                int temp = i;

                for (int j = 0; j < 8; ++j)

                {

                    if ((temp & 0x80) != 0)

                    {

                        temp = (temp << 1) ^ poly;

                    }

                    else

                    {

                        temp <<= 1;

                    }

                }

                table[i] = (byte)temp;

            }

            return table;

        }


        // vị trí trong CRCtable

        private static byte ComputeChecksum(params byte[] bytes)

        {

            Crc8Table();


            byte crc = 0;

            if (bytes != null && bytes.Length > 0)

            {

                foreach (byte b in bytes)

                {

                    crc = table[crc ^ b];

                }

            }

            return crc;

        }

    }

}