Blog - Title

Visual Studio 2013 Current Status

  • The Ultimate Visual Studio Tips and Tricks Blog

    Make Selection Uppercase or Lowercase

    • 0 Comments

    Keyboard:  CTRL + SHIFT + U (upper); CTRL + U (lower)
    Menu:  Edit -> Advanced -> Make Uppercase; Edit -> Advanced -> Make Lowercase
    Command:  Edit.MakeUppercase; Edit.MakeLowercase
    Versions:  2008,2010
    Published:  4/10/2010
    Code:  vstipEdit0044

     

    Download the seriously cool Tip of the Day Extension to get the daily tips delivered to your Start Page!

     

    Okay, so let's say you have some text (a variable, maybe?)

     image 

     

    and you need to do some case-changing action on it.  Plus, there is a crazy guy holding several people hostage and threatening to dip them in boiling chocolate unless you do it fast.  What do you do?  No Problem!  You just select the word and press CTRL + SHIFT + U to make it uppercase

    image 

     

    or if the evil guy isn't satisfied you can always make it lowercase by pressing CTRL + U

     image

     

    And now you have saved the day!

  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 2010 Tips and Tricks Begins!

    • 2 Comments

     

    I'm happy to announce that the New Year marks the beginning of my endeavor to carry on Sara Ford's great work with Visual Studio Tips and Tricks for the Visual Studio product  (http://blogs.msdn.com/saraford/archive/tags/Visual+Studio+2008+Tip+of+the+Day/default.aspx).  After many discussions between us on how best to move the effort forward we decided that continuing the love with 2010 was a good idea.  With Sara's help I have managed to get a good idea of her approach and added elements of my own style to the mix. 

     

    Additionally, in conjunction with Scott Cate (http://scottcate.com), I am pleased to say almost all tips will include a video showing the tip in action.  Many thanks to Scott for stepping up and doing the past and future videos related to this series.  

     

    I haven't decided to crank out the book proposal yet for a new edition and probably won't for a while yet but am thinking the updated version will include versions 2005, 2008, and 2010 as well as (per Sara's suggestion) some new sections on extending Visual Studio with macros and the new extensibility model.

     

    There was some debate over whether to wait until VS2010 launches or begin with the New Year.  As you can see, I decided to begin on January 1.  This is important for a couple of reasons:

     

    1.  The tips published until RTM will be based on Beta 2 and RC builds.

    2.  It is possible (though unlikely) some of the tips may not be valid in the RTM build when it ships.   I will be retesting all tips when VS2010 ships to make sure they work as advertised :)

     

    The plan is to have a tip a day posted on this blog with a few extra items thrown in for good measure.  What you will see is a healthy mix of new tips in Visual Studio 2010 and some of the old favorites as well (tested to make sure they still work).  To be absolutely clear:  These are Visual Studio 2010 Tips and Tricks so what you will see are the details on how to leverage old and new content with our latest product.  To get things started, and through the inaugural weekend, let's take a look at the #1 tip from Sara's Tips and Tricks:

     

     

    How to behold the power of Incremental Search

     

    Tip Code:  vstipFind0001

    Keyboard Shortcut:  CTRL + I

    Video:  http://scottcate.com/tricks/001/

    Menu Command:  Edit -> Advanced -> Incremental Search

     

     

    Incremental search is a powerful search to use when you want to keep both your focus and your cursor in the editor when searching in the current document. It is powerful because it allows you to keep typing, meaning the search is driven by keystrokes. And you don't need to interact with any UI.

     

    To conduct an incremental search, follow these steps:

    1. Press Ctrl+I.

    2. Start typing the text you are searching for.  You'll see the cursor jump to the first match, highlighting the current search string:

      image

    3. If you look in the lower-left corner of your screen you will see an indication that you are doing an Incremental Search:

      image

    4. Press Ctrl+I again to jump to the next occurrence of the search string:
      image

    Here are all the options you can leverage while in this mode:

    To

    Use

    Move to the next match in the file

    CTRL+I

    Reverse the direction of the search

    CTRL+SHIFT+I

    Remove a character from the search string

    BACKSPACE

    Stop the incremental search

    ESC

  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 2012 New Features: Preview Tab

    • 15 Comments

     

    Preview Tab Overview

    We all explore code and need to move quickly between files when examining code to get familiar with it or debugging or [insert file browsing scenario here]. In prior versions of Visual Studio you had to open a file to look at the contents which often resulted in many open files (tabs) when you were done. The Preview Tab eliminates the need to open files when browsing code. Most likely you’ll first encounter the Preview Tab when you are looking at files with Solution Explorer. When you click on a supported file type, you will see the contents of that file in the new preview tab (to the far right in the tab well):

    image

     

    If you click anywhere inside the file the tab will go from grey to purple to distinguish it from regular (blue) tabs:

    image

     

    Again, the point of the preview tab is to let you view the contents of a file without actually opening up a new tab in the tab well. As you look at different files the preview tab only shows the contents of the file you are currently on. This keeps the environment from getting cluttered with open tabs and allows you to focus on only those files that are interesting to you. Solution Explorer isn’t the only place you can use the preview feature. It turns up in several situations where you might need to look at file content. For example, when using Find in Files (CTRL + SHIFT + F) to locate information you will see the preview tab:

    image

     

     

    Promoting Previews

    At some point you may decide to promote the preview to an opened tab in the Tab Well so you can do additional work on the file or just keep it around for other purposes. There are a few ways you can make this happen.

     

    Click the Keep Open button

    Probably the least useful and and least likely technique you will use is to click on the tiny Keep Open button on the Preview Tab.  It’s not only useless it’s actually kind of annoying for some reason I can’t identify:

    image

     

    Double Click the File

    The most likely approach is you will just double click the file in Solution Explorer or whatever results dialog you happen to be in.

     

    Press CTRL + ALT + HOME

    With the cursor inside the file (the tab is purple), just press CTRL + ALT + HOME to open a tab for the file you are currently viewing.

     

    Change the File

    While previewing a file, if you make any change to the file it will automatically be promoted to an open tab so that you can make additional changes and do any other actions you need to perform.

     

    Click the Preview Selected Items button

    Another button is useless and a waste of space on the Solution Explorer toolbar is the Preview Selected Items button.  You can click it to preview the current file and its only use that I can find is if you turn off single clicking a file to preview it (see below).  Also the tooltip would lead you to believe that you can select multiple files and preview them.  Nope.  Doesn’t work.  Don’t waste your time with this button.

    image

     

     

    Turning Preview Off

    To see the options you have for using the preview feature, just type preview in Quick Launch (CTRL + Q) and click Environment -> Tabs and Windows:

    image

     

    This will take you to Tools | Options | Environment | Tabs and Windows:

    image

     

     

    To turn off the preview feature (NOT suggested unless you are having performance issues with it) uncheck the Allow New Files to be Opened in the Preview Tab option. Also notice you can decide if a single click open the files in for preview in Solution Explorer and Find dialogs. For Solution Explorer you can use ALT to prevent a file from being previewed when you click on it. While I see the value in using ALT to prevent preview from happening. I haven’t yet found any reason for turning off the single-click option as it, in effect, forces you to use the Preview Selected Items button which is a lot of extra work and kind of defeats the purpose of the feature.

     

     

    Finally

    The Preview Tab is one of my top two favorite features in Visual Studio 2012 (the other one being project round-tripping).  You definitely want to leverage this feature to make your life easier.

  • The Ultimate Visual Studio Tips and Tricks Blog

    Reset All Your Development Settings

    • 2 Comments

    Menu:  Tools -> Import and Export Settings
    Command:  Tools.ImportandExport Settings
    Versions:  2008,2010
    Published:  7/16/2010
    Code:  vstipEnv0023

     

    In the final post dealing with the Import and Export Settings Wizard, we deal with the nuclear option-the "Reset all settings" option:

    image

     

    WARNING:  Use this at your own risk.  It WILL reset your settings and do things like reset your Toolbox thus getting rid of any custom tabs, code pieces, etc.. you have put in there.

     

    Clicking Next will give you the option to save your current settings.  YOU SHOULD ABSOLUTELY DO THIS:

    image

     

    The next screen let's you choose from the list of default settings:

    image

     

    Choose your default settings of choice and click "Finish".  It will run for a few minutes and reset all your settings.  This is definitely something you would do as a last resort and, remember, you can always bring your old settings back by importing the previous settings.

  • The Ultimate Visual Studio Tips and Tricks Blog

    Creating, Configuring, and Consuming a WCF Service in IIS 7

    • 10 Comments

    After much delay, here are the goods :)

     

    The goal here is to show how to create a basic WCF service that can be hosted in IIS7 and will kick over to other protocols using Windows Activation Service (WAS) as needed.  Your choice of language doesn't matter for this one and I will show code for C# and VB.  And awaaaaaaay we go...

     

     

    1. Start up Visual Studio by running it as Administrator

      image
    2. Begin creating a new Web Site

      image
    3. Feel free to pick your language of choice, for this demo I will call the services CoolServiceCS and CoolServiceVB respectively

      image
    4. Press F5 to build and run the application just to make sure all is well so far, you will get the obligatory error for debugging, just click OK:

      image
    5. You should ultimately see a web page that has something like this:

      image
    6. Close the service web page and let's see if IIS7 is aware of this service
    7. Go to the IIS Manager

      image

      image
    8. Expand the tree and, under "Default Web Site", you should see your service.

      image
    9. Okay!  So far everything seems to be going well.  Now let's take a quick peek at the service in Visual Studio to verify that it is, in fact, using HTTP to communicate.
    10. There are a couple of ways we can do this:  One way is to just open up Web.config and scroll to the <services> element:

      image
    11. Another way is to right-click on your Web.config and choose "Edit WCF Configuration..."
      SPECIAL NOTE:  There seems to be a "feature" that makes this not show up initially.  This is usually "fixed" by simply going to Tools...WCF Service Configuration Editor
      The funny thing is you don't appear to have to actually use this tool just open it and close it then you can right-click Web.config to get the editor option.  Weird.

      image
    12. If you expand the Service area and look at the Endpoints, you can see that wsHTTPBinding is used.  Once you have verified, close this dialog box.

      image
    13. The only thing I wish here is that the endpoints would be "automagically" named for us (we could always change the names) but, sadly, that is not the case.
    14. At this point we have created our service, run it, verified it is in IIS, and verified it uses wsHTTPBinding.  Now we need to create a client to consume the service.
    15. In Visual Studio, right-click on your Solution and choose Add New Project...

      image
    16. Let's use a Console Application for our client this time around.  Make sure to use your language of choice.

      image
    17. Call the application "CoolServiceClientVB" or "CoolServiceClientCS" as appropriate then click on OK.

      image
    18. Set the new project as the Startup Project.  

      image
    19. Now we need to right-click on the project and choose Add Service Reference...

      image
    20. The new service dialog is very cool and will find services in your solution if you just click on Discover --go for it! 

      image
    21. Leave all other settings as they are and click on OK.  You should see your reference in Solution Explorer.

      image
    22. Now let's crank a little code to actually use this service (finally!) heheh...
    23. Open up Module1.vb or Program.cs and put the following code in:

      VB:
    24. Sub Main()
             Dim myService As New ServiceReference1.ServiceClient()

             Console.WriteLine(myService.GetData(33).ToString())

             Console.ReadKey()
         End Sub

      CS:

      static void Main(string[] args)
              {
                  ServiceReference1.ServiceClient myService =
                      new CoolServiceClientCS.ServiceReference1.ServiceClient();

                  Console.WriteLine(myService.GetData(33).ToString());

                  Console.ReadKey();
              }

    25. This should look pretty straightforward.  We are calling one of the sample operations that are available with our WCF Service and then use ReadKey() to pause when we run the app.
    26. Press F5 to run this sucker and you should get this:

      image
    27. Press any key to continue.
    28. So we have a client and we have a service and we are all having a group hug.  Now what?  Well, now let's configure this puppy to use other protocols besides HTTP.  For this run, we will use TCP and Named Pipes.
    29. First, we have to configure Windows Process Activation Service (WAS) settings.  To learn more about WAS, go here:  http://msdn.microsoft.com/en-us/library/ms730158.aspx
    30. Assuming you're running Vista, we have to tell WAS that non-HTTP protocols can be used for activation.  If we were not using IIS to host this service we would also have had to tell it that HTTP activation is possible but fortunately IIS handles those details for us.  For more info on what we are doing here, you can check out this area http://msdn.microsoft.com/en-us/library/ms752218.aspx
    31. Go to Control Panel

      image
    32. Choose Programs

      image
    33. Now select Turn Windows Features On or Off

      image
    34. Go to the Microsoft .NET Framework 3.0 area and check the WCF Non-HTTP Activation.  NOTE:  Since this is my play machine, I also turned on WCF HTTP Activation as well but you don't have to unless you need it.

      image
    35. Click on OK; It may take a minute to install the needed files so be patient.  Go grab a drink or something, go on, you deserve it :)
    36. Next we have to configure the the web site to be bound to a TCP port for our activation to work.
    37. Open a command prompt with administrative privileges by right-clicking on the command prompt icon and choosing Run as Administrator

      image
    38. Copy and paste the following command into the command prompt area and press Enter

      %windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='808:*']
    39. The result should look similar to the following:

      image
    40. Now the Default Web Site is bound to TCP but we still need to allow TCP for our applicationCopy and paste the following into the command prompt area and press Enter:

      VB
      %windir%\system32\inetsrv\appcmd.exe set app "Default Web Site/CoolServiceVB" /enabledProtocols:http,net.tcp

      CS
      %windir%\system32\inetsrv\appcmd.exe set app "Default Web Site/CoolServiceCS" /enabledProtocols:http,net.tcp
    41. You should see something like this:

      image 
    42. Okay, the hard part is done.  We now have the Web Site and the application within the site configured for TCP.  We just need to tell the service to use TCP and then have the client use TCP to talk to the service.  Here we go!
    43. To configure the service, go to Visual Studio and Solution Explorer.  Now let's go to our service and right-click on Web.config to edit the WCF Configuration.  You may have to do that stupid Tools...WCF Service Configuration Editor workaround to get the context menu item to show up.  You may wonder why I just don't have you edit the XML directly and the answer is simple:  I'm all about easy and think that this way is easier for folks.

      image
    44. We need to make sure the service knows it can use TCP by creating a new endpoint.  Currently the only usable endpoint for communicating is HTTP but we are going to change that by right-clicking on endpoints under the Service and adding a new service endpoint.

      image
    45. Enter myTcpGoodness for the Name, choose netTcpBinding for the Binding, and enter IService for the Contract as seen here:

      image
    46. We also need to identify the BaseAddress for getting to our service.  Go to the Host area in the current dialog.

      image
    47. Under Base Address, click on New... and type in the following for the address then press enter:

      VB
      net.tcp://localhost/CoolServiceVB

      CS
      net.tcp://localhost/CoolServiceCS
    48. You should see something like this in the BaseAddress area:

      image
    49. Close the configuration dialog and you should be prompted to save changes.  Click Yes.

      image
    50. Let's make sure there are no errors.  Build the service by right-clicking on it and choosing Build Web Site.
    51. WOW!  We are on step 50 now.  Does it feel like your brain is going to explode like in the movie "Scanners"? http://www.imdb.com/title/tt0081455/  Just stay with me, we are almost done.
    52. At this point we could start configuring the client but I really like to run the service one last time to make sure there are no issues.  So this step is optional but suggested just to make sure everything is good with the service:  (1) Right-click on the Service.svc file and set it as the Start Page.  Right-click on the service project and choose Set as Startup Project.  Press F5 to run the application.  You should see the test page for the service.  If you do then all is well, if not go back and fix any issues.  Make sure to close the web page when you are done here and set the client application as the Start Up Project again.

      image
    53. Okay now on to the client.  Since we have updated the service we need to update the Service Reference on the client.  This is easily done.  Simply right-click on ServiceReference1 and choose Update Service Reference.

       image
    54. You should see this dialog flash by:

      image
    55. We are almost done.  Now we just have to tell the client what protocol to use based on the binding name.  Remember when you set the Name of the TCP Binding to myTcpGoodness?  Well you did that to make this step easier for us.  Go to Module1.vb or Program.cs to see the code for your client application.
    56. Now we will pass the name of the binding to use in the constructor so that the client uses the protocol we want.  Change the code for creating an instance of the service to this:

      VB
      Dim myService As New ServiceReference1.ServiceClient("myTcpGoodness")

      CS
    57. ServiceReference1.ServiceClient myService =
                      new CoolServiceClientCS.ServiceReference1.ServiceClient("myTcpGoodness");

    58. Now just run your client application and you should see the predictable result.

      image
    59. At this point you are probably asking if it is REALLY using TCP.  It's easy enough to test.  From your command prompt type in the following:
      DANGER:  DO NOT RUN THIS COMMAND ON A PRODUCTION MACHINE UNLESS YOU LIKE GETTING FIRED!

      net stop w3svc
    60. You should see this:

      image
    61. You have stopped IIS and killed HTTP as an option for communicating to our service.  Now run the client application again.  Does it work?  Then you are in business!
    62. We are done but if you want you can add net.pipe to be used just like you did with net.tcp and see if it works.  Play with it and enjoy!  Oh yeah, you might want to type in "net start w3svc" from the command prompt to get IIS running again.  :P
  • The Ultimate Visual Studio Tips and Tricks Blog

    SQL Server vs. Access: Which is right for you?

    • 6 Comments

     

    This question came up the other day from Craig P. and I thought it was such a good one I wanted to blog about it.  I think many of us take it for granted that upgrading from Access to SQL is a natural progression but we sometimes forget the "why" of it all.  the bottom line is that sometimes the answer is to upgrade but sometimes the answer is to keep using Access.  Making informed decisions is important and being able to convince management plays a critical role to your success.  So with that I present two articles:

     

    1)  Microsoft Access or SQL Server 2005: What's Right in Your Organization?

    http://www.microsoft.com/sql/solutions/migration/access/sql-or-access.mspx

     

    2) And, to help compare SQL 2005 vs SQL 2008, "SQL 2005 vs. SQL 2008 Part 1"

    http://www.sqlservercentral.com/articles/Compression/62746/ 

     

    Yes, you have to register at that last site unless, of course, you use something like BugMeNot.com:  http://www.bugmenot.com/

  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 2013 Preview: Code Map Debugger Integration

    • 11 Comments

    5-16-2012 12-48-10 PM

     

    Prologue

    The original Code Map was introduced in the product with Visual Studio 2012 Update 1. You need to read my original post before moving on:

    http://blogs.msdn.com/b/zainnab/archive/2013/02/07/visual-studio-2012-update-1-understanding-code-map.aspx

     

    My assessment at the time was that it was a good feature but had poor performance and didn’t really add much value relative to Dependency Graphs. With debugger integration however Code Maps have definitely come into their own and the performance is very good.

     

    Note: Code Map Debugger Integration is a feature in the Ultimate edition of Visual Studio.

     

     

     

    Code Map Debugger Integration

    Assuming you have a handle on Code Maps now let’s see how the debugger integration works. First, I’ll take the TailSpin Toys sample code and set a breakpoint within the code base (ShoppingCart.cs, line 61):

    5-16-2012 12-04-13 PM

     

     

    I’ll press F5 and add an item to my cart to trigger the debugger:

    5-16-2012 12-07-12 PM

     

     

    Ordinarily, we would step though the code and hope we remember how we got to a particular place. Those days are gone! Now we can turn on the Code Map feature while debugging:

    5-16-2012 12-12-27 PM

     

     

    You can also find this on the Menu Bar at Debug | Show Call Stack on Code Map:

    5-16-2012 12-13-37 PM

     

     

    You will see a Code Map in sync with the debugger at this point. You can create Code Maps in C#, VB, C++, JavaScript currently. Once activated all future debugging sessions will include a Code Map until you turn this feature off:

    5-16-2012 12-17-38 PM

     

     

    If we take a closer look at the current map, we can see that it shows how we arrived at the current call (the squares above the last AddItem call) and our current location (yellow arrow). Although the current location indicator is partially covering it, you can also see the breakpoint indicator:

    5-16-2012 12-27-35 PM

     

     

    Stepping through the code we see the map keeps updating so we don’t have to keep the path in our heads:

    5-16-2012 12-29-19 PM

     

     

    The Code Map will continue to update for our debugging session showing where we have been and where we currently are in the call stack:

    5-16-2012 12-35-58 PM

     

     

    The graphs can get quite large:

    5-16-2012 12-40-46 PM

     

     

    For this reason it’s important to use the map tools at your disposal. The context menu items when you Right Click any node are a great example of common tools:

    5-16-2012 12-45-23 PM

     

     

    You can Double Click any node to view the code from that location in the stack. A green arrow will indicate your current position:

    5-16-2012 12-54-27 PM

     

     

    If you happen to choose a node that isn’t part of the current active call stack then you will get a slightly different indicator:

    5-16-2012 12-57-41 PM

     

     

    When you stop debugging the Code Map will be preserved so you can save it if desired and keep a map of the code base you just went through. I think this is an exceptional addition to the debugging experience!

  • The Ultimate Visual Studio Tips and Tricks Blog

    Set a Simple Breakpoint Condition

    • 5 Comments

    Menu:  [Right-Click the Breakpoint] -> Condition
    Versions:  2008,2010
    Published:  5/3/2010
    Code:  vstipDebug0021

     

    image  

     

    Did you know you can set Conditional Breakpoints?  They are arguably the most powerful among the types of Breakpoints you can set.  There are many layers to using them correctly and knowing is half the battle.

     

    Let's start with the Breakpoint Condition dialog.  Notice that the condition can be turned off by unchecking the Condition checkbox.  Additionally, there are two options for the condition that you set:

    "Is true" is used for Boolean expressions that evaluate to true or false. 

    "Has changed" means what it says - if the expression changes then the code stops.

    image 

     

     

    Suppose I have this "for" loop:

    image

     

     

    "Is true"

    I can set a simple "Is true" condition that says when the variable "i" is greater than, say, 5 the code should stop:

    image

     

    When I run the code and the Breakpoint is hit, sure enough, it stops when the value of "i" is greater than 5:

    image 

     

     

    "Has changed"

    This one is more interesting.  Basically you set up something to watch.  In this case, I'll just have it watch the "i" variable:

    image

     

    When the Breakpoint is hit and the value of "i" has changed in in any way then the code stops:

    image

     

     

    Special Notes

    Anytime you set an advanced Breakpoint you will get a new glyph:

    image

     

    You can always tell what kind of breakpoint you have by looking placing your mouse over the glyph and looking at the tooltip:

    image

     

    Or checking out the Breakpoints window:

    image

  • The Ultimate Visual Studio Tips and Tricks Blog

    Single Sign-On with ASP.NET and Without Using Active Directory

    • 2 Comments

     

    Bill N. recently asked this one, here is some of the email:

    "I'm working a problem at the office that requires we implement a means of logging in once to a web site and then enable SSO access to all other web apps on that site.  We also need to implement roles-based security.  We currently have a SQL Server database containing username/password information and roles information.  These are not people who are in AD, or are ever going to be in AD.  We're currently using a third-party portal solution and a little custom code in each web app for all of this; we're looking to separate authentication and authorization from the vendor(s)."

     

    Here are some links to what I came up with but feel free to add to this if you have some insights:

     

    http://aspalliance.com/1545_Understanding_Single_SignOn_in_ASPNET_20

    http://blah.winsmarts.com/2006/05/19/aspnet-20-implementing-single-sign-on-sso-with-membership-api.aspx

    http://johndyer.name/post/2005/12/Single-SignOn-with-ASPNET-Membership-and-WebServices.aspx

  • The Ultimate Visual Studio Tips and Tricks Blog

    How to cycle through the Clipboard Ring to paste different things

    • 9 Comments

    Keyboard:  CTRL + SHIFT + V; CTRL + SHIFT + INSERT
    Menu:  Edit -> Cycle Clipboard Ring
    Command:  Edit.CycleClipboardRing
    Versions:  2008,2010
    Published:  1/2/2010
    Code:  vstipEdit0001

     

    image

     

    The Clipboard Ring keeps track of the past 20 items you've either cut or copied so you can reuse them over and over again!  After you hit item 20, it'll go back to the first item again. This is why the feature is called a Clipboard Ring.

     

    Give it a try!  Copy a few pieces of text into your clipboard then keep pressing CTRL + SHIFT + V to cycle pasting them in the editor.  This is one seriously cool time-saving feature. 

Page 5 of 135 (1,345 items) «34567»