W3WP.exe*32 crashed whenever trying to read VPS Disk Space

95 views Asked by At

I tried two different codes to get the C Drive Disk Space on my VPS, they are as follows:

System.IO.DriveInfo di = new System.IO.DriveInfo("C");
Console.WriteLine(di.TotalFreeSpace);

And other one is

using System;
using System.Management;

public string GetFreeSpace();
{ 
    ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
    disk.Get();
    string freespace = disk["FreeSpace"];
    return freespace;
}

Now these codes are working fine on localhost, however, whenever I am running them under ASP.Net (FW4) Application, W3WP.exe crashes and IIS technicaly restart automatically.

Is there a way around to get the disk space on my VPS without crashing the W3WP.exe ?

I am using IIS 7.5 with Windows Server 2008 R2 Standard from GoDaddy

Any help appreciated :)

1

There are 1 answers

1
Peter Kiss On

I think you have to run the AppPool under a different user not the default AppPoolIdentity user becouse maybe it doesn't have enough privilage to access this information.