system.diagnostics

“Gracefully” killing a process

浪尽此生 提交于 2019-12-04 15:27:27
问题 Right now I am using Process.Kill() to kill a process. Is there a way though, instead of just killing it immediately, that I can like send a message to the process instructing it to close so that it can gracefully clean up and shut down. Basically, I'm looking for the equivlent to just clicking the red X in the upper right hand corner, which I believe DOES send a message to the application requesting a shut down. 回答1: If the process has a windows interface (as you refer to the red "X"), you

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

 ̄綄美尐妖づ 提交于 2019-12-04 13:46:00
问题 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 issue. Changing from ApplicationPoolIdentity to LocalSystem seemed to do the trick. However, in our production environment changing the User that runs to LocalSystem is a no go. I suspect it has something to do with the security permission needed to

restart via code on windows 10 uwp

烂漫一生 提交于 2019-12-04 13:05:48
We've created a Windows 10 application that runs on tablets in Windows 10 kiosk mode. It works just fine, however, the wifi connection gets lost sometimes since the locations are very remote. We tried fixing the issue from the networking side, but when the devices lose and regain internet access the application will still hang as if it doesn't have internet access displaying a blank page. Where these devices are used, they are bolted into the wall to prevent theft. Which means if we want to reboot its very time consuming as we have to unscrew the cases off the wall and then open the cases to

Event Logging IPAddress does not always resolve

别说谁变了你拦得住时间么 提交于 2019-12-04 13:00:58
问题 I am hooking the Security event log with System.Diagnostics.Eventing.Reader.EventLogWatcher class, and I am watching Event ID 4625 on a 2008 server box, for incoming failed logins (RDP, specifically). The log capturing is working fine, and I am dumping the results into a queue for related, later processing. However, sometimes the logs captured have the IPAddress data field filled (resolved), and sometimes they do not. I have run windump while watching the server, trying my usual RDP logins

System.Diagnostics.Debug namespace vs Other logging solutions (log4net, MS Enterprise Library, etc.)

拈花ヽ惹草 提交于 2019-12-04 09:16:46
问题 I'm currently investigating various logging possibilities for .net projects and I can't decide between System.Diagnostics.Debug/Trace features and third party libraries like log4net, MS Enterprise Library, NLog, etc. At the moment I have found out this: System.Diagnostics is rather difficult to configure and to use since you need to explicitly configure all the listeners, filters, sources, etc. It seems that it also lacks the bulk insertion to the DB (think about writing 100'000 log entries

System.Diaganostics.Process.Id Isn't the Same Process Id Shown in Task Manager. Why?

冷暖自知 提交于 2019-12-04 04:42:40
I'm using C#'s System.Diagnostic.Process object. One of its properties is Id . The Id this produces is not the same as the PID , shown in Windows Task Manager . Why is this? You see, once this process is started. It launches two other unmanaged processes, for which I can't explicitly get IDs for by object property references. I have to search through all processes to find them by process name via System.Diagnostics.Process.GetProcesses() . I'm trying to find a reliable way to kill this process and all associated processes by PID , the one that shows in Task Manager . Is there a better way? I

Difference between using Trace and TraceSource

与世无争的帅哥 提交于 2019-12-03 22:06:25
Anyone knows the difference between System.Diagnostic.Trace and System.Diagnostic.TraceSource classes? I've been using Trace for most of my projects and I just happen to found out about TraceSource the other day. They seems to offer similar API, is one better than the other? TraceSource is the newer version (since .NET 2) and Trace is the older version, more info is available here: Clarification on TraceSource/Trace TraceSource allows you to enhance the granularity over your tracing : in your config file you can enable/disable only the tracesource you want at the level you want (information,

Get line numbers of fields without using a c# parser

半世苍凉 提交于 2019-12-03 16:36:59
I would like to get the line #s of a type's fields. To get the line #'s of the statements in a method it is simple enough: Type type = typeof(MyClass); MethodInfo methodInfo = type.GetMethod("SomeMethod"); int token = methodInfo.MetadataToken; ISymbolReader reader = SymUtil.GetSymbolReaderForFile(@"dllName", null); // from mike stall's pdb2xml ISymbolMethod methodSymbol = reader.GetMethod(new SymbolToken(token)); int count = methodSymbol.SequencePointCount; ISymbolDocument[] docs = new ISymbolDocument[count]; int[] startColumn = new int[count]; int[] endColumn = new int[count]; int[] startRow

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

冷暖自知 提交于 2019-12-03 09:31:21
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 issue. Changing from ApplicationPoolIdentity to LocalSystem seemed to do the trick. However, in our production environment changing the User that runs to LocalSystem is a no go. I suspect it has something to do with the security permission needed to run unmanaged code. Is there another way to make Tracing work under ApplicationPoolIdentity? Or (as our

What is the best way to log exceptions using ETW?

♀尐吖头ヾ 提交于 2019-12-03 07:24:37
问题 Is there a standard way to log exceptions using ETW? As far as I have seen the only way to do this is to log the message and possibly the inner exception message as there is not strongly typed parameter for the Exception type. 回答1: Use an extra Event and fire this event in the catch block and pass the exception message as a parameter to the Event [Event(1, Message = "Application Falure: {0}", Level = EventLevel.Error, Keywords = Keywords.Diagnostic)] public void Failure(string message) { if