Catatan

Menunjukkan catatan yang berlabel C#

Install SFTP in Windows Server and Connect using C# .NET

Imej
Install & Setup SFTP Server  Video reference For Windows 11, refer link below; https://medium.com/@imtejassingh/setup-sftp-in-windows-11-8191e7c6b2b2 Connect using C# .NET Install library using NuGet -  https://github.com/sshnet/SSH.NET/ f f f f f f f f f f Video Reference

BitArray in C#

Imej
  BitArray in C# - https://code-maze.com/csharp-bitarray/ C# Bitwise and Bit Shift Operators -  https://www.programiz.com/csharp-programming/bitwise-operators Bit Processing in C# -  https://derekwill.com/2015/03/05/bit-processing-in-c/ How can I convert BitArray to single int? -  https://stackoverflow.com/questions/5283180/how-can-i-convert-bitarray-to-single-int BitArray Class -  https://learn.microsoft.com/en-us/dotnet/api/system.collections.bitarray?view=net-7.0 C# | Inverting all bit values in BitArray -  https://www.geeksforgeeks.org/c-sharp-inverting-all-bit-values-in-bitarray/ Convert from BitArray to Byte -  https://stackoverflow.com/a/560131

C# calculation CRC16

Imej
Code for CRC116: private static string Crc16Ccitt(byte[] bytes)         {             const ushort poly = 4129;             ushort[] table = new ushort[256];             ushort initialValue = 0xffff;             ushort temp, a;             ushort crc = initialValue;             for (int i = 0; i < table.Length; ++i)             {                 temp = 0;                 a = (ushort)(i << 8);                 for (int j = 0; j < 8; ++j)                 {                     if (((temp ^ a) & 0x8000) != 0)                         temp = (ushort)((temp << 1) ^ poly);                     else                         temp <<= 1;                     a <<= 1;                 }                 table[i] = temp;             }             for (int i = 0; i < bytes.Length; ++i)             {                 crc = (ushort)((crc << 8) ^ table[((crc >> 8) ^ (0xff & bytes[i]))]);             }             return crc.ToString();         }  Explan

.NET C# SDK

 https://medium.com/@xaviergeerinck/how-to-write-a-c-sdk-using-net-core-17f2dabef8d4

Epoch & Unix Timestamp

Imej
  Epoch & Unix Timestamp Conversion Tools -  https://www.epochconverter.com/ How could I convert data from string to long in c# -  https://stackoverflow.com/a/51739602 How do you convert epoch time in C#?  -  https://stackoverflow.com/questions/249760/how-can-i-convert-a-unix-timestamp-to-datetime-and-vice-versa -  https://stackoverflow.com/a/2883645

Save config in Register Editor

  How to read value of a registry key c# - https://stackoverflow.com/a/18234755 How to add, modify, or delete registry subkeys and values by using a .reg file - https://support.microsoft.com/en-us/topic/how-to-add-modify-or-delete-registry-subkeys-and-values-by-using-a-reg-file-9c7f37cf-a5e9-e1cd-c4fa-2a26218a1a23

Encryption and Decryption in C#

References:  Encryption and Decryption in C#  - https://sankhadip.medium.com/encryption-and-decryption-in-c-f2de3d802e1d#:~:text=The%20Advanced%20Encryption%20Standard%2C%20or,to%20encrypt%20and%20decrypt%20messages. Encryption And Decryption Using A Symmetric Key In C# - https://www.c-sharpcorner.com/article/encryption-and-decryption-using-a-symmetric-key-in-c-sharp/ Public Key Encryption - https://www.tutorialspoint.com/cryptography/public_key_encryption.htm

Create minimal WEB API ASP.NET

Imej
Tutorial: Create a minimal web API with ASP.NET Core https://docs.microsoft.com/en-us/aspnet/core/tutorials/min-web-api?view=aspnetcore-6.0&tabs=visual-studio Use a database with minimal API, Entity Framework Core, and ASP.NET Core https://docs.microsoft.com/en-us/learn/modules/build-web-api-minimal-database/?wt.mc_id=academic-0000-chnoring Return value JSON or XML format JSON and XML Serialization in ASP.NET Web API https://docs.microsoft.com/en-us/aspnet/web-api/overview/formats-and-model-binding/json-and-xml-serialization Deploying Web API ASP.NET Quickstart: Deploy an ASP.NET web app https://docs.microsoft.com/en-us/azure/app-service/quickstart-dotnetcore?tabs=net60&pivots=development-environment-vs The .NET Core Hosting Bundle https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/hosting-bundle?view=aspnetcore-6.0 Publish .NET 5 Web API on IIS || .NET Core Hosting on IIS

ASP.NET C# Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.

