Common Language Runtime Beginner Series Part 1:-CLR Basics

CLR or Common Language Runtime is a very important part of whole .net Framework and its utter importance is not seen by most of us as it works behind the scenes.This beginner series of my articles will help you to know what actually CLR is in simple terms and what are its basic features. Remember this is for beginners, or people who are not as much familiar with CLR. I will try to make this series of articles very simple so that everyone can understand and here and there i will make some simple comparisons so that the fact is understood easily.In simplifying things some facts may sound vague so please pardon me...

  • In earlier days of programming there was no concept of managed code,there was only unmanaged code which means that all the things should be handled by the operating system.
  • The programming languages compiled the programs written in them to the native code specific to the architecture or the CPU.
  • There are many disadvantages of such an approach which we will see one by one in a series of articles.
  • So first of all what is CLR....Actually speaking it can be considered as a small processing unit of its own which when given a Intermediate Language code can produce a native code to be run on that CPU.
  • CLR consists of various parts in which each is a topic of research and discussion and requires an in depth analysis.
  • So the process in which our programs get executed is first of all we have a code in a language it can be VB,C# or C++ now we compile this code using the respective compiler for that language.
  • After this first compilation we receive a IL or Intermediate Language code, now this IL code act as input to the CLR and its Just In Time Compiler chooses the right Model to be executed for compilation for that CPU type.
  • So now the JIT decides according to the CPU type and architecture which mode of compilation it should follow.
  • Now after this decision JIT actually compiles and produces the native code which can be run on that CPU.
  • CLR can be considered as a SandBox environment from which no code can execute outside its given bounds that is the code execution is confined and this is a major advance over the earlier model of program execution.
  • So now you can say that .net can only execute the managed code and there is no need for unmanaged code but this is not true. There are some special cases where  unmanaged code is the best thing till today e.g are device drivers and real time applications where performance is a bottleneck although there are algorithms which will be implemented in future CLR for support of Real Time applications.
  • But .net framework also provides few ways to write unmanaged code which will not use facilities of CLR and execute in an old fashioned way.
  • Both C++ and C# has ways to execute this unmanaged code.
  • When the code is first compiled to an IL we get a .exe or .dll file this is what we call an assembly.
  • Once you ask this assembly to be executed it is loaded into the ApplicationDomain or AppDomain of the CLR.
  • AppDomain of CLR is the region in which a process is running and each assembly can get executed without creating a new process side by side with other assemblies without hampering or affecting their execution.
  • Creating separate processes for execution was a performance intensive task which earlier programming languages used to do.But with CLR this performance lapse is reduced.
  • The other benefit is that this code is compiled only once by the JIT and after that it can be run utilizing full power of the CPU.
  • So the million dollar question is when ultimately the native code is getting generated which is also being generated by other language compilers what's the difference between this native code and the one generated by CLR.
  • So the difference is that CLR places some information within this native code which tells this native code to follow the execution model and remain in bounds confined by the CLR.
  • Earlier unmanaged applications never thought of maximizing the overall throughput,they always used to maximize individual applications throughput but managed code always tries to maximize the overall throughput rather then considering a single process.

So this was the first article of this Series which tells very basic things about the CLR.In future articles we will dig deep into the features provided by the CLR.


Blogger Tips And Tricks:- Opening each link from your new Blogger blog in a new window

If you want your visitors to stay for long on your blog and they should not navigate from your blog even if they are clicking any external links from your blog then this small trick is what you all need. Opening the links in a new window will allow your visitors to return to your blog once they have read the information in the external link which you provided on your blog.Sometimes readers just simply forget your blogs name while they navigate through and then just don't care to come back again. So to provide an easy hand to your visitors this trick can be of help. Workaround

  1. Just sign in to your blogger and navigate to Layouts Section.
  2. Under layouts just click Edit HTML link.
  3. Remeber to backup your existing template now so that you can rollback if you don't like the changes.

4.Now just search for the </head> section in your blogger template.Remember to edit this template in firefox because it will allow you to search within the template rest all browsers which i have tested only search on the visible content on the page. 5.After you find </head>.Just above it enter this exactly the same way it is given below.

<base target=' &quot;_blank&quot;'/> Here in my blog the html tags will be replaced by their tags and symbols so i have provide the image below on how you should add this so kindly do it the same way.

Remeber this is tested only for new blogger.I have not tested this myself for old blogger. That's all now save the template and see the changes now your every link will open up in a new window not in the same window in which  your blog was opened. If you have any doubts then do leave a comment.


Google Calendar Sync for Windows Server 2003:-Install Google Calendar Sync on your Windows Server 2003 Systems

