Saturday, December 13, 2008

Resharper:- Visual Studio Refactor,Maximize your productivity-(Code Generation Techniques And Code Analysis Techniques)-Part1

Resharper is one of the most widely used utility for the .net Developers who use Visual Studio,it can be either VS2005 or VS2008.Every person who wants to be more efficient,productive and do smart coding should always use refactoring.

Although VS2008 has bunch of refactoring features inbuilt but they are not sufficient if you do a lot of work in Visual Studio.For this kind of situations Resharper is a must have add-on and its price is worth its value.

In this series of my articles i will try to explain you with many of its features related to refactoring and some of its other powerful stuffs.

Although there can be a learning curve in mugging up some keys but once you practice them in your daily coding and make it a habit, you will find that your productivity has increased a lot.

 

First Let's See some of the Code Generation Techniques using Resharper

  • Creating File from Template
  1. You can just press Ctrl+Alt+L to open the solution Explorer

From inside the solution Explorer just press Alt+Insert to open the generate file from Template smart navigation as shown below

    3. This will create a new Class called Person and put it inside the required Namespace.
    4.You can create a new class,Interface,Structure in the similar fashion.

     

  • Surround With Template
    • Just Select the region you want to Surround with a region and then press Ctrl+E,U

    To remove the region surrounding again to its original just press Alt+Enter on the region bubble and Press Remove Region

  • Insert Live Template
    • To insert live template just press Ctrl+E,L
    • Live template can be used to insert various code templates some of which are frequently used such as enum,interface,#region,prop etc...
  • Insert some common code using Alt+Insert inside a file
    • Just Press Alt+Insert inside a file to get a number of code generation templates including creating Constructors,Properties,readonly properties,implementing missing members,overriding members,delegating members,equality members,formatting members.

     

    Code Assistance And Analysis using Resharper

  • Moving the Code Block Up and Down
    • Just Press Ctrl+Shift+Alt+[Up] to move up or Ctrl+Shift+Alt+[Down] to move down.

  • Show available quick fixes and context actions
    • Most of the times you will make use of this shortcut,whenever you see a bulb in front of your code line you can just press Alt+Enter to see related quick fixes and context actions.
  • Symbol Code Completion
    • Shortcut for symbol code completion is Ctrl+Space
  • Code Cleanup
    • Resharper includes a code cleanup module which can clean up your code according to some predefined set of rules
    • Just press Ctrl+E,C  prompt code cleanup and press Ctrl+E,F for silent cleanup
  • Extending And Shrinking the Selection
    • For extending the selection just press Ctrl+Alt+RightArrow
    • Fore shrinking the selection just press Ctrl+Alt+LeftArrow
  • Comment with Line Comment
    • Just Press Ctrl+Alt+/ to comment with line comment.
  • Comment with Block Comment
    • Just Press Ctrl+Shift+/ to comment with block comment.
  • Duplicate or Copy and paste a line ore selection
    • Just press Ctrl+D to duplicate the selection or the line and this duplicated copy is inserted just after the line which is duplicated.

 

If you are new to Resharper you can download it from the below given link

http://www.jetbrains.com/resharper/download/

Rest of the techniques will be covered in next article in this series which will be related to search assistance and navigation techniques using Resharper.

So stay tuned for more .........

Happy Programming!!!!

Monday, December 08, 2008

SytleCop For Resharper 4.1 Updated and a new Release is out...Wow!!!

StyleCop for Resharper is a Resharper4.1 plugin which allows Microsoft Style Cop to be run as we type and generates real time syntax highlighting of violations
    1. If you don't know what Resharper is visit this page
      1. http://www.jetbrains.com/resharper/
    2. If you don't know what Microsoft Style Cop is visit this link
      1. http://code.msdn.microsoft.com/sourceanalysis
    3. To download StyleCop For Resharper visit this link
      1. http://www.codeplex.com/StyleCopForReSharper

Guys do check out this it will help you write cleaner code which is in accordance with specified standards.

According to me Resharper and Style Cop are must have's for a .net developer to code smartly and efficiently.

More on this in upcoming posts......

Happy Programming!!!!!

Sunday, December 07, 2008

