Blog - Title

Visual Studio 2012 & 2013 Current Builds

  • The Ultimate Visual Studio Tips and Tricks Blog

    Print with Line Numbers

    • 25 Comments

    Keyboard:  CTRL + P
    Menu:  File -> Print
    Command:  File.Print
    Versions:  2008,2010
    Published:  3/9/2010
    Code:  vstipEnv0006

     

    Want to print your line numbers with your code?  Don't worry!  You can do it by just checking the "Include line numbers" option in the Print Dialog:

    image

  • The Ultimate Visual Studio Tips and Tricks Blog

    TODO Comments in the Task List

    • 21 Comments

    Versions:  2008,2010
    Published:  6/7/2010
    Code:  vstipTool0029

     

    Ever been writing some code and you want to leave a reminder to yourself to do something on a particular line or area?  Did you know about the "to do" comment feature?  It seriously rocks if you have never used it AND, because it goes in the source code, everyone can have access to the information when you do you check-in!

     

    So here's how it works:  In VB you just put any comment in that begins with the letters "todo" (case doesn't matter):

    image

     

    In C#, it's pretty much the same thing (again, case doesn't matter):

    image

     

    C++ requires that the “TODO” be in upper-case or it will not show up in the Task List:

    clip_image002 

     

     

    In C++ for VS2010 you have to explicitly turn this feature on.  Go to Tools | Options | Text Editor | C/C++ | Formatting | Miscellaneous and change Enumerate Comment Tasks to true:

    clip_image004 

     

     

    Regardless which language you use the result is a nice entry in your Task List:

    clip_image006 

     

    NOTE:  In order to see these items, you have to click the drop-down list in the Task List and choose Comments as shown here.

  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 11 Developer Preview - Project Backward Compatibility (Round-Tripping)

    • 21 Comments

     

    [ NOTE:  This post has been depricated.  The new, updated post can be found here:

    http://blogs.msdn.com/b/zainnab/archive/2012/06/05/visual-studio-2012-compatibility-aka-project-round-tripping.aspx ]

     

    image

     

    UPDATE 3/8/2012:  As of the Beta this does not work with all project types.  Most notably web projects are not supported currently for this feature.  For more information on what is supported and what isn't look here:

    http://msdn.microsoft.com/en-us/library/hh266747(v=VS.110).aspx

     

    Probably one of the most welcome new features in VS11DP is the new project backward compatibility feature also known as project round tripping.  Let’s dig into the details.

     

    The Old Days

    In all prior incarnations of Visual Studio if you had an older version, VS2008 for example, and opened up the project in a newer version, VS2010 in this case, you had the option to convert the project.  If you did the conversion it was a one-way trip.  You couldn’t open the project again in VS2008 if you tried to go back.  This has been the source of a lot of pain and suffering for developers who have to work with multiple versions of Visual Studio.  We want the cool features of the latest IDE but still want others on our team to be able to open the solution in the older version of Visual Studio when they get the files from source control.

     

    The New, Happy Days

    You can now create projects in Visual Studio 2010 with Service Pack 1 then open those projects in Visual Studio 11 Developer Preview and THEN open the project up again in VS2010SP1.  In other words, we now have full project round-tripping capability so you can work with the latest features but still keep the solution compatible with and older version of Visual Studio. 

     

    Putting it to the Test

    Here are the steps you can take to test this for yourself:

    1. Create a project with Visual Studio 2010 with Service Pack 1 and put in a little sample code.
    2. Save and close the solution.
    3. Open the solution (CTRL + SHIFT + O) in Visual Studio 11 Developer Preview and add some more code.  Notice there is no longer a prompt to convert the project that appears.
    4. Save the close the solution.
    5. Open the project up again in VS2010SP1 and bask in the glory of project round-tripping.

     

    Limitations / Observations

    • I know this works with Visual Studio 2010 Service Pack 1 but haven’t tested VS2010 with out the service pack.  I believe it will not work unless you have the service pack but am checking with the team.
    • You can’t use this feature with versions older than VS2010.
    • When you use any feature specific to the new version of Visual Studio, like changing the Framework to the latest version, then the project cannot be opened in the prior version.  I just changed the framework version from 4.0 to 4.5 for a project and saved it without many any other change and was not able to open the solution in VS2010.
  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 2013: Turn Off the Uppercase Menu

    • 20 Comments

    NOTE: This is an older feature. I’ve updated the information for VS2013.

     

    This is one change to Visual Studio that I’m not a fan of and I still continue to see a ton of posts on this change so thought I would share here as well. 

     

    I always try to give credit where credit is due and I believe the earliest mention of this fix is by Richard Banks in his post 6\1\2012 here:  http://www.richard-banks.org/2012/06/how-to-prevent-visual-studio-2012-all.html 

     

     

     

    Mixed Case is Your Friend

    Okay so you really, really don’t like the Uppercase menu in VS2012 because you feel like it is shouting at you:

    5-16-2012 7-50-41 PM

     

     

    You would rather go back to mixed case for your menu:

    5-16-2012 7-43-08 PM

     

    Not a problem! Below are ways you can fix this feature in VS2013.

     

     

     

    Manual Registry Change

    WARNING:  Making changes to the registry can cause unexpected results so do any changes at your own risk!

    1. Open the registry editor and go to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\General\
      (For Windows 8 Express go to HKEY_CURRENT_USER\Software\Microsoft\VSWinExpress\12.0\General)
      (For Web Express go to HKEY_CURRENT_USER\Software\Microsoft\VSWDExpress\12.0\General)

    2. Create a new DWORD value called SuppressUppercaseConversion set to 1
      image

    3. Restart Visual Studio and you should see the change

    NOTE: Watch your spelling if you are typing this manually.

     

     

    PowerShell

    If you like to “simplify” this a bit you can use PowerShell to run a nice script to make this happen.  However, if you haven’t used PowerShell before this may not be faster for you.

    1. Go to the Start button or (Start Screen in Windows 8) and type powershell then select the Windows PowerShell Entry:
      image

      image

    2. In the PowerShell window copy the script below and paste it in then press Enter:

      Set-ItemProperty -Path HKCU:\Software\Microsoft\VisualStudio\12.0\General -Name SuppressUppercaseConversion -Type DWord -Value 1

      image 

    3. Restart Visual Studio and you are good to go.
  • The Ultimate Visual Studio Tips and Tricks Blog

    Turn on Line Numbers

    • 19 Comments

    Menu:  Tools -> Options -> Text Editor -> All Languages -> General -> Display
    Versions:  2008,2010
    Published:  3/7/2010
    Code:  vstipEdit0025

     

    Line numbers are not on by default.  To turn on line numbers just go to Tools -> Options -> Text Editor -> All Languages -> General -> Display and check Line numbers:

    image

  • The Ultimate Visual Studio Tips and Tricks Blog

    Setting Bookmarks

    • 18 Comments

    Keyboard:  CTRL + K, CTRL + K (toggle bookmark)
    Menu:  Edit -> Bookmarks -> Toggle Bookmark
    Command:  Edit.ToggleBookmark
    Versions:  2008,2010
    Published:  7/5/2010
    Code:  vstipTool0047

     

    Bookmarks are a pretty cool feature that a lot of people don't seem to know about.  Essentially, Bookmarks are a way to mark locations in your code.  Unlike tokens ("TODO's"), Bookmarks are not stored with the source code.  There are numerous ways to set a Bookmark.  The simplest way is to use CTRL + K, CTRL + K to create a single Bookmark:

    image

     

    When you set a Bookmark it will create a glyph in the Margin and create an entry in the Bookmarks Window:

    image

     

    The good news is you don't have to keep the default name that is given for the Bookmark.  Just RIGHT CLICK the entry in the window and choose "Rename":

    image

     

    Then put in whatever you want for the name and you are good to go:

    image

     

    You can continue to use this method or the menu to create Bookmarks.  Another cool way to create Bookmarks is to use the "Bookmark All" (bottom right) button in the Quick Find dialog (CTRL + F):

    image

  • The Ultimate Visual Studio Tips and Tricks Blog

    LINQ and Stored Procedures

    • 18 Comments

    Okay so last quarter I was asked if you can call stored procedures using Language Integrated Query (LINQ).  The answer, of course, is YES!  It would be kind of silly if we didn't include this type of functionality. :P

     


    NOTE:  You need the following items to do this example

    SQL Server (pretty much any version will do but this example uses 2005)

    Visual Studio 2008 (Beta 2 was used for this example)

    A little time to sling some code

     

     

    So how exactly DO you call a stored proc using LINQ?  Easy just follow these simple steps:

    1. Create a new Windows Forms Application in Visual Studio 2008, let's call it "LINQ_SP_Coolness"

      image
    2. Next, make sure you have a connection to some data source in your Server Explorer.  You may need to add a new connection.

      image
    3. For the purposes of this discussion I am using the Northwind Database on SQL Server.

      image
    4. Take a look at the existing stored procedures because what you need may already be there.

      image
    5. Aaaaaand since I'm bored watching re-runs tonight, why don't we make our own stored procedure?

      image
    6. Just write a simple SELECT to yank out some data AND remember to save :)

      image
    7. Just to make sure, refresh the stored procedure folder on your data source in Server Explorer to see your shiny, new stored proc listed...

      image  
    8. You might even want to test it :P

      image
    9. To get this to a point we can manipulate it using LINQ we need to have our classes and mappings in place.  Fortunately, this is a VERY easy thing to do.  Just right-click your project, choose Project...Add New Item from the Menu Bar.  Let's add a "LINQ to SQL Classes" item with the default name of "DataClasses1.dbml".

      image
    10. Click and drag the stored procedure from Server Explorer on to the LINQ design surface.

       image
    11. You should see the procedure showing up on the upper right of the design surface.

      image
    12. Now let's slap some controls on our Windows Form.  How about a list box and a button?  Live on the edge!

      image 
    13. Now we need to work with database by establishing a context to it.  Next, we need to create a query expression that treats the result of the stored procedure as a table and query against it selecting only the LastName column.  Just for fun why don't we sort all the last names as well?  Finally, we will take the list of names returned and loop through them adding each one to our listBox as we go along.

      Double-click on the button to code for the Click event and write the following lines of code:
      (NOTE: make sure to substitute your server name in place of "zero_cool" and if you are using SQL Express you need to modify the server piece to read like this "SQLEXPRESS\myserver")

       image
    14. If all goes well, you should get the following result:

      image
    15. And that's how you use a stored procedure with LINQ.  This was a very simple example but if you really want to see a great series on LINQ go to my buddy Benko's site.   He has a webcast series on LINQ that kicks major butt! :)



      [Updated:  added tags]
  • The Ultimate Visual Studio Tips and Tricks Blog

    The RTM of Visual Studio 2008 Is Coming

    • 17 Comments

    [EDIT:  As Guy pointed out on his blog http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/11/19/visual-studio-2008-rtm-is-available-for-msdn-subscribers.aspx VS2008 is RTM for MSDN already]

     

    By now it is no secret that Visual Studio 2008 will RTM before the end of November.  Soma mentioned this at TechEd Europe and I couldn't be more excited!  Make sure you are getting ready with for the new version by checking out our webcasts and other training materials that are available.  Here is a list of places to help you get prepared:

     

    Main Visual Studio 2008 Product Page     http://msdn2.microsoft.com/en-us/vstudio/products/default.aspx

     

    Main World Wide Events Website     http://msevents.microsoft.com/cui/default.aspx?culture=en-US

    NOTE:  Don't let the name throw you off, this is your best "one stop shop" for getting MS content.  Make sure to take advantage of the Virtual Labs!  Below is an extremely short list  at what I found when I searched on the keyword "linq":

    image

     

     

    Channel 9 (of course)     http://channel9.msdn.com/

     

     

    And of course the various blogs (on the left hand side) and other resources that crop up.   I will be doing a 26 part webcast on new features of VS2008 beginning in December as well.

     

     

    In the meantime, let's have a contest.   Post here with your list of resources for getting up to speed with VS2008.  I will randomly choose one person to be the recipient of ONE of these prizes (winner's choice):

     

    Windows Vista Ultimate

    Office 2007 Ultimate

    Halo 3/Flight Simulator X  Combo gift

    [Edit:  contest extended until 12/1 by popular demand!]

    Just in time for the holidays!  Contest ends on 11/26/2007 @ 5pm Central.  Good Times :)

     

    (MS employees not eligible but shoot me an email if you would like to see an FTE version of this contest)

     

  • The Ultimate Visual Studio Tips and Tricks Blog

    Ever Give Your Dog Mouth-To-Mouth?

    • 16 Comments

    PIC-0018

    Well!  I had an interesting night.  As many of probably know by now we have four dogs at my house:  Max (Basenji), Fibi (Jack Russell Terrier), Lily aka Piggy (we think she is a Pit Bull mix), and Zorro (Blue Tick mix).  With four dogs you are always breaking up little fights between them at one time or another.  Not sure if it is just our dogs or this is a normal thing. 

     

    Last night my dogs were in the backyard and I heard a little skirmish start.  I did my usual yell to tell them to cut it out but this time Zorro kept making a funny noise like he was hurt.  It didn't sound good at all.  I went out side and found Max and Zorro attacking Lilly.  Normally Lilly can handle herself no problem but she didn't seem to be fighting and it looked like Zorro had her around the neck. 

     

    As I approached and got Zorro to hold still I discovered that he had managed to get his lower jaw stuck in Lilly's collar.  As I looked closer I found I was having a hard time getting Zorro lose so I brought them closer into the light near our porch.  That is when I realized there was a bad problem.  Zorro was really stuck and there was blood all over Lilly. 

     

    I called for my wife to come down and give me some help and she began looking for a flashlight to get a better idea of what we were dealing with.  Right after she left, I noticed that Lilly had a funny look and realized she was choking--things were much worse than I thought.  OMG.  I almost freaked but held it together and called for my wife to bring me a knife (screw the collar, ill buy a new one).  It was close but I managed to cut the collar off w/o cutting Zorro or Lilly.  As soon as I cut them lose, I grabbed Lilly who had turned purple and had stopped breathing.

     

    I didn't know you could give a dog mouth-to-mouth but my wife (freaking out) managed to say "give her mouth-to-mouth".  Now, I have to admit, giving my dog mouth-to-mouth was not appealing to me but when you are faced with a purple dog you tend to not give a crap.  I directed her to start the car so we could take Lilly to the emergency room and gave the the dog mouth-to-mouth. 

     

    It worked!  I never, EVER would have thought you could resuscitate a dog that way but she started breathing slowly and we rushed her  to the emergency room.  By the time we got to the emergency room, she had completely restored breathing and was just a regular dog.  So there we were in our pajamas with a perfectly healthy dog just wagging it's tail and having a good time.  About 30 minutes and 95 dollars later we were on our way home and now we are looking for a new (hopefully safer) collar for Lilly. :P

  • The Ultimate Visual Studio Tips and Tricks Blog

    Track Active Item in Solution Explorer

    • 16 Comments

    Menu:  Tools -> Options -> Projects and Solutions –> General
    Commands:  View.TrackActivityinSolutionExplorer
    Versions:  2005,2008, 2010
    Published:  3/29/2010
    Code:  vstipProj0011

     

    Note: Several people have asked if you can turn this feature on and off at will. You can if you bind the View.TrackActivityinSolutionExplorer command to a keyboard shortcut.

     

    By default, VS2010 will track the current file you are editing in Solution Explorer.  It looks like this:

    image

     

     

    Notice that the current file being edited is also selected in Solution Explorer automatically.  This is a great way to keep track of where you are in the solution when you are working with a lot of files.  You can turn it off if you want.  Just go to Tools -> Options -> Projects and Solutions -> General -> "Track Active Item in Solution Explorer" and uncheck the option to turn this feature off.

    image

Page 2 of 135 (1,345 items) 12345»