system.diagnostics

Problem launching a System.Diagnostics.Process under Windows 7

久未见 提交于 2019-12-07 05:15:18
问题 I’m trying to launch an application (Operating System, My Application and the application I want to launch are all 32 bits), from .NET 3.51. The code that launches the Process is used for other applications, but there’s one that is giving us a headache. If we “double click” on the application’s icon, it works as expected, meaning that it works fine as an application in the computer. Double clicking the .exe directly, also works. The operating system is Windows 7 32Bits (Home and/or

How to keeps colours from msbuild output?

本秂侑毒 提交于 2019-12-06 20:52:07
问题 When I run msbuild at the command line it shows pretty colours in the console. However when I run it from C# with Process.Start , the output appears in black and white. How can I keep the colours? var info = new ProcessStartInfo("msbuild") { UseShellExecute = false, CreateNoWindow = true, RedirectStandardError = true, RedirectStandardOutput = true, }; using (var p = Process.Start(info) ) { p.ErrorDataReceived += (s, e) => Console.Error.WriteLine(e.Data); p.OutputDataReceived += (s, e) =>

How to Configure Network Tracing Dotnet core for HttpClient calls?

落爺英雄遲暮 提交于 2019-12-06 05:22:48
As per reference document at https://docs.microsoft.com/en-us/dotnet/framework/network-programming/how-to-configure-network-tracing We can setup this in web.config or any other configuration file and we get detailed system.net traces, packets traces for HttpClient calls and any kind of issue in HttpClient calls can be captured in traces, be it certificate, TLS or anything else. However, do we have similar implementation for dotnet core / standard which can be used in both web app or console app/ libraries ? Configuration for dotnet framwork : <configuration> <system.diagnostics> <sources>

ASP.NET and System.Diagnostics tracing - have I missed something, or is this a bad idea?

独自空忆成欢 提交于 2019-12-06 03:42:53
问题 For various common reasons I wanted to use tracing for my ASP.NET application. Especially since I found out about the possibility to use the Service Trace Viewer tool which allows you to examine your traces in a powerful way. Since I had never used this trace thing before, I started stuying it. After a while of Google, SO and MSDN I finally have a good idea of how things work. But I also found one very distrubing thing. When using trace in ASP.NET applications it makes a lot of sense to group

log4net became very slow with caller location information after Windows 10 Fall Creators Update (1709)

£可爱£侵袭症+ 提交于 2019-12-05 23:03:42
I known that the documentation of log4net points out that the logging of caller location information can be very slow and shouldn't be used unless the performance of the software is not affected. And until the Windows 10 Fall Creators Update this was the case. Here is a small example project. app.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" /> </configSections> <log4net> <appender name="DefaultAppender" type="log4net.Appender.RollingFileAppender"> <file value="logging.log

TextWriterTraceListener does not work

走远了吗. 提交于 2019-12-05 19:05:31
Config file: <system.diagnostics> <trace> <listeners> <add name="Console" type="System.Diagnostics.ConsoleTraceListener" initializeData="false"></add> <add name="Text" type="System.Diagnostics.TextWriterTraceListener" initializeData="D:\uat\logs\bifit.log" traceOutputOptions="DateTime"></add> </listeners> </trace> </system.diagnostics> The code: static void Main(string[] args) { try { Trace.WriteLine("Running BiFit Test Server."); } } I can see the text in cosole window. And the file is created, but it empty. I remember there is something like Autoflush property somewhere? You recall correctly

What's the difference between creating a new instance with “new() and ”.StartNew()\"?

时光毁灭记忆、已成空白 提交于 2019-12-05 04:47:34
Coming from my "answer" to question "Stopwatch in a Task seems to be additive across all tasks, want to measure just task interval" What are the possible differences between creating a new Stopwatch instance as: Stopwatch timer = System.Diagnostics.Stopwatch.StartNew(); with Stopwatch timer = new Stopwatch(); timer.Start(); Implied subquestion: Why was StartNew() method provided? StartNew , create new instance of the stop watch and starts it as well. Simple new is Stopwatch instantiation only. It doesn't start the Stopwatch. For your current code where you are creating a new instance and

Does System.Diagnostics.Trace have any performance degredation?

守給你的承諾、 提交于 2019-12-05 04:42:19
I am looking for a simple native .NET error logging solution. I am not interested in using log4net, Elmah or any other logging library. Below is what I am planning on using. My question is performance on my site is paramount and does this flow introduce any performance concerns? Global.asax protected void Application_Start(object sender, EventArgs e) { GlobalFilters.Filters.Add(new HandleExceptionsAttribute()); } Handle Exceptions Attribute: public sealed class HandleExceptionsAttribute : HandleErrorAttribute { private void TraceError(Exception _this) { Trace.TraceError("{0} Exception {1}",

Get line numbers of fields without using a c# parser

让人想犯罪 __ 提交于 2019-12-05 01:06:52
问题 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

System.Diaganostics.Process (when one process internally uses another)

两盒软妹~` 提交于 2019-12-04 17:32:52
I've been using C# System.Diagnostics.Process to monitor the output of a command line utility. The process I'm monitoring "internally" launches a second process, and as soon as it does, I receive no further output from the process object. What's frustrating, is, if you execute the very same command (that I'm launching with the System.Diagnostics.Process object) with cmd.exe (manually), the console outputs every line I need to be seeing in my C# app! However, if I (for testing purposes) launch cmd.exe with the System.Diagnostics.Process object, and run the command, it still stops outputting at