January 2006 - Posts

Internet Explorer Beta2 now available

Check it out. http://www.microsoft.com/windows/ie/ie7/default.mspx
Posted by Vipul Patel | with no comments
Filed under:

Visual Studio Tip of the day - Refactoring - Extracting method

You notice that you have a chuck of code which could easily be transitioned to a new function. How tdo you do that?

Again, Visual Studio Refactoring menu comes to the rescue.

Suppose you have the following code in your function

public void Myfunc()

{

   Console.WriteLine("a");

   Console.WriteLine("b");

   Console.WriteLine("c");

   // Do some processing here.

   Console.WriteLine("a");

   Console.WriteLine("b");

   Console.WriteLine("c");

}

 

We realize that code containing Console.Writeline is replicated. Select one set of the Console.Writeline instructions and right click > Refactor > Extract Method...

Type the name of the new function you want to create containing the selected lines and Click OK.

A new method containing the selected lines is created. So your code will look like

public void Myfunc()

{

   NewMethod();

   // Do some processing here.

   Console.WriteLine("a");

   Console.WriteLine("b");

   Console.WriteLine("c");

}

private static void NewMethod()

{

   Console.WriteLine("a");

   Console.WriteLine("b");

   Console.WriteLine("c");

}

 

Keyboard shortcut: Ctrl R + Ctrl M

Cavaet: You will have to delete the second set manually as currently VS editor is not smart enough to replace all the occurances of the selected lines. Maybe in the next version we can get that feature.

 

Posted by Vipul Patel | with no comments
Filed under: , ,

Visual Studio Tip of the day - Refactoring - Changing variable names

Did you mistype a variable/function/property only to realize it in the code review and are frustrated over the time you will need to spend to correct it across the whole source code?

Visual Studio 2005 has a new feature called refactoring by which you can rename a property/function/variable at one location and the same will be replicated across all the location where the property/function/variable is referenced.

To do that, select the property/variable/function you desire to rename and right click and select Refactor > Rename. A Rename window will appear and you can select whether you want to preview the reference changes, or you want to change the entity in the comments also.

Keyboard shortcut: Ctrl R + Ctrl R

 

Posted by Vipul Patel | with no comments
Filed under:

VB gets a LINQ equivalent

With the release of the LINQ CTP for Visual Basic, VB matches C# tooth and nail (purely from the LINQ perspective)

CTP version features Intellisense, Dlinq support, support for XML literals,

Download link: http://msdn.microsoft.com/vbasic/future and http://msdn.microsoft.com/netframework/future/linq/default.aspx

Posted by Vipul Patel | with no comments
Filed under: ,

Is my webservice really a webservice

How to tell if your webservice is really a webservice which will interact seamlessly with external entities?

Well, keep the following in mind

1. Uses WSDL.  A Web Service should expose its service contract using WSDL.  If it can’t give you a WSDL document, it’s probably just XML over HTTP…

2. Uses SOAP.  All messages sent from and received by the Web Service must use SOAP formatting.  If it’s not using SOAP it’s probably just XML over HTTP…

3. Uses XSD.  All data types in the SOAP payload must be XSD compliant.  No platform native types are allowed.  If it’s not using XSD it’s probably just XML over HTTP…

4. Uses XML.  The underlying messages should of course be formatted using XML.

5. No Arbitrary Binary Data.  The message payload should 7 bit ASCII and should contain no embedded binary blobs.  Any binary data passed over a Web Service should be sent using either SwA, DIME or MTOM (preferably MTOM).

6. Transport is likely to be HTTP.  Although not a requirement, the majority of Web Services today use HTTP as the transport.  Compliant Web Services should definitely work over HTTP.

7. Discovery can be through UDDI.  Again although not a requirement, it should be possible to host the Web Service endpoint using UDDI.

