system.diagnostics

How get value of parameters in stacktrace

对着背影说爱祢 提交于 2019-11-28 09:08:31
I can get information about a parameter by StackTrace using something like this: catch (Exception ex) { var st = new StackTrace(ex); System.Reflection.ParameterInfo pi = st.GetFrame(0).GetMethod().GetParameters().First(); } I want know how i get the value of parameter. Example: If my method in stack trace was like: void MyMethod(object value) And the call was like: MyMethod(10); I want to get the value 10. How i do that? There are two ways. The more powerful is the COM API for .NET Debugging. For example, arguments and local variables of function in the call stack are both accessible from

FileVersionInfo.GetVersionInfo() incorrect in Console Application

老子叫甜甜 提交于 2019-11-28 08:53:31
问题 I'm getting some serious weirdness using FileVersionInfo.GetVersionInfo() and was hoping somebody might be able to help. The basics of the issue is that I am iterating through all the files in a folder calling GetVersionInfo() on each. There are about 300 files. This works ok for all but 2 of the files. For these DLLs I am getting comepletely incorrect info back from GetVersionInfo(). In order to eliminate all other variables, I extracted this call into a simple test app and it still got the

Difference between ElapsedTicks, ElapsedMilliseconds, Elapsed.Milliseconds and Elapsed.TotalMilliseconds? (C#)

拜拜、爱过 提交于 2019-11-28 05:44:04
I'm totally confused between these 4. What is the difference between ElapsedMilliseconds (long), ElapsedTicks (long), Elapsed.TotalMilliseconds (double) and Elapsed.Milliseconds (int)? I have a function { Stopwatch sw = new Stopwatch(); sw.Start(); MyTimeConsumingAction(); sw.Stop(); sw.//what? } How do I get the correct time consumed by my long running process from elapsed property of Stopwatch object in milliseconds? Edit: I tried msdn documentation but it isn't anything detailed there.. Dr. ABT Elapsed.TotalMilliseconds (double) returns the total number of whole and fractional milliseconds

System.Diagnostics.Debug.WriteLine in production code

吃可爱长大的小学妹 提交于 2019-11-28 05:11:03
I should probably know this already, but I'm not sure and I don't see it documented. I use System.Diagnostics.Debug.WriteLine quite often during the development process to be able to track changes to variables or exceptions as I'm debugging the code. This is meant to make development and understanding what's happening easier only during development. I normally either comment out the code or delete it when I go to production. I'm wondering what happens if I forget to comment the code out. Say, for example, that during the development cycle, I'm tracking error information that may log a

How to translate MS Windows OS version numbers into product names in .NET?

江枫思渺然 提交于 2019-11-28 04:41:45
How to translate MS Windows OS version numbers into product names? For example, in .NET the following two properties could be used to work out that the product is MS Windows Vista Ultimate Edition : Environment.OSVersion.Platform returns Win32NT Environment.OSVersion.Version returns 6.0.6001.65536 Avram howto net os version VB: Public Function GetOSVersion() As String Select Case Environment.OSVersion.Platform Case PlatformID.Win32S Return "Win 3.1" Case PlatformID.Win32Windows Select Case Environment.OSVersion.Version.Minor Case 0 Return "Win95" Case 10 Return "Win98" Case 90 Return "WinME"

When should I use Tracing vs Logger.NET, Enterprise Library, log4net or Ukadc.Diagnostics?

微笑、不失礼 提交于 2019-11-28 02:49:13
How do I choose between standard tracing, Logger.NET, Enterprise Library, log4net or Ukadc.Diagnostics? Is there a situation where one is more appropriate than the other? ... what would that be? (ASP.NET, console app, Azure Cloud, SOHO, Enterprise...) What are the benefits or drawbacks? Did I miss any other major logging frameworks? wageoghe There are many similar questions here on SO: Logging best practices log4net versus TraceSource Silverlight Logging framework and/or best practices log4net vs. Nlog What's the point of a logging facade? C# Logging. What should I use? You missed several

Can Stopwatch be used in production code?

二次信任 提交于 2019-11-27 20:20:45
I need an accurate timer, and DateTime.Now seems not accurate enough. From the descriptions I read, System.Diagnostics.Stopwatch seems to be exactly what I want. But I have a phobia. I'm nervous about using anything from System.Diagnostics in actual production code. (I use it extensively for debugging with Asserts and PrintLns etc, but never yet for production stuff.) I'm not merely trying to use a timer to benchmark my functions - my app needs an actual timer. I've read on another forum that System.Diagnostics.StopWatch is only for benchmarking, and shouldn't be used in retail code, though

Is my process waiting for input?

隐身守侯 提交于 2019-11-27 19:49:09
I am using the Process class to run an exe. The exe is a 3rd party console application that I do not control. I wish to know whether the process is waiting for input on the command line. Should it make any difference, I intend to kill the application should it be waiting for input. There are suitable events for when there is output from the program waiting to be read, but I cannot see anything similar for when the process is waiting patiently for input. ProcessStartInfo info = new ProcessStartInfo(); info.FileName = "myapp.exe"; info.CreateNoWindow = true; info.UseShellExecute = false; info

How do I run a Console Application, capture the output and display it in a Literal?

北慕城南 提交于 2019-11-27 17:19:00
问题 I see that I can start processes with System.Diagnostics.Process. I'm trying with the following code, but its not working. The page just hangs and I have to restart IIS... using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Diagnostics; public partial class VideoTest : System.Web.UI.Page { List<string> outputLines = new List<string>(); bool exited = false; protected void Page_Load(object sender, EventArgs e) {

Trace file isn't being created even though TraceEvent is called?

邮差的信 提交于 2019-11-27 08:44:43
问题 Objective Use System.Diagnostics to perform tracing. Though I have used log4net and other logging solutions, I am only interested in getting tracing to work with System.Diagnostics . Problem Even though I'm issuing the TraceEvent the file is not being created anywhere. Application Information I have an application that's hosting some WF services. One of the services is a state machine with an initial state that looks like this: the LogMessage custom activity is also very straight forward. It