Testing/Debugging/Logging

Unit, integration and regression testing

How to disable messages for category based on severity in EnterpriseLibrary logging configuration

Microsoft documentation article Source Schema for the Logging Application Block is very hard to follow,the set of articles http://www.education.vic.go... is much betterFinally I found Log Event to Listener Routing in Enterprise Library article, that very clear described available options , how to disable/enable logging There are three Filters provided out of the box including a LogEnabledFilter which is a very effective...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Compiler doesn’t report missing 'Microsoft.Practices.ServiceLocation”

I’ve upgraded Enterprise Library form 4. to 5 and replaced references to the DLLs (in particular we are using EnterpriseLibrary.Logging”) Compiler doesn’t report any errors about missing dependencies however at run time I’ve got Could not load file or assembly 'Microsoft.Practices.Servic... I had to add the library explicitly. It will be good if the error will be shown during the build. Related links http://stackoverflow.com/qu...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

DDD Melbourne -lessons learned

I've attended DDD Melbourne and want to list the interesting points, that I've learned and want to follow. To read more: * Moles-Mocking Isolation framework for .NET. Documentation is here. (See also Mocking frameworks comparison created October 4, 2009 ) * WebFormsMVP * PluralSight http://www.pluralsight-trai... * ELMAH: Error Logging Modules and Handlers Great for new sites or sites without error logging/monitoring. However if you site already have working error...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Command prompt utility to copy files for specified time range

I've tried to find an utility that will allow to copy files from big folder for specified time range. The discussion in experts-exchange suggested to use RoboCopy (http://www.microsoft.com/d... For the specified date command e.g 2009-11-24 command should be: Robocopy FolderFrom FolderTo /MINAGE:20091125 /MAXAGE:20091124 Note that for 1 day selection MINAGE should be one day BIGGER than required date. I still wish...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Do not check-in DEBUG specific code.

We are using .Net Remoting to interact beteeen client and back end server. I needed to call a method from services class. For debugging purposes I decided to create the class directly. It was easier to debug without starting extra back-end process. The code was like the following: IMyServices services = (IMyServices)RemotingHelper... #if DEBUG services = new MyServices(); #endif // Process the task services.ProcessItems(Items... During the development I checked...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Windows Workflow: Concatenate all parents QualifiedNames- instead of call stack

MSDN Debugging Workflows tells that The entries in the Call Stack window are a depth-first search of executing activities. You can double-click an entry to put focus on the selected activity.-It doesn't work for me. The text on stack trace is not meaningful, when activities are described. > codeRaiseEvent_ExecuteCode(... sender = {codeRaiseEvent_CAGPNRIterate [System.Workflow.Activities... System.EventArgs e = {System.EventArgs}) Line 671 C# System.Workflow.ComponentMo...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Logging application block-how configure different listeners for different level of message.

I've asked on codeplex EntLib forum logging application block-how configure different listeners for different severity? and AvanadeSupport gave me the answer to use "Filter" property of the tracelistener. MSDN Source Schema for the Logging Application Block documents listeners Child Element (loggingConfiguration)/add Child Element Now I am able to make configuration like the following <loggingConfiguration name="Logging Application Block" tracingEnabled="true"> <categorySources> <add...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Debugging Windows Services with "Edit & Continue"

I needed to debug Windows Services. But I didn't like suggested in multiple articles Debugger.Launch. Thanks to post "Debugging Windows Services is a Pain" (and article CodeProject: Debugging Windows Services under Visual Studio .NET) I was able 1. To download Service Debugging Helper (Binary) (or Service Debugging Helper (Binary + Source)) 2. Add in my service project a Reference to AndersonImes.ServiceProcess... 3. Change in the Main() function //ServiceBase.Run(ServicesT... ServicesLoader.StartService...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Avoid throwing exception from asynchronous delegate.

I am using delegate to invoke asyncronous call of the function. Sometimes the function can throw exception. As described in thread Re: exception handling with events , article "Handling Exceptions Thrown from an Asynchronous Delegate"(and in many other places) "You should call EndInvoke in a try/catch block to catch any exceptions your asynchronous method threw". I followed the same approach in my Asynchronous long-running tasks in ASP.NET application The code is like the following: RecalculateDelegate...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Use WCF Message Logging

The post based on How to enable WCF tracing article Open WCF Service Configuration Editor under VS 2008 Tools menu or directly from installation folder (typically C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\SvcCo... - subfolder v6.0 can be different depending on which version of Windows SDK has been installed) To enable WCF message logging Click the Diagnostics node, and expand it. Enable Message Logging on the right Tab To edit Message Logging settings, click the Message Logging...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Enterprise Library Logging Application Block and Alternatives Links