8. Agreed Versions of Specifications.  The versions of the above specifications (WSDL, SOAP, XSD, XML, HTTP, UDDI) should be in line with the latest version of the WS-I Basic Profile (http://www.ws-i.org) – to ensure Web Service compliance between vendors.

9. Operations should be Document Style.  Operations to/from a Web Service should be Document/Message Style (e.g. SendOrder(order o)).  RPC style should be avoided (e.g. SetOrderLine1(orderId id)).

10. Should be compliant with WS-*.  Compliant Web Services should be able to accept WS-* payloads and extensions for Security, Reliability and Transactions (although not all stacks today support these yet).

Source: http://blogs.msdn.com/smguest/archive/2006/01/26/518020.aspx

Posted by Vipul Patel | with no comments
Filed under:

How to: Determining programmatically if DLL is registered

Here is a C# code snippet to determine if a particular DLL is registered or not.

 

[DllImport("kernel32")]

public extern static int LoadLibrary(string lpLibFileName);

 

[DllImport("kernel32")]

public extern static bool FreeLibrary(int hLibModule);

 

public bool IsDllRegistered(string DllName)

{

      int libId = LoadLibrary(DllName);

      if (libId>0) FreeLibrary(libId);

      return (libId>0);

}

 

Source: http://blogs.msdn.com/asanto

Posted by Vipul Patel | with no comments
Filed under: , , ,

Visual Studio Tip of the day - Format Document

Time and again we write code and our brackets get out of visual sync, i.e. they no longer appear as a coherent set even though they may be.

 

In Visual Studio, there is a feature known as Format Document which will align the code systematically.

 

It can be invoked by the key combination of Ctrl K + Ctrl D

 

Suppose you code looks like

 

namespace LogFileCheck

    {

    class Program

        {

        static void Main(string[] args)

        {

            TextReader sr = new StreamReader("mb20051116_05000600_BAYTRARPT03_k.msn.com_w3svc10000.log", Encoding.UTF8);

            TextWriter writesr =

                new StreamWriter("mb20051116_05000600_BAYTRARPT03_k.msn.com_w3svc10000_csResult.log",

                false,              Encoding.UTF8);

            while (sr.Peek()

                != -1)

                            {

                string line = sr.ReadLine();

                if (Regex.IsMatch(line, "&di=78") && Regex.IsMatch(line, @"([^,]*,){19}66"))

                    writesr.WriteLine(line);}

 

                sr.Close();

            writesr.Close();

        }

    }

}

 

Press the magic keys Ctrl K + Ctrl D and voila, all your code looks pretty organized as under:

 

namespace LogFileCheck

{

    class Program

    {

        static void Main(string[] args)

        {

            TextReader sr = new StreamReader("mb20051116_05000600_BAYTRARPT03_k.msn.com_w3svc10000.log", Encoding.UTF8);

            TextWriter writesr = new StreamWriter("mb20051116_05000600_BAYTRARPT03_k.msn.com_w3svc10000_csResult.log", false, Encoding.UTF8);

            while (sr.Peek() != -1)

            {

                string line = sr.ReadLine();

                if (Regex.IsMatch(line, "&di=78") && Regex.IsMatch(line, @"([^,]*,){19}66"))

                    writesr.WriteLine(line);

            }

 

            sr.Close();

            writesr.Close();

        }

    }

}

 

Want to format only a small selected section of the dirty code?  Select the area you want to format and press Ctrl K + Ctrl F.

Posted by Vipul Patel | 2 comment(s)
Filed under: ,

Visual Studio 2005 - A Guided Tour

Want to learn more about Visual Studio 2005.

MSDN magazine folks have come  up with a new issue dedicated solely to the new IDE.

Check it out online at http://msdn.microsoft.com/msdnmag/issues/06/00/default.aspx

 

Posted by Vipul Patel | with no comments
Filed under: , , ,

Visual Studio Tip of the day - Bookmarks

How often do you wish that you could put a mark at a particular location in your source code and then switch to that point with a simple click?

With Visual Studio, you can do that with the help of bookmarks.

A bookmark is a virtual placeholder which notes the position where you place one and you can quickly go to that position from anywhere in your source files by just a few keyboard clicks.

How to define a bookmark?

To create a bookmark, press Ctrl K + Ctrl K

This creates a book mark in the code. This is indicated by a blue button like indication on the left side of the line where you placed the bookmark.

Now to switch bookmark from any portion of your code, just press Ctrl K + Ctrl N

To go to previous bookmark, press Ctrl K + Ctrl P

To unmark a particular bookmark, navigate to that bookmark and press Ctrl K + Ctrl K (yes, this is the same combination you used to create a bookmark, what you are currently doing is toggling a bookmark)

To clear all your bookmarks, press Ctrl K + Ctrl L

If you have many files in your current folder and you want to navigate to the next bookmark in the folder, the shortcuts for next bookmark in folder is Ctrl Shift K + Ctrl Shift N and the previous bookmark in folder is Ctrl Shift K + Ctrl Shift P

All the above options are also available from the menu, Edit > Bookmark > ….

If you want to see all the bookmarks in one window, Go to View -> Bookmark Window (Ctrl K + Ctrl W). And click on the bookmark you want to go to.

Happy coding.

This post is aggregated at http://msmvps.com/blogs/vipul/default.aspx 

RSS link: http://msmvps.com/blogs/vipul/rss.aspx

Atom: http://msmvps.com/blogs/vipul/atom.aspx

 

 

Posted by Vipul Patel | with no comments

Want to test Vista

Update: Due to the completion of the beta program, the nominations are not longer accepted.

Please nominate yourself at http://www.microsoft.com/technet/prodtechnol/beta/preregister.mspx  for the next change to participate. Beta 2 should be open to public in the end of summer.

I will be deleting all the email addresses posted on this blog to prevent spam to your inboxes.

Sincere apologies, and check around summer for Beta 2.

------------------------------------------------------------------------------------------------------------------------------------------------------------

 

Do you want to check out Vista before it is released to market and be a partner in helping Microsoft ship a fantastic Operating system.

Well, here is your chance. If you are in US and want to test drive Windows Vista, drop a comment with your email address and I will arrange to send a Beta invite to you.

Play with Vista and find out how this OS will impact your life.

PS: You should be familiar with installing/reinstalling the OS. A beta product is not guaranteed to be stable.

Posted by Vipul Patel | 1 comment(s)
Filed under: ,

Incremental search - VS2005

One of the lightly used features of VS2003 and VS2005 continue to be Incremental search. Developers usually know the text which they are searching for.

Due to lack of awareness of the VS editor features, I have seen many a developers editing code in TextPad and other editors.

If you know the exact text which you are searching for, you can use the incremental search feature of Visual Studio.

Press Ctrl + I. and start typing the text you are looking for. Your cursor will start to look like binocular facing downloads, and the first text matching the pattern will be selected. As you keep typing the complete text, the selection will jump to the location with contains the complete text. The status bar will contain the text you are looking for.

  

Hot keys:

Start Incremental Search: Ctrl + I

Made a mistake in typing: Hit Backspace till the wrong text is removed

Found the text you were searching for: Hit Escape

Change the search direction: Ctrl + Shift + I

Posted by Vipul Patel | with no comments

Windows Vista successor named Vienna

The next Windows version following Vista will be named Vienna. It was earlier known as BlackComb.

Reference: http://channel9.msdn.com/ShowPost.aspx?PostID=156166#156166

Posted by Vipul Patel | with no comments
Filed under:

Its Unofficial : Windows XP SP 3 will be there in 2007

MFJ mentions in her blog about SP3 for Windows XP being released in 2007. Check out

http://www.microsoft-watch.com/article2/0,2180,1911773,00.asp for more details.

Posted by Vipul Patel | with no comments
Filed under:

Visual Studio Live

With Visual Studio Live being discussed in the developer circles, a natural question arises. What do developers think of when they hear about Visual Studio live? Darryl K. Taft  has an articles dedicated to this at http://www.eweek.com/article2/0,1895,1912035,00.asp.

Here are the top demands:

  • Pair programming: A developer could work with a co-worker, without the coo-worker being actually with him physically.
  • Hosted VSTS: Another idea being popped around is that of Hosted version of VSTS (Visual Studio Team system). Boy oh boy. if we could have these [;)] it would be fantastic. Small businesses would not have to look for high performance machines to work with the pletoroa of benefist offered by VSTS. Keep it coming developers.

 

 

