Thursday, August 24, 2006

Hey guys, how are you these hot and exhausting days?? I am pretty OK, except for the heat...

If you didn't hear about the ReSharper yet, some words about it:
ReSharper is an add-on to Visual Studio 2003 and 2005, It comes equipped with a rich set of features that greatly increase the productivity of C# and ASP.NET developers. With ReSharper you get intelligent coding assistance, on-the-fly error highlighting and quick error correction, as well as unmatched support for code refactoring, unit testing, and a whole lot more. All of ReSharper's advanced features are available right from Visual Studio.

This add-on includes features like: Error Highlighting and Quick-Fixes, Advanced Coding Assistance, Numerous Refactorings, Navigation and Search, Unit Testing, ASP.NET Editing, NAnt and MS Build Scripts Editing. More details you could read in the link attached below.

So, you can try using this good add-on by downloading a 30-day evaluation from the jetbrains.com site here, and if you will like it I suggest to buy it (on your company account of course :))

Posted by: Eran Nachum (c)
Post Date: 8/24/2006 9:21:38 AM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | Comments [2] | Trackback   #
 Monday, August 21, 2006

Hello!

Yesterday while surfing on the web in purpose to find some interesting tutorials and innovations, I encountered with a nice article that has been written by my college's mate, Evyatar Ben-Shitrit.

This control derives from ListBox, supports a horizontal scroll bar, and yet behaves like the ASP.NET ListBox control. More in this article, he explains the creation of the ScrollableListBox custom control (written by him).

So, I recommend reading this one at thecodeproject web site here.

Fare well...

Posted by: Eran Nachum (c)
Post Date: 8/21/2006 2:31:30 PM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | Comments [5] | Trackback   #
 Wednesday, August 02, 2006

Hello!

I am still working on a big web application in work. I will glad to tell you about the application, but this is for other conversation. I am glad to say that we are close to the end of the project and doing now last fine tuning on it.

The thing that I had to deal with for the last days is all the issue with publishing application errors in orderly fashion to the event viewer. The reason of doing it is to get the ability of tracking in runtime, bugs, errors or exceptions that can be appear while the application is in production. In this case we don't have the CLR debugger to find what was wrong (if something happend of course...), so we must publish the exception to the system's event viewer or just  to a simple Log file (which less recommended then publishing to the system's event viewer).

Now, to the implementation (the imporatnt thing!!!)

In order to publish error to the event viewer, we need to use the Microsoft.ApplicationBlocks.ExceptionManagement assembly of Microsoft. This assembly expose us all the publishing tools that we will need to publish an errors (and more...).

In my web application, in global.asax file, in Application_Error method, I wanted to publish the exception to the event viewer. It is very important to do it there, because in every application error, like runtime errors, exceptions and actions that the application and systme doesn't know to deal with, this method is being called (by the application of course).

Now, before publishing the error to the event viewer, you need to distinguish between the different exceptions. Do it with your own information about every exception that is happening but, it is important to know that also in every response's redirect (Response.Redirect (" ... ", true) or server's transfer (Server.Transfer (" ... ", true) an ThreadAbortException is being raised.

Exception lastError = Server.GetLastError();

if (Server.GetLastError() is ThreadAbortException || lastError.InnerException is ThreadAbortException)
{
   // Eat the exception - caused by Response.Redirect(..., true) or Server.Transfer(..., true).
   Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(lastError.GetBaseException());
   Server.ClearError();
}
else
{
   Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(lastError.GetBaseException());
   Server.ClearError();
   Server.Transfer("~/Error.aspx", false);
}

By this example you can see the publish exceptions handling.

Now, do not forget to declare in the web.config file the appliation name and the exceptions pulishing handling:

<exceptionManagement mode="on">
        <publisher assembly="Microsoft.ApplicationBlocks.ExceptionManagement" type="Microsoft.ApplicationBlocks.ExceptionManagement.DefaultPublisher" applicationname="APPLICATION_NAME"/>
</exceptionManagement>

One more thing... you need to register this assembly with the appliation name in the registry in purpose to let the application all the rights to publish the error in the event viewer, if you won't do it, the system won't let you write to the event viewer and you will get the exception: The event source ExceptionManagerInternalException does not exist and cannot be created with the current permissions. security exception and you will spend planty of time trying to solve it :) (like me...)

How to register this to the registry you ask?

Open notepad and write there this code:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\APPLICATION_NAME]
"EventMessageFile"="C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\EventLogMessages.dll"

Save this file with .reg extension and double click on it, this will register this to the system's registry.

So, bye for now...

Posted by: Eran Nachum (c)
Post Date: 8/2/2006 7:47:28 AM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | Comments [2] | Trackback   #