{"id":65656,"date":"2021-07-10T04:10:06","date_gmt":"2021-07-10T08:10:06","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/debug-and-trace-classes-in-net-misc-net\/"},"modified":"2021-07-10T04:10:06","modified_gmt":"2021-07-10T08:10:06","slug":"debug-and-trace-classes-in-net-misc-net","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=65656","title":{"rendered":"Debug and Trace classes in .Net #Misc .Net"},"content":{"rendered":"<p>Brought from our old-site (yes, pretty old short-note): http:\/\/salearningschool.com\/displayArticle.php?table=Articles&amp;articleID=636&amp;title=Debug%20and%20Trace%20Classes%20in%20.Net<\/p>\n<p><b>Debug and Trace classes in .Net<\/b><\/p>\n<p>You can always debug your applications line by line. However, when the applications get very bigger\/larger, debugging line by line may not be an efficient way for finding errors in code (well, you can first find out the error region and then can debug line by line). Debug and Trace classes are handy in such cases. Using Debug and Trace classes, you can find errors and write them in a file or create an event log. Later, you can check the file or the event log to see what kinds of  errors the applications are causing. They both provide the same functionalities except that Debug class works only in the debug mode. Trace can work even after the applications are released and also you can control the error reporting from released versions. In a .config file you can  change the behavior of the Trace class.<\/p>\n<p><b>Logging Trace Output into a text file<\/b><\/p>\n<ul>\n<li>1. Create a FileStream object instance and map it to a file<\/li>\n<li>2. Create a TextWriterTraceListener instance and make the text file as the targe of this listener<\/li>\n<li>3. Add this listener to the Trace.Listeners collection<\/li>\n<li>4. set Trace.AutoFlush to be true<\/li>\n<li>5. where required you can use Trace.Write method to send error messages to the  file<\/li>\n<li>6. Trace.Write, Trace.WriteLine, Trace.WriteIf, Trace.WriteLineIf can be used to send error message to the file<\/li>\n<li>7. Trace.Assert method writes error messages only if the supplied condition fails.  Trace.Assert also displays the error in a MessageBox<\/li>\n<li>8. Trace.Fail causes an Trace.Assert unconditionally<\/li>\n<\/ul>\n<p><b>Logging Trace output into an Event Log <\/b><\/p>\n<ul>\n<li> 1. Create or open an Event Log <\/li>\n<li> 2. Set the Source property of Event Log<\/li>\n<li> 3. Create an instance of EventLogTraceWriter and specify the new event log as it&#8217;s target<\/li>\n<li> 4. Use Trace.AutoFlush[automatic sending], or Trace.Flush [send error messages explicitly]<\/li>\n<li> 5. Where required, you can use Trace.Write method to send error messages to the  file<\/li>\n<li> 6. Trace.Write, Trace.WriteLine, Trace.WriteIf, Trace.WriteLineIf can be used to send error messages to the file<\/li>\n<li> 7. Trace.Assert method writes error messages only if the supplied condition fails.  Trace.Assert also displays the errors in a MessageBox<\/li>\n<li> 8. Trace.Fail causes a Trace.Assert unconditionally<\/li>\n<\/ul>\n<p><b>TraceSwitches<\/b><\/p>\n<p>TraceSwitch\/BooleanSwitch class can be used to control the error messaging that the Trace class generates.<\/p>\n<p> From: http:\/\/sitestree.com\/?p=3753<br \/> Categories:Misc .Net<br \/>Tags:<br \/> Post Data:2016-07-17 09:54:12<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Brought from our old-site (yes, pretty old short-note): http:\/\/salearningschool.com\/displayArticle.php?table=Articles&amp;articleID=636&amp;title=Debug%20and%20Trace%20Classes%20in%20.Net Debug and Trace classes in .Net You can always debug your applications line by line. However, when the applications get very bigger\/larger, debugging line by line may not be an efficient way for finding errors in code (well, you can first find out the error region &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=65656\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-65656","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":69926,"url":"http:\/\/bangla.sitestree.com\/?p=69926","url_meta":{"origin":65656,"position":0},"title":"Debug and Trace Classes in .Net #18","author":"Author-Check- Article-or-Video","date":"August 22, 2021","format":false,"excerpt":"Debug and Trace classes in .Net You can always debug your applications line by line. However, when the applications get very bigger\/larger, debugging line by line may not be an efficient way for finding errors in code. Debug and Trace classes are handy in such cases. Using Debug and Trace\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65677,"url":"http:\/\/bangla.sitestree.com\/?p=65677","url_meta":{"origin":65656,"position":1},"title":"Debugging in .Net, (XML Web Services) #Misc .Net","author":"Author-Check- Article-or-Video","date":"July 11, 2021","format":false,"excerpt":"Brought from: http:\/\/salearningschool.com\/displayArticle.php?table=Articles&articleID=1117&title=Debugging%20in%20.Net,%20(XML%20Web%20Services) Just listing some related notes. Tools: DbgClr -GUI Based, CorDbg - command line based You can use the debug menu. Start, Step Into, Step Over, New Breakpoint options - as available in most Good to great IDEs for debugging Watch Window: Check the values of variables and\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":69390,"url":"http:\/\/bangla.sitestree.com\/?p=69390","url_meta":{"origin":65656,"position":2},"title":"Debugging in .Net, (XML Web Services) #24","author":"Author-Check- Article-or-Video","date":"August 20, 2021","format":false,"excerpt":"May not make sense to all. Just listing some related notes. Tools: DbgClr - GUI Based, CorDbg - command line based You can use the debug menu. Start, Step Into, Step Over, New Breakpoint options - as available in most Good to great IDEs for debugging Watch Window: Check the\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":75845,"url":"http:\/\/bangla.sitestree.com\/?p=75845","url_meta":{"origin":65656,"position":3},"title":"In Bengali, PHPStorm Debug Configuration for PHP and Laravel applications","author":"Sayed","date":"July 9, 2023","format":false,"excerpt":"https:\/\/youtu.be\/FxCPKPchsLk","rel":"","context":"In &quot;From Youtube Channel&quot;","block_context":{"text":"From Youtube Channel","link":"http:\/\/bangla.sitestree.com\/?cat=1952"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/img.youtube.com\/vi\/FxCPKPchsLk\/0.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":20696,"url":"http:\/\/bangla.sitestree.com\/?p=20696","url_meta":{"origin":65656,"position":4},"title":"Netbeans IDE for PHP; How to Debug PHP Applications","author":"Author-Check- Article-or-Video","date":"February 26, 2021","format":false,"excerpt":"From: http:\/\/sitestree.com\/?p=369 Categories:Web Development, Root, By Sayed AhmedTags: Post Data:2013-09-07 20:52:32","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10464,"url":"http:\/\/bangla.sitestree.com\/?p=10464","url_meta":{"origin":65656,"position":5},"title":"DebugExample.jsp Page that uses the DebugTag custom tag","author":"","date":"August 28, 2015","format":false,"excerpt":"# DebugExample.jsp Page that uses the DebugTag custom tag <!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\"> <!-- Illustration of SimplePrimeTag tag. Taken from Core Web Programming Java 2 Edition from Prentice Hall and Sun Microsystems Press, . May be freely used or adapted. --> <HTML> <HEAD> <TITLE>Using the Debug Tag<\/TITLE>\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65656","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=65656"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65656\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65656"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}