Catatan

Menunjukkan catatan yang berlabel .net

.NET open solution as admin

Imej
How to open .NET solution as administrator Add application manifest file to project Add application manifest file to project Option dont create new.. check in folder Properties Open Project Properties and set the Manifest Change value in line 19 It will shows ClickOnce does not support the request Go to properties - security, turn off clickOnce

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

Imej
Install & Setup SFTP Server  Video reference 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

.NET C# SDK

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

FORCE TO OPEN .NET APPLICATION AS ADMINISTRATOR

  References :  https://stackoverflow.com/questions/2818179/how-do-i-force-my-net-application-to-run-as-administrator

Add ProjectInstaller in Windows Service

Imej
How to create ProjectInstaller.cs class in Windows Service? On Solution Explorer, Go to Service1.cs and double click on the file to open the design view. Right-click in the Design View box and select Add Installer. The class will be generated as below. Click on serviceProcessInstaller1. Set Account : LocalSystem Build the application.

Force Execute File to Run As Administrator

Imej
Right-click your WPF project to add new Item: "Add->New Item..." Select "Application Manifest File" and click Add Double Click your newly created manifest file and change the <requestedExecutionLevel level="asInvoker" uiAccess="false" /> to <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> Then the WPF application would run as Administrator. References link:  https://stackoverflow.com/a/53431997

How to make Windows Service start as "Automatic (Delayed Start)" ?

  Now that .NET 4.0 is here: serviceInstaller1.StartType = ServiceStartMode.Automatic; serviceInstaller1.DelayedAutoStart = true ; https://stackoverflow.com/a/9525289

Stop and Start a service via batch or cmd file?

  net start [serviceName] and net stop [serviceName] tell you whether they have succeeded or failed pretty clearly. For example U:\>net stop alerter The Alerter service is not started. More help is available by typing NET HELPMSG 3521. If running from a batch file, you have access to the ERRORLEVEL of the return code. 0 indicates success. Anything higher indicates failure. As a bat file,  error.bat : @echo off net stop alerter if ERRORLEVEL 1 goto error exit :error echo There was a problem pause The output looks like this: U:\>error.bat The Alerter service is not started. More help is available by typing NET HELPMSG 3521. There was a problem Press any key to continue . . . Return Codes - 0 = Success - 1 = Not Supported - 2 = Access Denied - 3 = Dependent Services Running - 4 = Invalid Service Control - 5 = Service Cannot Accept Control - 6 = Service Not Active - 7 = Service Request Timeout - 8 = Unknown Failure - 9 = Path Not Found - 10 = Service Already Running -