If you use Microsoft Outlook as a Desktop Client and want to synchronize your Google Calendar then you need to download and install Google Calendar Sync which can be downloaded here. http://dl.google.com/googlecalendarsync/GoogleCalendarSync_Installer.exe How to install this on Windows XP and Vista can be found here on this link http://www.google.com/support/calendar/bin/answer.py?answer=89955 But if you are running Windows Server 2003 then this installer will fail and give an error stating that this can only be installed on Windows XP and Windows Vista operating Systems. Workaround

  1. So the solution of this problem is just download a tool by microsoft called Application Verifier.
  2. Install this tool and just go to File ->Add Application.
  3. Now add the Google Calendar Sync.exe to this and just fool the installer to think that it is going to install on Windows XP system.
  4. How to do this is explained here in this article remember it shows the workaround for Photoshop CS3 but you have to open the Google calendar Sync file.

http://localhost/smallworkarounds/index.php/2008/09/17/installing-photoshop-cs3-on-windows/

Just copy the below as same given in the above article -    Major Version --- 5 Minor Version---- 1 Build Number ---  2600 Service Pack Major -- 2 Service Pack Minor -- 1

Now just click save and run the Google Calendar Sync.exe Now it will just work fine. If you are getting an error saying that daylight timezone have not been updated either install that update from the link provided and if you are unable to download from there download it from the below link for Windows Server 2003 http://www.microsoft.com/downloads/details.aspx?FamilyId=40D82C50-2E93-45A1-AD4C-7F27AA0A0E25&displaylang=en   I have not tested it for Windows Server 2008.Anyone who tested this trick please do leave a comment telling that is it working or not in WS2008.


FeedBurner only showing 25 feeds for Blogger blogs,How to get all my posts feed in feedburner

Blogger's atom.xml file by default contains only 25 latest posts and when we burn this file with feed burner then only these 25 posts are converted to feedburner feeds, so what if i want all my feeds to be burnt by feed burner and to be availiable as feeds to my subscribers. Workaround

  1. So the workaround for this common problem is just go to your blogger homepage and do the View Source
  2. In view source you will find an entry saying .....Atom" href=http://www.blogger.com/feeds/....some no/posts/default.Lets assume this no to be 12345678 so you will be having it like this.....Atom" href="http://www.blogger.com/feeds/12345678/posts/default.Its also shown in the figure below.

 

3.Just copy that URL and add to its end ?max-results=100 so now your final URL will look like http://www.blogger.com/feeds/12345678/posts/default?max-results=100. 4.You can also replace this max-results =100 by 500 or 50 or by any no which blogger provides. 5.Also there is some limit on feedburner feeds size. its something around 500-550 KB's so keep that also in mind before giving a very large no. 6.That's all go to your feedburner account and add this url  and then burn it now you will see that the no of feeds availiable are the one which you specified as the parameter.


Visual Studio is missing default templates

If your Visual Studio either VS2005 or VS2008 is missing some default tempates, or whenever you want to add any new item and click add new item you are surprise to find that either your add new WebForm is missing or any other similar item is missing from the add new item list then your templates defaults are corrupted due to some reasons or latest updates or patches or any other software which you have recently installed. Workaround So the workaround to this problem is:-

  1. Just go to the Visual Studio command prompt.
  2. Close all opened instances of Visual Studio
  3. Run this command devenv/installvstemplates on Visual Studio Command Prompt.
  4. And thats it all your templates will be set to defaults.

Want to transfer your post:- From Blogger to Blogger,Blogger to Wordpress,LiveJournal to Blogger,Blogger To Windows Live Spaces all in all almost every blog.

If you want to transfer your posts from one blogging platform to another and are facing problems , then Paul Cooley has a very good application which he calls "Blog2Blog" which can do this for you very easily. I have myself tested it for my blogger to blogger transfer and it works just fine. Also in blogger i was unable to find a safe way to transfer all the posts or selected posts to another blogger account. But with this tool you can achieve the same easily. You can download the tool from here:- http://www.paulcooley.com/linuxlore_blogstorage/apps/blog2blog/blog2blog-2.4.0.2.zip Instructions for using the tool

  • Just Click the setup.exe and install the application.
  • Once installed it will open up an interface like this
  • In select source select the blogging platform from which you want to import the posts.
  • Enter your username and password source-URL ex. http://smallworkarounds.blogspot.com.
  • Then for the source-API-URL especially in blogger if you are using old blogger then the defaults which will be coming will work.
  • But if you are on new blogger then you have to open your blog on the home page and do the view source.
  • In view source you can locate and entry which says "service.post" and there will be a link after that as shown below.
  • Just copy and paste that link to the source-API-URL and this is it your source is set up.
  • Remember that this trick is for new blogger only.
  • Once completed with all the above things just press fetch.
  • After fetching is completed just repeat the same steps for your destination blog also.
  • Once you are done with your destination blog then just click publish.
  • And thats all you will see all the posts being published to your new blog.

Thanks! for this great tool by "Paul Cooley" http://linuxlore.blogspot.com/2007/09/livejournal-to-blogger-or-blogger-to.html