Imej
The Error: <asp:AsyncPostBackTrigger ControlID="Timer1" /> The Solutions: Change  <asp:AsyncPostBackTrigger ControlID="Timer1" /> to  <asp:PostBackTrigger ControlID="Timer1" /> Reference Solution: https://social.msdn.microsoft.com/Forums/en-US/cc3f69ee-6634-4f2c-ab97-0427825ce0e4/syswebformspagerequestmanagerparsererrorexception-the-message-received-from-the-server-could-not?forum=aspwebforms#:~:text=WebForms.-,PageRequestManagerParserErrorException%3A%20The%20message%20received%20from%20the%20server%20could%20not%20be,or%20server%20trace%20is%20enabled.

How to log data to the Windows Event Log in C#

if (!EventLog.SourceExists(sSource)) {       EventLog.CreateEventSource(sSource, sLog); } Rujukan:  How to log data to the Windows Event Log in C#

WMPLib Media Player

Imej
Failed to AxHost. System Reflection Solution: Remove AxWMPLib and WMPLib references. Remove Media Player from Toolbar Close the tab windows. Rebuild the project. Go to Manage NuGet Package to download the new WMPLib to replace the corrupted WMPLib. Rebuild the application, add a media player on the toolbar and now we can drag and drop the media player to windows. References: https://social.msdn.microsoft.com/Forums/windows/en-US/c2a286ed-6973-4cd4-a2c7-79e5f784b71a/error-on-visual-studio?forum=winforms

Manually force terminate starting service C#

Imej
Here is the step to manually stop and terminate service that starting & running in background Go to Services.  Right click on the service that we want to stop. Open command prompt as Administrator. write down the command as below: sc queryex " Service name " taskkill /pid PID /f Reference :  How To: Manually Force a service to stop if not responding

WMPLib assembly issues (Solved: Driver issues)

Imej
  File yang kena check Source code SOLUTION https://chilionyang.blogspot.com/2020/11/c-windows-media-player-control-com.html PERMANENT SOLUTION - Update graphic card driver (Intel Graphic UHD & GeForce NVIDIA) https://www.intel.com/content/www/us/en/support/intel-driver-support-assistant.html  

System.Net.Sockets.SocketException: 'Only one usage of each socket address (protocol/network address/port) is normally

Imej
 System.Net.Sockets.SocketException: 'Only one usage of each socket address (protocol/network address/port) is normally Option 1 Open the Command Prompt. Type  netstat -ano | findstr ":80"  - where "80" is the port number you are searching for. Look at the last column in the results - the PID. For each PID running that you want to kill, execute  taskkill /PID <PID> /F  in the Command Prompt window (where  <PID>  is the PID that needs to be killed). Option 2 If Option 1 above doesn't work, try rebooting your machine.

[PSH,ACK] wireshark capture

Reference : https://osqa-ask.wireshark.org/questions/20423/pshack-wireshark-capture/ This is basic TCP communications flow. The ACK indicates that a host is acknowledging having received some data, and the PSH,ACK indicates the host is acknowledging receipt of some previous data and also transmitting some more data. Google will let you search for more info about basic TCP communication.   ACK means that the machine sending the packet with ACK is acknowledging data that it had received from the other machine. In TCP, once the connection is established,   all   packets sent by either side will contain an ACK, even if it's just re-acknowledging data that it's already acknowledged. PSH is an indication by the sender that, if the receiving machine's TCP implementation has not yet provided the data it's received to the code that's reading the data (program, or library used by a program), it should do so at that point. To quote  RFC 793 , the official specification for TCP

ASP.Net perform auto reload

Imej
Working with SQL Server ROWCOUNT

ASP.NET show console

Page.Response.Write("<script>console.log(' Message : " + message + "');</script>");

Name cannot begin with the '<' character, hexadecimal value 0x3C

Imej
Problem : Name cannot begin with the '<' character, hexadecimal value 0x3C Solution : .resx corrupt due to bad merging from git

C# List

Note C# List<T> Rujukan: C# - List<T> -  https://www.tutorialsteacher.com/csharp/csharp-list How to Delete All Items Of A C# List -  https://www.c-sharpcorner.com/UploadFile/mahesh/delete-all-items-in-a-C-Sharp-list/ C# | Join() Method - https://www.geeksforgeeks.org/c-sharp-join-method-set-1/

C#: Upload excel into database

Imej
The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machines Error state as below; Solution: Install Microsoft Access database engine 2010 driver Rujukan :  https://stackoverflow.com/a/6649413/10763264 The given ColumnMapping does not match up with any column in the sources or destination Rujukan :  https://stackoverflow.com/questions/20228359/the-given-columnmapping-does-not-match-up-with-any-column-in-the-source-or-desti