October 2003 - Posts

Where to start ?

WOW ! Lots happening with PDC burning the fire and i am totally out of touch now. I am just too confused on where to look and what to read first... there are just too many sites and links to keep track ! Good to know that this is just the start of the excitement !

I am going bonkers on looking at all the new features of ASP.NET 2.0 ! The amount of personalisation looks really cool ! Great effort ! Just checked out the ASP.NET Whidbey site and found lots more articles on that ! Awesome !

Also bumped onto this ! Interesting ! Keep track of this to get a good look on Longhorn SDK !

Source : Fred Palmer from DOTNET-WEB mailing list !

I also just read that anyone who has an MSDN subscription can get the stuff distributed at PDC by calling MSDN customer service:

"Eligible MSDN Subscribers can request the previews by calling MSDN Customer Service. Certified Partners and Breadth ISV / Empower partners should contact their respective Service Centers for further assistance. Note that the preview package contains DVD media, and a DVD drive is required. Please allow 3-4 weeks for fulfillment."

MSDN Customer Service Center: (800) 759-5474 (North America)

The preview includes:

Preview versions of the "Longhorn" operating system and SDK, and Visual Studio "Whidbey".

hmm does someone know of some offer like this in India ?!

Am really missing all the action in PDC ! Eventhough PDC bloggers site is giving a good account of what's happening in PDC in sessions, and the links in there is good too but it can never match the absolute presence at the sessions :( None of my friends too are there and so no editions of Longhorn SDK, Yukon and Whidbey ! Will have to wait until the official subscription offer comes out ! aaarrgh !

Off-Topic blog entry !

Brian Jackson rocks ! A beautiful post which speaks out the right words that most of us wanted to speak when writing some topics that are not of current interest considered off-topic ! I haven't been blogging pretty much recently and with all that's happening in PDC, all that i can do now is to read up all that i've missed ...

Dont forget to read the article if you are one of them who cribs about not churning out elegant .NET posts everyday !

Below total rows count ?!

Index 10 is not non-negative and below total rows count.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Index 10 is not non-negative and below total rows count.

This exception occurred when i was trying to access a particular index of a collection above that of the total count ! hmm .. Well i was really confused on seeing it the first time because it doesn't seem to be good enough to understand what the exception is trying to say exactly ! I got into the dilemma on why someone would throw me an error when my Index is non-negative and below total rows count ?!

Doesn't it sound a little weird to you on reading that ?! Well probably it is just my illusion !

Just realized.

You know that you are deep down into hardcore monotonous work when you realise that you haven't been googling for around a month .. ugghh .. Height of monotonous work habit !

Gotta change ...

Another Server.Tranfer problem.

There are lots many intricacies of .NET that most of us who work on it are unaware of. It is the obvious truth but time and time again, the CLR proves that to you by taxing your brain with weird results and behaviour and makes you think about your coding pattern again ! Recently, one of my team mates got stuck with a really weird Server.Transfer problem and it drove us crazy trying to even find out the problem. Irony it seems that the delicate problem has been encountered by so many people and everyone have been cribbing about it in many forums. I tried to replicate the problem with a simple Web App and guess what, within minutes, my computer was spitting out the same error message too !!!
 
Here's the situation :
 
Just use this code below ... It is a cooked up code but the funda is that whenever you have a Server.Transfer in a try catch block, after some kind of code, or rather preprocessing, then the Server.Transfer will throw up an exception “Thread was being aborted.” Well because we have a Catch that watches over these exceptions, eventhough the exception occurs after the transfer, the Catch block is executed unnecessarily and hence the actual code gets buggered ... This was one major pain in one of our projects recently and took us quite a while to sort it out !
 
Warning : Dont get messed up with such code. 
 
 
   public class WebForm1 : System.Web.UI.Page
   {
      protected System.Web.UI.WebControls.Button Button1;
      public static bool Diversion = false ;
 
      private void Button1_Click(object sender, System.EventArgs e)
      {
          try
          {
               if(Diversion)
               {
                  Diversion = false ;
                  Server.Transfer("Test1.aspx") ;
               }
               else
               {
                  Diversion = true ;
                  Server.Transfer("Test2.aspx") ;
               }
         }
         catch(Exception err)
         {
            Response.Write("Error Message : " + err.Message);
            if(!Diversion)
            {
                  Server.Transfer("Error.aspx") ;
                  Diversion = true ;
            }
         }
      }
 
      override protected void OnInit(EventArgs e)
      {
            this.Button1.Click += new System.EventHandler(this.Button1_Click);
            this.Load += new System.EventHandler(this.Page_Load);
 
            base.OnInit(e);
      }
   }
 
 
One thing to remember about SmartNavigation is how SmartNavigation works. It takes postbacks and renders all the changed items to a hidden IFRAME, then replaces all the innerHTML control elements on the page with the results. This is what gives the illusion of a page that doesn't "jump" when reloaded. Server.Transfer() executes the referred page in the current context and does not actually readdress to it. It just clears the output buffer and executes another page producing output in the same buffer. Watch out for such details which can be important while doing such operations !
 