C#----When to use As Keyword in C#

  1. As keyword is a hidden treasure in C# which most of us don't use in our day today programming.
  2. As keyword is used for the comparison of compatible types
  3. Its general syntax is expression as type where expression is also a reference type and type is also a reference type.
  4. Whenever there is nothing in the object instead of complaining to user or throwing an exception it just returns "null" thus it doesn't throw an exception.
  5. So when to use as keyword and when to use cast expression is a very important question indeed.
  6. Both have their individual significance.
  7. Whenever you do not want to raise any exception and you have already handled the returned null value condition then it  is wiser to use "As" keyword.
  8. But when you want that whenever the object is null an exception should be raised and you are using exception handling then you always must use the same familier cast expressions.

Given below is a small code snippet to demonstrate that:-

using System;
namespace Ramp.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var myObject = new object[3];
            myObject[0] = new Student();
            myObject[1] = new Teacher();
            myObject[2] = "I love C#";

            foreach (object obj in myObject)
            {
                string s = obj as string;
                if (s != null)
                    Console.WriteLine("It is a string");
                else
                {
                    Console.WriteLine("Its not a string");

                }
                Console.ReadLine();
            }
        }
    }

    public class Student
    {

    }

    public class Teacher
    {

    }

}



Output

Its not a string 
Its not a string 
Its a string

Outlook 2007 Signatures:- Using custon HTML and styles in Signatures in Outlook 2007

Outlook 2007 does not give the facility to put the custom HTML and styling in Signatures under the signatures box.

As you can see that by default when you edit your signatures you only have Delete New Save Rename Options. And also a few options to insert image and some hyperlink but no support for any kind of custom editing of HTML and styles. So what to do if you want to enter some custom HTML and do some styling to your signatures while using Outlook 2007. Here is the workaround. WorkAround

Just Navigate to your "C:Documents and Settings(your_username)Application DataMicrosoftSignatures". Here Search for the htm file which will generally be starting with you Name. Open this file in Notepad , Notepad++ and add whatever custom content you want to add.

Click Save and you are done. Open your Outlook Signatures Box to see that changes made by you are reflected or not. Send a mail to your another account to check whether your custom signatures are working or not.


Adding LinkedIn Button To Blogger or Wordpress or any other Blog

Today i was trying to add a "LinkedIn" to my linked in profile button on Blogger.But it was not so easy. You can directly embed the HTML and get the linked in image link if you want but for me it didn't workde.Then i came to know that the linked in people themselves provide custom buttons that you can add anywhere either to your blog or your websites. But these custom button service is rather hidden ie not visible at the first sight.So i thought that it would be helpful if i share this post with you all. Below i have given detailed description with images on how to add this linked in button to your blog. Steps:-

  1. Just go to http://www.linkedin.com/

2.Sign into your profile

    3.Goto public profile and click the edit button next to your public profile
    4.Click on promote your profile add custom buttons link
    5. Now you can see a lot of buttons and their respective code which you can directly paste into your blog.

JQuery with Asp.net and Visual Studio 2008 intellisense

Here is a small post on Jquery which is a far better alternative to Aspnet Ajax.Its a small JavaScript library with immense power and most widely used these days.A few months ago Microsoft announced that they will be shipping JQuery with Next Release of their Visual Studio i.e Visual Studio 2010. Visual Studio 2010 and .net framework 4.0 Community Technology Preview are already available  for download from http://www.microsoft.com/downloads/details.aspx?FamilyId=922B4655-93D0-4476-BDA4-94CF5F8D4814&displaylang=en I am not sure about the intellisense support for JQuery and JavaScript in this new version but as Microsoft Promised they will surely ship it in their final release. As for now with Visual Studio 2008 full intellisense for JQuery is achieved using a .vsdoc.js file.   Steps to follow to get full intellisense

  1. Install this Hotfix which will fix many issues for Visual Studio Team Systems 2008 and also enable and enhance you script intellisense if somehow it is disabled or its not coming with many other fixes. Download Link :-https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=10826
  2. Jeff King has a very good post describing the second step here.

http://blogs.msdn.com/webdevtools/archive/2008/10/28/rich-intellisense-for-jquery.aspx

Here a hack is applied so there two files are given one is "jquery-1.2.6.js" another is "jquery-1.2.6-vsdoc.js".So the first file is the actual Jquery file which should be downloaded on the clients browser along with the markup whereas second file should only be available while using intellisense inside the Visual Studio 2008.The markup comments shown above are achieving the same thing. A very simple Visual Studio Solution is attached at the end of this post for you to see the architecture of how to include jquery files and how to do very basic things using Jquery in an aspx page having basic markup as HTML.

After following these steps you are now ready to start Jquery development in Asp.net Download Source Code Here :-http://9wtpog.bay.livefilestore.com/y1pPZ0KF1m2F28wRGe4wQYrbDCyIuWruESEpdlcILrP_8rIkJfe2eTchl6iw6KSUMwRroVAQ2UvoCo/JqueryIntellisenseInstallation.rar?download