How to run a ".bat" file during installation?

  62 Well, after much searching and trial and error I have solved this. I'm not sure if this is the best way, but it works. Here's the scenario: I have an application I would like to deploy via a Visual Studio Setup project. In addition to my application files, I would like to create a subdirectory in the target directory that contains a batch (.bat) file. I would like this file to run at the end of the installation process. Here's what you do: Create a setup project and configure as you normally would, including the subdirectory in which you'll place your batch file (you can just place it in the Application Folder directly if you don't want it in a subdirectory). In the "File System" view (right-click on the project in Solution Explorer->View->File System), add the batch file you want to execute  and  cmd.exe (C:\Windows\System32\cmd.exe) Open the "Custom Actions" view (right-click on the project in Solution Explorer->View->Custom Ac

ASP.Net perform auto reload

Imej
Working with SQL Server ROWCOUNT

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

.Net prevent load Microsoft Symbol Servers

Imej
Masa nak run Debug mode dekat .NET, code tu ada error. Lepas tu dengan secara tidak disengajakan tertekan retrieve Reference Microsoft Symbol Server.  Lee simpan kat sini je cara nak ubah balik setting tu.. kalau lupa boleh rujuk balik Bila Run, instead of .NET execute terus application tu, .NET pergi Load Microsoft Symbol Servers. Lama dowh dia load. Jadi dekat belah atas tu, klik Tools > Options... Akan display windows Options macam kat bawah ni. Pergi ke Debugging > Symbols. Lepas tu, pilih option yang belah bawah tu.. Load only specified modules . Kalau nak untick dua2 symbol tu pun boleh je.

.Net Symbol loading for d3d9.dll was skipped because it is not specified in the included modules list

Imej
Lee ada buat function untuk Media Player dekat .NET. Before ni okay je function mcm biasa. Tapi after Lee clean windows.. function tu tak jadi dah then keluar error mcm kat bawah.. Cara Lee solve isu ni adalah dengan update Driver, Error tu muncul sbb .pdb.dll file tu corrupt atau not updated Error seperti di bawah Cara solve, update drive DirectX atau GPU Driver

How to debug C# - Breakpoint & Exception

Imej
 Cara untuk debug code dekat .NET Rujukan utama : Get started debugging multithreaded applications (C#, Visual Basic, C++) https://docs.microsoft.com/en-us/visualstudio/debugger/get-started-debugging-multithreaded-apps?view=vs-2019 Use breakpoints in the Visual Studio debugger https://docs.microsoft.com/en-us/visualstudio/debugger/using-breakpoints?view=vs-2019 Watch variables with Watch windows and QuickWatch https://docs.microsoft.com/en-us/visualstudio/debugger/watch-and-quickwatch-windows?view=vs-2019 7 Ways to Look at the Values of Variables While Debugging in Visual Studio https://devblogs.microsoft.com/devops/7-ways-to-look-at-the-values-of-variables-while-debugging-in-visual-studio/ Rujukan lain: Send messages to the Output window -  https://docs.microsoft.com/en-us/visualstudio/debugger/diagnostic-messages-in-the-output-window?view=vs-2019&redirectedfrom=MSDN&viewFallbackFrom=vs-2015 The program '[3984] dotnet.exe' has exited with code -2147450751 (0x80008081)

C# Garbage Collector

  References: Garbage Collection and C# -  https://www.codingame.com/playgrounds/6179/garbage-collection-and-c Use of Finalize/Dispose method in C# -  https://stackoverflow.com/questions/898828/use-of-finalize-dispose-method-in-c-sharp When is it a good idea to force garbage collection? -  https://softwareengineering.stackexchange.com/questions/276585/when-is-it-a-good-idea-to-force-garbage-collection

Building Visual Studio Setup/Deploy project asks to install 2010 shell integrated

  I actually found a solution to this now over at   Microsoft's Visual Studio Developer Community   (Quoted relevant parts to prevent the likelihood of future dead links): 1- Open a cmd as admin. 2- Go to directory C:\Program Files (x86)\Common Files\microsoft shared\MSI Tools 3- run: regsvr32.exe /u mergemod.dll" 4- run: regsvr32.exe mergemod.dll" I followed these steps, restarted VS2017 and it worked perfectly. No more request for the VS2010 Integrated Shell installer! References:  https://stackoverflow.com/a/52031193 https://developercommunity.visualstudio.com/t/building-a-microsoft-visual-studio-2017-installer/198143#T-N217923

Invoke or BeginInvoke cannot be called on a control until the window handle has been created

 Invoke or BeginInvoke cannot be called on a control until the window handle has been created Reference: https://stackoverflow.com/questions/7181756/invoke-or-begininvoke-cannot-be-called-on-a-control-until-the-window-handle-has

mylog.WriteEntry(" Error (List Stn) :" + ex.Message);

Imej
  To give  Network Service  read permission on the  EventLog/Security  key (as suggested by Firenzi and royrules22) follow instructions from  http://geekswithblogs.net/timh/archive/2005/10/05/56029.aspx Open the Registry Editor: Select  Start  then  Run Enter  regedt32  or  regedit Navigate/expand to the following key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security Right click on this entry and select Permissions Add the  Network Service  user Give it Read permission UPDATE:  The steps above are ok on developer machines, where you do not use deployment process to install application. However if you deploy your application to other machine(s), consider to  register event log sources during installation  as suggested in  SailAvid's  and  Nicole Calinoiu's  answers. I am using PowerShell function (calling in Octopus Deploy.ps1) function Create - EventSources ( ) { $eventSources = @( "MySource1" , "MySource2" ) foreach ( $sour

Cannot connect to the ManagementScope via C#. Access denied

  Rujukan https://stackoverflow.com/a/6348152 Access Denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED) Docs Microsoft Connecting to WMI on a Remote Computer Connecting to WMI Remotely with C# Securing a Remote WMI Connection Setting up a Remote WMI Connection Troubleshooting a Remote WMI Connection

Create installer for .Net Windows Service using Visual Studio

How to create an installer for a .net Windows Service using Visual Studio Nor Kelsey, nor Brendan solutions does not works for me in Visual Studio 2015 Community. Here is my brief steps how to create service with installer: Run Visual Studio, Go to  File -> New -> Project Select .NET Framework 4, in 'Search Installed Templates' type  'Service' Select 'Windows Service'. Type Name and Location. Press  OK . Double click Service1.cs, right click in designer and select 'Add Installer' Double click ProjectInstaller.cs. For serviceProcessInstaller1 open Properties tab and change 'Account' property value to 'LocalService'. For serviceInstaller1 change 'ServiceName' and set 'StartType' to 'Automatic'. Double click serviceInstaller1. Visual Studio creates  serviceInstaller1_AfterInstall  event. Write code: private void serviceInstaller1_AfterInstall ( object sender, InstallEventArgs e ) { using (System.Service