Visual Studio 2008 Tips & Tricks for Developers:- This includes some shortcuts and some hidden features in Visual Studio 2008 which will increase your productivity

  1. Working in Full Screen Mode in Visual Studio
    1. Alt+Shift+Enter is the shortcut to enter to fullscreen mode in Visual Studio
    2. Its sometimes really helpful and more appealing for developers to work in full screen mode
  2. Editing
    1. For Copying a line in the IDE just go to the start of the line and press Ctrl+C,there is no need to select anything
    2. For Pasting a line just go to the start of the line and just press Ctrl+V
    3. For Deleting  a line just go to the start of the line and press Ctrl+X,  this is not actually delete but its similar to cut if you do Ctrl+X on current line and go to some other place in your code and do Ctrl+V then it will paste the same line there.
    1. Expanding and Collapsing the code units
      1. This nice little shortcuts has saved me a lot of time.Whenever i am working on a large piece of code i always get confused and make some changes in other Method or property because they were looking similar.
      2. But now with this shortcut i collapse one method as soon as it is finished.
      3. The shortcut is Ctrl+M+M.
      4. Just go to the beginning or end of the method or property or any code block and hit the shortcut it will expand or collapse the code block comparing to its present state.
      5. If you want to collapse all your code units or blocks to their definitions then the shortcut to achieve this is Ctrk+M+O or Ctrl+M Ctrl+O.This is also a very handy shortcut which helps a lot in development.
    2. Automatic Text Indentation and Formatting
      1. This shortcut helps me to write beautiful and decorative code which is easy to understand by any person.
      2. Shortcut is just press Ctrl+K+D.
      3. This works not only in C# and VB code behind but it works well in aspx pages.
      4. If you want to just format the selected piece  of code then just press Ctrl+K+F
    3. Automatically adding Namespaces
      1. Use the Ctrl+. (Remember this is Ctrl+[period] if you get confused) shortcut key to automatically get intellisense for probable namespaces.
      2. Just press enter to include the required namespace.
      3. There are much cooler tricks when using a refactor like Resharper.I will discuss those tricks later this month in one of my posts.
    4. Commenting And Uncommenting The Code
      1. This trick saved me a lot of time.
      2. Just select the code to be commented and press Ctrl+K+C,this will comment your code block.
      3. For uncommenting the code just press Ctrl+K+U,this will uncomment the code block.
    5. Automatically generating properties
      1. Generating dummy getter and setters or properties is also a pain in big projects.
      2. Although i would recommend you some refactors like Resharper which can do it for you or some code generators like Code Smith and also give a try to inbuilt on in Visual Studio 2008 called T4 or Text Template Transformation Toolkit.
      3. But if you don't have such a mass volume project and just don't want to write your getter and setters then just type this prop + TAB+TAB
      4. Remember you don't have to type all of this but you only type prop and then press TAB two times for VS2008 to automatically generate the property for you now you can change the name and any other thing by navigating and just pressing TABS.
    6. Increasing and decreasing the indentation
      1. Select the code block for which you want to increase the indentation and after selecting just press TAB,this will increase the indentation.
      2. To decrease the indentation just select the required code block and then press SHIFT + TAB,this will decrease the indentation of the selected code block.
    7. Selecting a single word then line and then other lines within that block and then.......
      1. This is also a cool trick if you are in middle of something and want to do something on either the word you are on or the entire code block, or entire method, or entire class then just go on pressing Ctrl+W,it will start selecting for you starting from the current word.
      2. After selecting the desired code block you can perform any operation on that code block.
    8. Build & Debug Shortcuts and tricks
      1. To build  a solution just press Ctrl+Shift+B
      2. To start debugging just press F5
      3. To stop debugging just press Shift+F5
      4. If you are already debugging or your WebDev.WebServer.Exe is running or any other webserver is running you can directly attach to that process escaping the hussle to build again this is a great time saver.Remember always build or rebuild if you have done some major changes but if simply you want to debug and have done no changes in any other class library projects then you can use this trick
      5. Simply Press Alt+D+P then the Attach to process window will open.
      6. Simply choose your web server process to attach and you will see without building your entire solution your solution has been attached to the debugger.

    9. Find Options
      1. You are already familiar with Ctrl+F option to find something either in current documents or all open documents or entire project  or entire solution,but another find option is Ctrl+Shift+F, this trick is helpful when you want all your results to be listed in a find window rather then to navigate one by one in every file where the searched string exists.
    10. Switching Between Design And Source Views
      1. F7 is the key used to switch between design and source (ie c# or vb files) views in IDE
      2. If you want to just toggle the markup's design and source view or want to view both then press Ctrl+PageDown
    11. Some other common used shortcut keys which can be helpful
      1. Ctrl+Alt+L for opening Solution Explorer
      2. F4 for opening properties window
      3. Ctrl+Alt+X for showing the toolbox
      4. Ctrl+\+T for displaying the tasklist
      5. Ctrl+\+E for displaying the error list
    12. How to navigate between various opened tabs inside Visual Studio
      1. Ctrl+TAB key will let you navigate between various open tabs in Visual Studio IDE
    13. Going to Declaration and then again returning to the actual usage
      1. Just press F12 to go to declaration
      2. And press Ctrl+- to return back to the piece of code where you were earlier.

    14. Selecting Source Control Plugin
      1. If you are working in a team you probably will be using a source control there are many options to choose SVN,Visual SVN,TeamFoundationServer,Source Vault and Source Fortress and many others.
      2. But when selecting a client you have to mention it in Source Cotrol Plugin Selection as shown below

    15. I want solution for every project which i create
      1. If you want a solution for every project which you create then you have to enable this as shown below

     

    I would have really forgotten many things which could be added in this list.I will update this list regularly  as I encounter any new thing,so stay tuned for more

    Also I would be doing an extensive post on Resharper 4.0,the most sharpest refactoring tool available out there its not just a refactor but a way beyond that

    Believe me i use it in my day to day coding and it makes development process 100K faster.

    Happy Programming!!!!

    Update 12Dec2008

    1. For deleting a line in Visual Studio just place the cursor in front of it and press Ctrl+Shift+L

    Update 4 Jan 2009

    1.This post links to a tip used to decrease the load time of the IDE by disabling the splash screen.

    http://smallworkarounds.blogspot.com/2009/01/visual-studio-tips-tricks-2-decrease.html

     

    “If someone wants to purchase Visual Studio 2008 at a discounted price, you can purchase at a low price from eCostSoftware.”

    Saturday, December 06, 2008

    Tabbed Browsing in IE6 :- How to get tabs in Internet Explorer 6

    Tabbed Browsing is a concept which is now common in every new browser whether it is IE7 or IE8 or Firefox old and latest versions,Chrome,Safari,Opera and generally every new browser have this facility to be called new enough and to get added to the list and make a difference.

    But many people still use old days Internet Explorer 6 and we as developers have to make our websites work as well under IE6 as they are in other new generation browsers.

    But without tabbed navigation it is very difficult for any type of user who uses IE6 either he is a developer or he is using IE6 for simple browsing purpose.

    So the workaround to get tabs for IE6 is really very simple

    Workaround

    1. Just follow the below given link and download the Windows Live Toolbar
      1. http://toolbar.live.com/moresysreq.aspx for Microsoft Windows Vista™ RC1, Windows XP SP2, Windows Server 2003, or Windows 2000 SP4
    2. If you have already yahoo or msn toolbar installed and you dont require them please do remove them because especially yahoo toolbar will have some issues with the windows live toolbar.
    3. Now install this windows live toolbar.
    4. Now if you see tabbed browsing option button then its well and good.
    5. Else if you have a window like this with toolbar installed and no add tabs button.
            6.Then probably the tabbed browsing button would not have been installed or it would have been turned off.
            7.So if its not installed you can download it from this link
            http://gallery.live.com/liveItemDetail.aspx?li=6ad971ea-c0dc-4880-be38-80f0859eb291&bt=2&pl=3
            8.Just run the downloaded .msi file,Now your toolbar should contain the tabbed browsing buttons like this

            9.After doing this also if you are not getting the button then please make sure that tabbed browsing is turned on.To do this just click you windows live toolbar icon at the leftmost part of the toolbar and select toolbar option from the menu and just turn on the tabbed browsing from there.

            This will do the trick for you!!!!!.

          Tuesday, December 02, 2008

          How to display firefox status bar in fullscreen mode

          By default firefox will not show you the status bar when its running in the full screen mode.

          Status bar is needed in the full screen mode especially by developers to see what's being currently requested by the page which is currently being opened.

          Status bar also contains various plugins such as adsense plugin,video downloader plugins and many similar plugins.

          So given below are sequential steps on how you can get your status bar in full screen mode in firefox.

          Workaround

          1. Just navigate to the path given  in your computer 
            1. Windows XP/2000/2003Server----> C:\Documents and Settings\[User]\Application Data\Mozilla\Firefox\Profiles\xgggxznr.default\chrome
            2. Windows 95/98/ME----->c:\windows\Application Data\phoenix\Profiles\[profile-name]\[#s].slt\chrome\
            3. Windows NT---->%UserProfile%\Application Data\phoenix\Profiles\[profile-name]\[#s].slt\chrome\
            4. *nix-------------->~/.phoenix/[profile-name]/[#s].slt/chrome/
            5. Mac OS X--------->~/Library/Application Support/Firefox/Profiles/[profile-name]/chrome/

           

           

                  2.By default on some operating systems you  will not have userChrome.css file instead there will be a userChrome-example.css file.
                  3.Just open this userChrome-example.css file and find a section saying "@namespace url("......mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default namespace to XUL */"
                  4.Just below this section paste this one line of code ------------------>   #status-bar {visibility: visible !important;}

                  5.Just save a copy of this file and rename it as userChrome.css.
                  6.Close and restart your firefox and switch to fulscreen mode now you can see your status bar in fullscreen mode as well.
                  I have personally tested it on my Windows Server 2003 Machine.You people can test on Vista,98/ME, Linux,Mac and post your comment so that i can re so that i can update the correct path for the userChrome-example.css file in this article.

                    Monday, December 01, 2008

                    Sitefinity CMS Error:-"...App_Data\Search\All-Pages\Index not a directory" If this is the error while publishing or saving your pages then the solution is....

                    If this error  in Sitefinity CMS is driving you crazy then there is a simple solution to this problem which is listed below.

                    This error might be caused when there is some missing index folder.

                    WorkAround

                    • So the simple workaround is to go to Administrator tab.
                    • Then in administrator go to Services and then to Search screen
                    • This will initialize the services client and all missing folders will be recreated.

                    Given below are the steps in images which will solve this problem

                    Saturday, November 29, 2008

                    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.

                    Friday, November 28, 2008

                    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.

                    Thursday, November 27, 2008

                    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://smallworkarounds.blogspot.com/2008/09/installing-photoshop-cs3-on-windows.html

                    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.

                    Sunday, November 23, 2008

                    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.

                    Friday, November 21, 2008

                    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.

                    Tuesday, November 18, 2008

                    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

                    Monday, November 17, 2008

                    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
                    

                    Wednesday, November 12, 2008

                    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 Data\Microsoft\Signatures".

                    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.

                    Sunday, November 09, 2008

                    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.

                                            Thursday, November 06, 2008

                                            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

                                             

                                            Monday, November 03, 2008

                                            Configuring Windows Live Writer for Community Server Blogs

                                            RJ Dudley has done a very good post on how to Configure Windows Live Writer for Community Server Blogs.

                                            If you want to blog on community server then this post might be of great help

                                            http://www.rjdudley.com/blog/Configuring+Windows+Live+Writer+For+Live+Community+Server.aspx

                                            Sunday, November 02, 2008

                                            Opening Sharepoint Sites in Firefox:-Firefox always asks for credentials

                                            If you are working on Sharepoint and your sharepoint sites always asks for credentials in Firefox then there are two workarounds which you can do.There can be others but the below mentioned two workarounds are most efficient.

                                            1.Using IE Tabs plugin in Mozilla Firefox

                                            You can download IE Tabs plugin from here https://addons.mozilla.org/en-US/firefox/addon/1419

                                            This plugin will simulate the behaviour of Internet Explorer Tabs inside Mozilla Firefox.And if your sharepoint site is correctly configured to run in IE then after opening it with IE Tab it will work fine in Mozilla Firefox also.

                                             

                                            2.Change the network.automatic-ntlm-auth.trusted-uris entry in the about:config in Firefox

                                            Just go to the address bar in firefox and type about:config.Now a configuration file will be opened for you, now here search for the entry named as "network.automatic-ntlm-auth.trusted-uris"

                                            Double click this entry and enter the name of your webserver or the server for which you want firefox to inherit the ntlm credentials.

                                            If you are working locally and have configured your Sharepoint Server also locally then generally adding localhost,Your computer name will do.You can enter comma separated lists for all the sites for which you want firefox to inherit automatic NTLM credentials.

                                            After this step just press ok and refresh your page you will find that now your sharepoint sites can run equally well in firefox also.

                                             

                                            If you are facing the same problems in IE 7 then you can read this article to fix the problems

                                            http://smallworkarounds.blogspot.com/2008/10/internet-explorer-always-ask-for.html

                                            Saturday, November 01, 2008

                                            Definition of Success

                                            1. Success can be in two sense one is in which a person thinks he is successfull and other is in which his surrounding think him to be successful.
                                            2. As far as the first one is concerned a person can think himself successfull whenever he thinks he has reached his desired level of satisfaction from his life.
                                            3. Your stimulus or surrounding thinks you successful only when you have crossed a pre-defined limit kept by the stimulus,surroundings or your society.
                                            4. Zenith of success is achieved only when you and your surroundings both think you to be successful

                                            Live Activity Feed,Tag Cloud For your Blog on Blogger

                                            If you always wanted to have a live activity feed for your blog on blogger then you must check out cool widgets from WowZio

                                            http://www.wowzio.com/

                                            Just Say Create my widget now.

                                            On the creation page enter your feed url or simply your blog url.It will automatically get posts from your Blog and then just click create my widgets.

                                            It will create many widgets for you but my favourite are Live Activity Feed and Tag Cloud.

                                             

                                            I am using same widgets in my Blogger blog also.

                                            The integration is very easy there is a link called add to blogger whenever you choose a widget.

                                            Friday, October 31, 2008

                                            How to install Sql Server 2005 SP1 on existing SQL Server 2005 SP2 Install:- If you are getting "A recently applied update, KB913090, failed to install".

                                             

                                            If you are getting this error then one probable reason can be that you are trying to install Sql Server 2005 SP1 on a machine already having Sql Server 2005 SP2 Installed on it.

                                            This error might be followed by another error telling "SqlSupport.msp is not digitally signed"

                                            The best way to fix this error is by following these steps:-

                                            1. Save the data in the following Registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\90\Bootstrap\MSIRefCount\Uninstall

                                             

                                            2.Copy this value data in a text file and save it for future use.

                                            3.Go to control panel , add/remove program and remove the Microsoft Sql Server Setup Support Files.While uninstalling you might get some error message or warning that this uninstall may effect some other Sql Server Components which are already installed.

                                            4.Click Yes to uninstall on the error message.

                                            5.From the installation CD browse to the folder Tools\Setup and start the SqlSupport.msi to again install the Sql Server Setup Support Files

                                            6.After this step again browse to the registry location mentioned earlier  and change the data value to the one we saved in the text file.

                                            7.Now you can successfully start the install of Sql Server 2005 SP1

                                            Wednesday, October 29, 2008

                                            Reporting Server Not Starting:Starting Report Server Failed

                                             

                                            How to tackle this situation as it may be really frightening

                                            1. Find your SQL server installation folder it might be in C:\Program Files\Microsoft SQL Server\MSSQL.x\Reporting Services\ReportManager.Here MSSQL.x can be anything where you Reporting Service is installed, generally if you have installed every thing including Notification Service,Analysis Service,Integration Service and DataBase service then it is MSSQL.4

                                            2. Use the All Programs menu to open the Report Server Status page.

                                            From here you can locate the instance id ie. is it MSSQL.2 or MSSQL.4 etc... 

                                            3.Now open the ReportServer.config File and find the line containing <WebServiceAccount></WebServiceAccount>

                                            4. Add IWAM_ComputerName like this <WebServiceAccount>IWAM_ComputerName</WebServiceAccount>

                                             

                                            5. Save and then close the RSreportserver.config file.

                                            6. Restart the SQL Server Reporting Services service.

                                            Sunday, October 26, 2008

                                            Windows Live Writer Portable

                                            Here is a very good post where you may know about Windows Live Writer Portable.For those who don't know Windows Live Writer is a desktop based application from which you can manage you n number of blogs.It consits of a rich sets of plugins to achieve different blogging objectives.

                                            Its a musch check and must have tool for bloggers

                                            The link to the post which i mentioned earlier is

                                            http://www.techlifeweb.com/2007/09/08/windows-live-writer-portable-20-now-with-u3/

                                            You can download the portable version of Windows Live Writer from the below given link and you have to follow the instructions given above to install this portable version.

                                            http://www.techlifeweb.com/download/WLWPortable2.zip

                                            Saturday, October 25, 2008

                                            Some useful properties,classes and methods which we require mostly during development in .net

                                             
                                             1: System.Web.HttpContext.Current.Request.ApplicationPath

                                            System.Web.HttpContext.Current.Request.ApplicationPath gives you the applications current running path.

                                             

                                             

                                            This list will be ever increasing as soon as i found some useful content i will publish it once again.

                                            If you also want to share some common,useful and often ignored things in .net you can comment in there i will surely include them in the list.

                                            Friday, October 24, 2008

                                            Internet Explorer always ask for password for my Sharepoint Site.........is this causing havoc

                                            1. Although When you install Sharepoint it by default configures all the settings to be used with Internet Explorer, but sometimes it may happen that when you installed sharepoint server at that time you were having IE6 or some other version and now you want to switch to some other version.
                                            2. Now when you install this new version every setting made by Sharepoint is gone  and if you open your sharepoint website in the browser it always asks for the credentials
                                            3. So what you have to do is follow these simple steps to again configure Sharepoint Sites to run smoothly with you IE browser
                                            4.  
                                            5. Now in Internet Options go to Local Intranet and make the security lever for this zone to low
                                            6. Then click on the sites tab

                                             

                                             

                                             

                                            Now click on the advanced tab

                                             

                                            Here in advanced settings make sure that you sharepoint site is included,and if not than just write the url of your site and press add and then close and then press OK

                                             

                                             

                                            Now you sharepoint site should work fine in IE7 or others

                                            If you still have some queries than do leave a comment.

                                            There is also another article on how to configure and install sharepoint

                                            http://smallworkarounds.blogspot.com/2008/10/share-point-series-basic-sharepoint.html

                                            Windows Live Writer Important Shortcuts

                                            Few important shortcuts which can make you more productive using Windows Live Writer

                                            1. Ctrl + F11 for normal view, no styling information is applied while you are writing your blog entry
                                            2. Shift + F11 this is the Html Mode, here you can edit the Html contents of your posts and just do any manipulations in the HTML or do any inline styling to you post
                                            3. F11 If you want to writer your blog with all the styling information about the blog in your background while writing.
                                            4. F12 To see the web preview of the post once you write it, this shows how your post will look after publishing.
                                            5. Ctrl + L to insert an image either from web or from your desktop
                                            6. Ctrl + K Insert Hyperlinks
                                            7. Ctrl + Shift + V is the shortcut to Paste Special Command what it does is if you copy the content from somewhere else it can remove the styling information from the original content and yet preserving all the image and link tags,its thus really powerful
                                            8. F7 is to check spelling on the post.

                                             

                                            If you want some more information regarding windows live writer than you can obtain it from these posts

                                            http://smallworkarounds.blogspot.com/2008/10/windows-live-writer-portable_24.html

                                            http://smallworkarounds.blogspot.com/2008/08/download-windows-update-agent-5802469.html

                                            http://smallworkarounds.blogspot.com/2008/08/downloading-windows-writer-2008-and.html

                                            Share Point Series:- Basic Sharepoint Installations And Configurations Part1

                                            This is the first article in the series of Sharepoint articles, a lot of stuff will be coming in next few months.

                                            Here in this first article i will just talk about simple steps to follow to install Microsoft Office Sharepoint Server 2007 on Windows Server 2003.

                                            It will refer MOSS 2007 to Sharepoint Server from now on.

                                            It should be made clear in early phase of this article series that Sharepoint Server can only be installed on Windows Server Installations it cant be installed on Windows XP and Windows Vista Installations.

                                            Installing Sharepoint Server

                                            1. Just follow this useful link already present on MSDN to install Sharepoint Server.I will not rewrite the whole thing but i will discuss where ever required and some problems i faced and their solutions.
                                            2. http://technet.microsoft.com/en-us/library/cc263202(printer).aspx
                                            3. As satated at last in the above article when the installation finishes than you have to click next and then it will ask you for the configurations,so you can just click next and start the configurations.
                                            4. If you install the standalone install with all basic settings it basically performs 10 diffrent basic configuration tasks and these tasks may take time so be patient.
                                            5. If everythings goes on smoothly after sometime it will say configuration completed successfully.
                                            6. Now at this stage we are ready to test our first sharepoint site.     
                                            7. If this is the scenario with your system than probably you might be running something else on your port 80 such as your Source Controls Server Such as SVN or Source Vault.
                                            8. So first you have to stop those or configure them on another port to work in synchronization with Sharepoint Server.
                                            9. If you are using SVN than you just have to stop the Default running apache server which is uses by default and configures it to use port 80.
                                            10. Make sure if you have made the default install of Sharepoint Server than no other thing is running on port 80 or your default Sharepoint website will not run.