The workaround for this is to put the Server.Tranfer outside the try-catch block ( which is the obvious answer isn't it ?! ) but oh well the elegant solution for that is to catch the System.Threading.ThreadAbortException and handle it appropriately !!
 
catch(ThreadAbortException e)
{
    throw e;
    // or ignore ;)
}

This problem occurs in the Server.Transfer method because the method internally calls Response.End because of which the thread which has been aborted can no longer serve the consequent execution commands and hence the CLR throws up the exception.

According to one of the MS KB articles, to work around this problem, use the Server.Execute method instead of Server.Transfer. This will solve the issue ! Well this works and solves the problem but another important fact has to be remembered here. The Server.Execute function accepts a URL parameter, stops execution of the current page (where the call to the function is made), and transfers the current environment to the new page. When that new page finishes execution, then control returns to the calling page just after where the Server.Execute was called. (Server.Transfer works the same way but however, upon completion of the execution of the new page, processing ends and Response.End is called for the current context !)

Well that's it for now about Page navigation. Still learning about this and will be glad to hear any other facts that i have missed out.

Happy coding.

CLR Proc Container !

Has anyone tried out the CLR Proc Container from Turtleneck software ? Just downloaded the code for it but haven't tried it out yet.. I was really impressed by the description about the software which reminded me very much of what Yukon could help you out with !!!

Here's the description .. Check it out.

The CLR Proc Container is free software that enhances the capabilities of SQL Server stored procedures by opening a door to the .NET world. Code written in any .NET language can be invoked from stored procedures, providing stored procedures all the functionality of the full .NET runtime. Named procedures can be defined in .NET, dynamic procedures can be created and run, and binary objects passed between stored procedure code and the .NET object.

Windows CONs

Bumped onto a very interesting fact today ! Someone forwarded me a message that said “Try creating a folder named CON in any version of windows!” ... I thought what's new now here and then tried to rename a new folder to 'CON'. hmmm ... Didn't quite expect the outcome ... I guessed that something must have been screwy when someone sent me a mail specifically about renaming something but this looked ridiculous...

Here's what i saw

Try Renaming a Folder as 'CON' and you shall end up with this error ! Weird isn't it ?

 

I guess no one else other than the man ( The Win32 Guru ) who answers questions like “What about BOZOSLIVEHERE and TABTHETEXTOUTFORWIMPS?” can answer this one too ... Raymond care to enlighten us all on this one ?!

Why does ASP.NET App restart?

There is a very informative post by Patrick Y. Ng (email) from the ASP.NET developer team ! He talks about the conditions on which an ASP.NET app restarts, for both V1.0 and V1.1 !! hmm unfortunately he doesn't seem to have a blog yet !

Well dont forget to read it through or else you are going to miss lots of information.

Improved Aggregation Service.

Brian says that the GDN RSS feed is now fixed. I am yet to find out what got buggered in the previous version of the code. I know that the filters weren't there because of which the feed size was huge ! Probably that got the webserver on a spin and it conked off ;(

Well i have remodelled the design completely and now the design is flexible and extensible to accomodate lots of new features and functionalities.. I dont want to limit this to being a GotDotNet aggregator alone but rather want it to be a personal aggregator service which will generate the feed and deliver it the way you want it at your doorstep !

How does the current GotDotNet Rss aggregator Service work ?!

The current service is a request based service where in the xml is not aggregated and maintained in the background but will be generated only when a request comes from the consumer of the feed.. This will lead to a lag in timing for the first user but from then on it is cached for a duration specified in the web.config file and consequent requests are much faster.

Advantage :

           Resources of the webserver needn't be unnecessary consumed when no consumer is requesting for the feed.

Disadvantage :

           There is always one poor soul who bears the brunt of the time lag :(

From now, this is how Rss Aggregator service will work.

  • The request based service stays until i write a windows service to consume the aggregation library to get the feeds. But the aggregation library has become efficient now and can filter out posts according to Date, Categories, and yet to add the functionality to filter using keywords. Also any other kind of filter that you can think of can be included too ! All suggestion for this are welcome.

  • Also made changes to the design to include facility to generate feeds in the required format, which will be specified by the user. Actually the work on this is in progress and Kris is currently working on a class for generation of ATOM feeds. Hopefully we should be able to integrate that into the aggregation engine pretty soon and will set up profile based requests so that feed can be customised and can be delivered to the user.

  • TODO : I have too many ambitious ideas and one of them is to set up an online aggregation server which will process requests from user based on their profile specifications and then deliver the feeds in the required format, with filters specified by the user applied, aggregating the feeds that the user has specified and more ... The ideas keep coming but with all the work pressure currently, it has left me with no free time..

Watch out for these functionalities to happen very soon in the aggregation service :)

Just finding enough time to read the interesting posts and keeping track of what's happening currently now .. Explains why i've been not been blogging enough lately ! aaarggh..

Anything can happen in a blog.

Oh yeah ... beleive me ! I've had it when someone posts a comment to one of my posts around 2 1/2 months old ! WOW ! Really kewl ..

Never ever seen a comment come so late for a post in blogworld where in comments keep bubbling, until the post's half-life reduces below 5 mins .. but this is wonderful ;)

Chris Strikes again.

I think Chris took exception when someone wrote that Suzanne Cook might be his equal in the technical blogging department – he has now given us a positively voluminous opus on exception handling.  If you like the gory details, you’ll love this one! 

Source : Bruce Williams.

Exception Model he starts... I am already confused ! And the best part is that Chris says

        So for the first time I decided to have some CLR experts read my blog entry before I post it.

Better read this right now or you are going to miss out lots of things !

Zen of Programming.

Bumped onto Scott Hanselman's “.NET Zen Koans” .. Really cool. I particularly liked the one on Objects !

Here's mine on Objects.

Played around with Objects but forgot not it's source,

Used it wisely and squandered not the resource.

In that OhNoSecond, all thy unmanaged work conks off

Reminding about the runtime, the omniscient managed framework.

Quit thy menial tasks now and start writing managed code

From now, .NET shall wash your bowl.