How might I see the SQL query generated from LINQ to SQL when debugging inside a WCF service? I thought I might just set dataContext.Log = Console.Out and the SQL would be written to the output/immediate window. It doesn't--is that because I am hosting using IIS? Console.WriteLine("Hello") doesn't even write anything to the output/immediate window.
How do see my console output?
IDE used is visual studio 2019. static void Main(string[] args) { int x; int y; Console. WriteLine("Enter the first value"); x = Convert.
In Solution Explorer, right-click the WCF Client project and then click Set as Startup Project. Enable debugging in the app. config or web. config file.
Visual Studio Output Window usage and description. A developer also can display application runtime diagnostic messages to the output window using Debug or Trace class from . NET API. The output window can be open in two ways, first is from the menu bar, select View > Output, or using the shortcut key Ctrl+Alt+O.
The easiest way to debug a self-hosted WCF is to configure Visual Studio to launch both client and server when you choose Start Debugging on the Debug menu. If the WCF service is self-hosting inside or a process that cannot be launched in this manner, such as NT service, you cannot use this method.
You can try to use System.Diagnostics.Debug.WriteLine(), so when you distribute Release app these lines will be stripped out from code.
You may want to write it to a file instead. dataContext.Log takes any TextWriter.
See this comment for a nice way to get a text writer writing to Debug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With