Posted by Vipul Patel | with no comments
Filed under:

Virtual India is live

Microsoft Research has released a first public build of their Virtual India research project. Language choices for the UI and map labels include English, Hindi, Kannada, and Tamil.

Virtual Earth blog:

"Before trying it out, I strongly encourage you to read more about the project at their site for background. Then check out the application. Street level maps are limited to Bangalore for this release, but they are working to integrate more base map data into future builds. This is a great first release and I'm looking forward to seeing where they take this. A discussion forum for the project is availible if you'd like to send feedback to the team working on this."

Virtual India

-

Posted by Vipul Patel | with no comments
Filed under:

Window Live Mail: My expectations

With the beta version of Windows Live Mail available and me already having got my hands dirty toying with it, here's what my wish list would look like:

  • Search: Ability to search for email across all folder. I could not find a button by which I could search in the current version of Windows Live Mail.
  • Ability to configure an email to be sent at a predetermined time (something like the current facility in Microsoft Outlook): That way I can compose all the birthday emails at one go and configure them to be sent on the BDays of my friends and relatives, and never get an response like "You forgot my birthday"
  • Stationary: No stationary. OK I am asking too much, but if Live Mail want to better GMail, I demand it. Or atleast provide a few templates and enable saving custom stationary.
  • Sort: Current version does not allow me to sort the email on the basis of "From", "Subject", "Date". How about adding that feature?
  • Meeting requests: Ability to accept meeting requests and add them to my calender. The earlier version of Hotmail did have this feature and getting 2GB of mail box space is not worth losing that fantastic feature.
  • You have mail: How about Outlook web access like notification that you have new mail. In the current version, you dont know if you have new mail Such a notification will be really appreciated.

More to come as I continue to use the new feature.

 

Posted by Vipul Patel | 4 comment(s)
Filed under:

Security patches for Windows Vista released

If you are using the Vista, I suggest that you download the patch released which corrects the WMF exploit.

Download link: http://www.microsoft.com/downloads/details.aspx?familyid=228f2cdc-7148-4002-86bb-e4ade080ea86&displaylang=en

 

Posted by Vipul Patel | with no comments
Filed under:

VS2005 for VB guys

Guys still in VB world can check out

http://msdn.microsoft.com/vbasic/default.aspx?pull=/library/en-us/dnvs05/html/VB05forVB6.asp

and see whats there for them in VS2005.

esp. Form1.Show works again...

Posted by Vipul Patel | with no comments
Filed under:

Disabling balloon tips in Windows XP

Tired of Windows XP ballooning tips about new Programs installed in the Start -> Programs folder or Hiding your inactive notifications in the System Tray.

Well, here is the solution.

Open the Registry.  Nagivate to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced

If there is key named EnableBalloonTips, modify the value to 0 (to disable the balloon tips) or 1 (to enable the balloon tips).

If such a key does not exist, create a new key of the type DWORD and set its value to the desired state.

This has only been tested on Windows XP.

Disclaimer: Please back up your regsitry before your modify it. I am not responsible for any accidental loss to your system/data.

Posted by Vipul Patel | with no comments
Filed under:
More Posts Next page »