Overview of to Enterprise Library Logging Application Block and Alternatives Loren Halvorson's comparision of the Enterprise Library Logging & Instrumentation Application Block and Log4Net (Published in 2005) Comments on the EntLib/Log4Net feature and performance comparison (Published in 2005) EntLib v4 has a few performance improvements in Logging Block. Based on quick read I feel that Log4Net and NLog are simple and may be sufficient for small applications. But they seems do not support specifying...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Profiling Performance of ASP.NET Code Links

Below are a few links that I found about Profiling Performance of ASP.NET Code Code performance analysis in Visual Studio 2008 and Find Application Bottlenecks with Visual Studio Profiler * Tool : VSProfiler - Analyze Performance of Managed Code How To: Use CLR Profiler and Transcript: Profiling Managed Code with the CLR Profiler are talking about CLR memory allocation profiler. - * Auto Performance Tuning in ASP.NET 2.0 process model (processModel) section of machine.config comes with default value...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Error: control with id ... could not be located or a different control is assigned to the same ID after postback

Our application has the intermittent (not too often,but can be 10-20 per day) errors like the following: An error has occurred because a control with id 'grdComplaints$ctl04$ctl00' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error. System.Web.UI.Page.ProcessP... postData, Boolean fBeforeLoad) +877 System.Web.UI.Page.ProcessR...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

TypeLoadExceptionHolder object can be inserted during unsuccessful Bynary Deserialization

I am using Binary Serialization to save and then reload state ot the object. In my post Issues using binary serialization to store object state for unit tests I described why I have to use it and how I tried to avoid versioning problems. I was able to read the object and access different properties of it withowt any warnings, but later, when the object was tried to be stored in Session, I've got the following error: System.Web.HttpException: Unable to serialize the session state. In 'StateServer'...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Validation of viewstate MAC failed when using asp.timer to trigger UpdatePanel

I have a page with UpdatePanel and ASP:Timer, that refreshs the UpdatePanel every minute. It was noticed that after new release after the first refresh any postback causes "Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster." I've searched Google and found that this error is quite common. Below there are just a few suggestions: I do...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Watin Test Recorder helps to navigate to required for debugging page.

It is quite common, that a developer needs to do a few (sometimes time-consuming) steps to navigate to the pages that are required debugging. And if you do some non-trivial change, Edit&Continue doesn't work, and you have to start debugging again. Yes, I know, that small unit tests should cover all the code paths and make debugging redundant. Unfortunately in the real life debugging is sometimes unavoidable. Watin Test Recorder allows to record the navigation steps and save it as a console executable(or...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Issues using binary serialization to store object state for unit tests

To save object state for unit tests we use binary serialization. The object state saved to data file and at the start of the test is loaded from the file. It works OK until the object will be changed in a new version. Fortunately There is no problem when a new field is added, but if a field is deleted or removed, it most likely will cause deserialization exception(see Version Tolerant Serialization, Net Serialization FAQ, Solving Binary serialization versioning conflicts articles for details). Also...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Unit Testing in .Net Notes.

Some time ago I posted my Unit Testing ASP.NET Applications notes. This post is to put togeter a few links that I found useful about general Unit testing frameworks. MbUnit vs. NUnit Vs. Team System Unit Testing - Choosing a unit test framework NUnit vs Team System Unit Test In our solutions we are using both NUnit and VSTS Unit testing. I like VSTS for the ability to generate test stubs code. But our build server has only VS Professional installed, that doesn't allow to include VSTS projects to...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Function to validate Html Fragment

My code generate some dynamic HTML fragments and I want to know does the html valid. Thanks to HtmlAgilityPack it is easy: Debug.Assert(IsValidHtmlFra... public static bool IsValidHtmlFragment(string html) { HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocumen... doc.LoadHtml(html); return (doc.ParseErrors.Count==0); }...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Reading AppSettings to be Unit Test friendly.

My application uses a lot of AppSettings to enable/disable different function and I wanted to created unit tests for different combination. I found the simplest way is to create static class data field, that is set to null by default, and loaded from config file if it is null. This allows in unit test methods to explicitely assign values, and when you want return to reading from config file, just reset it to null. static private bool? st_bAPIEnabled; public static bool IsAPIEnabled() { st_bAPIDomesticEnabled...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Full Testing/Debugging/Logging Archive

«February»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910