How to Defragment .NET

book

Article ID: 180680

calendar_today

Updated On:

Products

Management Platform (Formerly known as Notification Server)

Issue/Introduction

 

Resolution

Question
What are the steps required to defragment the .NET Framework on my Notification Server and why is it necessary?

Answer

When workers are getting licensing errors on Helpdesk, this is due to an excessive amount fragmented temp files in the “Temporary ASP.NET Files” folder. As the number of assemblies that are loaded in a process grows, the virtual address space can become fragmented. When the virtual address space is fragmented, out-of-memory conditions are more likely to occur. To prevent a large number of assemblies from loading in a process, ASP.NET tries to compile all pages that are in the same directory into a single assembly. This occurs when the first request for a page in that directory occurs. In the case of our software, the amount of items that are constantly being cached, grows which in turn causes memory problems. Removing these files/folders removes everything from memory and allows a clean start.

First try to restart .NET to clear all of its current memory accations and let it start with a fresh memory set. 

  1. Run "services.msc" and hit the restart on all of the Altiris services.
  2. Run "iisreset" IIS (run "iisreset"). 

If this does not work, then it maybe an issue with the pre-compiled .NET code.  To force .NET to reset and recompile every page.  The following steps can be followed. 

  1. Run "iisreset /stop" to stop all Internet services.
  2. Stop all Altiris services 
  3. Delete all the files and folders under C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files.
  4. Restart the Altiris services
  5. Restart all internet services by running "iisreset /start"

In extreme cases, .NET itself may be corrupted and may need to be completely re-installed, but this should be reserved only if the above attempts are still falling.

  1. Run "iisreset /stop" to stop all Internet services.
  2. Stop all Altiris services 
  3. Delete all the files and folders under C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files
  4. On the Notification Server computer, open a command window (Run Command). Use Windows Explorer to go to C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 (or equivalent in your environment). Register your aspnet_isapi.dll by dragging it into the command window and adding regsvr32 command on the front of the path.

    regsvr32 "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll"

  5. Run the following command line to view the Notification Server Web applications associated to .NET 1.1.4322 (Note: Run the following commands from the Run prompt or from the C prompt.):

    C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe –lk

    Note: -lk lists all the path of all IIS metabase keys where ASP.NET is scriptmapped, together with the version. Keys that inherit ASP.NET scriptmaps from a parent key will not be displayed.

    Note: The aspnet_regiis.exe utility is an administration utility that manages the installation and uninstallation of multiple versions of ASP.NET on a single computer.
  6. Run the following command line to remove the all associations to .NET 1.1.4322:

    C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -k W3SVC/

    Note: -k <path> removes all scriptmaps to any version of ASP.NET from the specified path, recursively. For example, aspnet_regiis.exe -k W3SVC/1/ROOT/SampleApp1.
  7. Run the following command line to add the Notification Server Web applications back to .NET 1.1.4322:

    C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe –i

    Note: The -i parameter installs this version of ASP.NET and updates scriptmaps at the IIS metabase root and for all scriptmaps below the root. Existing scriptmaps of lower versions are upgraded to this version.
  8. Restart all the Altiris services
  9. Restart all internet services by running "iisreset /start".

NOTE: This is not to be used on Notification Server 7 as it uses .NET 2.0 and the above sets 1.1 as the default to Default Web Site. If performed on NS 7, just edit the Default Web Site back to .NET 2.0.