locked
System.Diagnostic.Process.GetCurrentProcess Access Denied Error RRS feed

  • Question

  • I don't know where to start so I will try here first. We are running some code on our web page as follows:

    System.Diagnostics.Process CurProc = System.Diagnostics.Process.GetCurrentProcess();

    When I access CurProc.MainModule.FileName I get the error

    "Access is denied"

    Here is the info for the process

    {System.Diagnostics.Process (w3wp)}
        base: {System.Diagnostics.Process (w3wp)}
        BasePriority: 8
        EnableRaisingEvents: false
        ExitCode: 'CurProc.ExitCode' threw an exception of type 'System.ComponentModel.Win32Exception'
        ExitTime: 'CurProc.ExitTime' threw an exception of type 'System.ComponentModel.Win32Exception'
        Handle: 'CurProc.Handle' threw an exception of type 'System.ComponentModel.Win32Exception'
        HandleCount: 1795
        HasExited: 'CurProc.HasExited' threw an exception of type 'System.ComponentModel.Win32Exception'
        Id: 9336
        MachineName: "."
        MainModule: 'CurProc.MainModule' threw an exception of type 'System.ComponentModel.Win32Exception'
        MainWindowHandle: 0
        MainWindowTitle: ""
        MaxWorkingSet: 'CurProc.MaxWorkingSet' threw an exception of type 'System.ComponentModel.Win32Exception'
        MinWorkingSet: 'CurProc.MinWorkingSet' threw an exception of type 'System.ComponentModel.Win32Exception'
        Modules: 'CurProc.Modules' threw an exception of type 'System.ComponentModel.Win32Exception'
        NonpagedSystemMemorySize: 232124
        NonpagedSystemMemorySize64: 232124
        PagedMemorySize: 298188800
        PagedMemorySize64: 298188800
        PagedSystemMemorySize: 1088496
        PagedSystemMemorySize64: 1088496
        PeakPagedMemorySize: 322125824
        PeakPagedMemorySize64: 322125824
        PeakVirtualMemorySize: 1124806656
        PeakVirtualMemorySize64: 1124806656
        PeakWorkingSet: 395051008
        PeakWorkingSet64: 395051008
        PriorityBoostEnabled: 'CurProc.PriorityBoostEnabled' threw an exception of type 'System.ComponentModel.Win32Exception'
        PriorityClass: 'CurProc.PriorityClass' threw an exception of type 'System.ComponentModel.Win32Exception'
        PrivateMemorySize: 298188800
        PrivateMemorySize64: 298188800
        PrivilegedProcessorTime: 'CurProc.PrivilegedProcessorTime' threw an exception of type 'System.ComponentModel.Win32Exception'
        ProcessName: "w3wp"
        ProcessorAffinity: 'CurProc.ProcessorAffinity' threw an exception of type 'System.ComponentModel.Win32Exception'
        Responding: true
        SafeHandle: 'CurProc.SafeHandle' threw an exception of type 'System.ComponentModel.Win32Exception'
        SessionId: 0
        StandardError: 'CurProc.StandardError' threw an exception of type 'System.InvalidOperationException'
        StandardInput: 'CurProc.StandardInput' threw an exception of type 'System.InvalidOperationException'
        StandardOutput: 'CurProc.StandardOutput' threw an exception of type 'System.InvalidOperationException'
        StartInfo: {System.Diagnostics.ProcessStartInfo}
        StartTime: 'CurProc.StartTime' threw an exception of type 'System.ComponentModel.Win32Exception'
        SynchronizingObject: null
        Threads: {System.Diagnostics.ProcessThreadCollection}
        TotalProcessorTime: 'CurProc.TotalProcessorTime' threw an exception of type 'System.ComponentModel.Win32Exception'
        UserProcessorTime: 'CurProc.UserProcessorTime' threw an exception of type 'System.ComponentModel.Win32Exception'
        VirtualMemorySize: 1124511744
        VirtualMemorySize64: 1124511744
        WorkingSet: 372817920
        WorkingSet64: 372817920
    

    The process is the w3wp process.  I am running IIS 6, my .NET Runtime is set to 4.0, Enabled 32 bit is true, Managed Pipeline mode is integrated and the identity is "ApplicationPoolIdentity". 

    I am at a complete loss so any help would be appreciated, or please point me to the right forum.

    Thanks.

    • Moved by CoolDadTx Tuesday, January 19, 2016 6:04 PM ASP.NET related
    Friday, January 15, 2016 4:53 PM

All replies

  • ASP.NET related questions should be posted in the ASP.NET forums: http://forums.asp.net

    You should also explain what you are trying to achieve, getting the main module name in a web application doesn't make a lot of sense.

    Saturday, January 16, 2016 12:06 PM
  • Moved to forums.asp.net
    Tuesday, January 19, 2016 3:03 PM