Questions tagged [system.diagnostics]

System.Diagnostics is a namespace of the .NET framework. It provides classes that allow you to interact with system processes, event logs, and performance counters.

System.Diagnostics is a namespace of the .NET framework. It provides classes that allow you to interact with system processes, event logs, and performance counters.

References

670 questions
4
votes
3 answers

.NET How to check if a Windows process is running as an "App" or as a "Background application"

On Windows 8.1 you go into the task manager and check the list of processes, there are two lists: - One for "Apps", which are visible foreground apps - One for "Background processes", which are processes running in the background My end goal is to…
Ritterbruder
  • 53
  • 1
  • 3
4
votes
2 answers

How to read from Process.StandardOutput without redirecting it? (F#)

I've got this little function that saves me some headaches from dealing with the horrible System.Diagnostics.Process API: let HiddenExec (command: string, arguments: string) = let startInfo = new System.Diagnostics.ProcessStartInfo(command) …
knocte
  • 16,941
  • 11
  • 79
  • 125
4
votes
1 answer

How to find Active (In Use) Graphic Cards?

I used this code for finding graphic cards: ManagementScope scope = new ManagementScope("\\\\.\\ROOT\\cimv2"); ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_VideoController"); ManagementObjectSearcher searcher =…
Mohammad
  • 528
  • 4
  • 21
4
votes
2 answers

Process.Start with arguments not working

I run this application in command line and get the desired results Helpdesk-02.exe /department it but my C# code (below) appears to ignore the argument but launches the app without the command line switches ProcessStartInfo psi = new…
software is fun
  • 7,286
  • 18
  • 71
  • 129
4
votes
1 answer

Detect if hard disk is being accessed or not

I am trying to make a very simple hard disk access monitor to work like those embedded LEDs that blink according to drive usage. That LED REALLY helps me, but the laptop I am using does not have it. =[ So, I've made a simple tray icon application,…
LuckyScooby
  • 81
  • 10
4
votes
1 answer

How to solve memory leak caused by System.Diagnostics.PerformanceCounter

Summary I have written a process monitor command-line application that takes as parameters: The process name or process ID A CPU Threshold percent. What the program does, is watches all processes with the passed name or pid, and if their CPU usage…
funkymushroom
  • 2,079
  • 2
  • 26
  • 39
4
votes
1 answer

cmd command in c#

I want to import a csv file to mongodb by using mongoimport in C#. So I implement this method public bool importCSV(string filepath, string db, string collectionName){ string result=""; try { ProcessStartInfo…
trallallalloo
  • 592
  • 1
  • 9
  • 25
4
votes
5 answers

Any libraries out there that extend System.Diagnostics.Trace?

Any there any good libraries out there that extend System.Diagnostics.Trace? Some of the features I am looking for. Rolling logs smtp And "Use log4net" is not an answer. The reason being is that i don't want a reference to any third party…
Simon
  • 33,714
  • 21
  • 133
  • 202
4
votes
2 answers

Configuring custom TextWriterTraceListener to web.config

I saw two answers about this topic but I can't figure out. I have a custom TextWriterTraceListener and I want it to use in my tracesource. namespace MyTraceLogger { public class MyTextTraceListener : TextWriterTraceListener { public…
Hieu N Trinh
  • 59
  • 1
  • 11
4
votes
0 answers

Add shared listener for TraceSources without config file

I want to reroute logging from System.Net to NLog:
Vlad
  • 3,001
  • 1
  • 22
  • 52
4
votes
2 answers

PerformanceCounterCategory.Exists is very slow if category doesn't exists

I have kind of library which uses a bunch of its own perf counters. But I want my library works fine even if that perf counters weren't installed. So I've created wrappers aroung PerformanceCounter and on the first use check if PerfCounter exists or…
Shrike
  • 9,218
  • 7
  • 68
  • 105
4
votes
1 answer

execute a process remotely with System.Diagnostics.Process

I'm working on an ASP.net app I'm trying to execute a process remotely , using System.Diagnostics.Process class here's my code: ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\TestCommand.exe"); startInfo.Domain = "myDomain"; …
DJPB
  • 5,429
  • 8
  • 30
  • 44
4
votes
2 answers

Specifying Conditional Trace Listener in Config

I want to make calls like the following in my code: System.Diagnostics.Trace.WriteLine("Starting XYZ..."); and write it to a file as described in the config:
user1017882
4
votes
2 answers

Identify the w3wp System.Diagnostics.Process for a given application pool

I got few web sites running on my server. I have a "diagnostic" page in an application that shows the amount of memory for the current process (very useful). Now this app is 'linked' to another app, and I want my diagnostic page to be able to…
Mose
  • 1,781
  • 3
  • 16
  • 35
4
votes
1 answer

System.Diagnostics.Trace not working in web app under ApplicationPoolIdentity

I have a web application which does (ab)use of System.Diagnostics Tracing. As usual, everything went fine until we hit production this week, where none of our listeners were being hit. Researching a bit, it was clearly a User Account permission…
Mauro2
  • 1,235
  • 1
  • 7
  • 9