Debug NCache Providers in Visual Studio
If you wish to debug the providers for NCache like ReadThru
, WriteThru
, and WriteBehind
, you can do so by attaching the NCache Service to the application. This approach enables run-time debugging through the standard debugging commands.
Important
- You must build the provider in debug mode, as debugging is not enabled for projects created with a release configuration.
- Cache host processes for .NET 6 are called Alachisoft.NCache.CacheHost.exe and dotnet.exe for .NET.
Open Task Manager and go to the details page where processes are listed depending upon the number of caches running on the node.
To select the appropriate cache, click on any default column and choose Select columns in the drop-down menu and enable the Command Line column so it is visible in the details tab.
After selecting the cache from the available options, you can move to your application and attach the provider with the appropriate cache.
Note the PID for the cache against which you want to debug the provider, and then in the Attach to Process... window, select the process with the same PID you want to debug.
In your application, insert a breakpoint in your application from where you want to debug.
From the top menu bar of Visual Studio, click on Debug and select Attach to Process... option as shown below.
- Select
dotnet.exe
orAlachisoft.NCache.CacheHost.exe
in Processes.
Ensure that the Show processes from all users and Show processes in all sessions options are selected.
Click Attach.
Any operation being performed over NCache will throw an exception in the debug code, allowing in depth feature debugging.
Important
For further detail on attaching processes with various configurations to debug, please refer to this Microsoft documentation.