Problem solved: Visual Studio stealing focus when breakpoint is hit

How many times have you been debugging and while you waited for a breakpoint to hit you switched to another application.  Then, while you were typing, the breakpoint hits and focus is ripped from the application your were typing into and set to Visual Studio.  In most cases the breakpoint is in code you have checked out so the worst thing that happens is that you overwrote some of your code, which can be easily remedied with the use of the Undo function.

I find this behavior to be very frustrating.  Why did the Visual Studio team at Microsoft decide to do this?  At a minimum they could have provided an option to turn it off.

I posted a request to a solution for this on my Twitter/Facebook status recently and a friend replied with a workaround – Tracepoints.  Here’s how it works:

  1. Set your breakpoint at the desired location.
  2. Right-click on the red breakpoint dot icon and select “When Hit…
  3. Select “Print a message”.
  4. Uncheck “Continue execution”.

You have effectively created a breakpoint that prints out the current function name and thread ID and name and then stops.  Tracepoints don’t steal focus like normal breakpoints do.

This isn’t an ideal solution, but at least it’s a workaround that works.

Message to Microsoft:  Please provide an option to turn off focus stealing in Visual Studio.

Leave a Comment

Viewing Distance Chart

I found a terrific chart published at HDGuru.com. It is an exhaustive table that includes the following information:

  • 16×9 diagonal measurement (the measurement of your screen or the screen you are considering).
  • Width of the 16×9 screen.
  • Height of the 16×9 screen.
  • Optimum viewing distance for 1080p/i material.
  • Optimum viewing distance for 720p material.
  • Width of 4×3 material on the 16×9 screen.
  • Diagonal measurement of 4×3 material on the 16×9 screen.
Resources

Comments (1)

Microsoft SharedView

There are quite a few screen sharing applications available, most of which are only available for a monthly fee.  Microsoft has released another one beyond Remote Desktop Connection that comes with their business and ultimate editions called SharedView.  This is a free sharing application that should make it easier to do the one-off sharing to use for helping someone out with a problem they are having with a specific application.  It also allows you to share the entire desktop if you want.

I tested it out briefly between two computers in my house and found it to be functional but sluggish.  I’d still recommend it for customer support-type sharing and for document collaboration.

Update 7/30/2009:
Apparently SharedView supports only the primary monitor, which means you can’t share anything on a 2nd or 3rd monitor. I was hoping to use it as a replacement for the solution our company uses, but I can’t do that now.

Resources

Leave a Comment

Invoking files with spaces in PowerShell

I needed to run an executable multiple times with different parameters and felt that it would be easier to write the script in PowerShell than in a command script.  The biggest challenge I ran into was running the executable because the path to it has spaces in it (C:\Program Files\etc).  Add to that I wanted to put the whole command in a string first and then invoke the string and this turned out to be a lot more challenging than I had hoped.

To invoke an executable (or any file, for that matter) that has spaces in it, you need to use quotes and then use the ampersand (&) operator.  For example, if you want to invoke a file called C:\My File.cmd, you would have to invoke it like so:
& '.\My File.cmd'
If you wanted to pass parameters, you would do this:
& '.\My File.cmd' foo
So far so good.  Things are a bit different, however, if you want to invoke a command in a variable.  To do that, you must use the Invoke-Expression cmdlet, like so:
$_cmd = "'.\My File.cmd' foo"
Invoke-Expression "& $_cmd"

or
$_cmd = "& '.\My File.cmd' foo"
Invoke-Expression $_cmd

PowerShell is certainly powerful, but this was far from obvious.  Fortunately there are others who have posted about this.  You can check out the resources I’ve listed below for a couple webpages that helped me.

Resources

Comments (1)

Cometdocs File Converter

I just ran across a free online file converter called Cometdocs.  This free online service allows you to convert different types of files to multiple other file types, including PDF.  You can also compare two files and get the results.

All you do is browse to a file on your disk, select the destination file type, then type an email address of someone to send the results to.  The recipient receives an email with a link to a page which allows them to download the resulting file.

The service keeps your file on their server for a limited amount of time (it wasn’t obvious to me how long in my brief perusal of their site) but if you want it to be stored longer you can sign up for a free account.

Very cool service!

Comments (1)

Failed to update headers in Outlook 2007

I use Outlook 2007 pretty rigorously.  I host my own Exchange Server, so that’s my primary mailbox.  I include multiple other mailboxes (such as my wife’s, my kids’, etc.).  Finally, I use IMAP to connect to my company’s Exchange Server so I can use a single interface for accessing all my email.  I’d use an Exchange connection if I could, but the Office team at Microsoft, in their infinite wisdom, decided this wasn’t something anyone should do.  Grrr.

Anyway, a week or two ago, I started getting an error message that looked like this every time I clicked on one of my IMAP folders:

Failed to update headers in Outlook 2007

An IMAP command failed.
        Protocol:  IMAP
        Server:     my.server
        Port:         143

I finally got myself unburied enough to investigate and found a very helpful post - a forum actually - that described how to solve this problem.  Microsoft provides the SCANPST tool which will scan and repair your personal store (.pst) and offline store (.ost) files which contain the mail data for your mail accounts and profiles.  Here are the steps to solve this problem:

  1. Close Outlook.
  2. Go to \Program Files\Microsoft Office\Office12\ and run SCANPST.EXE as Administrator.
  3. Browse for your .PST and .OST files.  If you haven’t changed the location, you will find them at
    \Users\AppData\Local\Microsoft\Outlook\
    on Windows Vista or
    \Documents and Settings\AppData\Local\Microsoft\Outlook\
    on Windows XP.
  4. Scan and repair all errors.  I had to do this 2 or 3 times for each file.  Be default the tool will save a backup file.  The second or third time you run it on a file it will want to overwrite the backup file it wrote the last time you ran it, so either change the name or answer yes to overwrite it.
  5. Restart Outlook.

But wait - this didn’t work for me.  No matter how many times I used SCANPST.EXE, it didn’t solve the problem.  My problem turned out to be caused by a corrupted meeting request in my inbox.  As soon as I deleted the meeting request, the problem went away.  I only found it by connecting to my inbox using Outlook Web AccessW when I discovered I couldn’t view it from there either.  What would have been nice is to have found a tool to scan my Exchange inbox.

Oh well.  At least I solved my problem.  I’d be interested to know if you find other solutions to this problem, particularly one that involves a tool that scans Exchange Server mailboxes.

Resources

Comments (7)

Changing the WordPress Table Prefix

WordPress allows you to specify the prefix used for naming all your tables.  Unfortunately, there are several places where it hard-codes the full names of the tables, including the prefixes, so you can’t just rename the tables.  You also must modify values in the tables.  I’ve had to do this a few times recently as I’ve reorganized my sites, so I figured it was time to write an article about it.

Here are the steps to change the prefix for your WordPress site.  I use phpMyAdmin v3, but you can use any tool that allows you to manage your MySQL databases.  These steps assume you are changing your prefix from prefix1_ to prefix2_.

  1. Rename all the tables beginning with prefix1_ to prefix2_.  You do this in phpMyAdmin by doing the following:
    1. Click on the database name.
    2. Click on each table whose name begins with prefix1_ in turn.
    3. Click on the Operations tab.
    4. In the Table options section to the left, replace prefix1_ with prefix2_ in the table name and click Go.
  2. Rename the values in the meta_key column of the wp_usermeta table using this SQL command:
    UPDATE `prefix2_usermeta` SET `meta_key` = REPLACE( `meta_key` , 'prefix1_', 'prefix2_' );
  3. Rename the values in the option_name column of the wp_options table using this SQL command:
    UPDATE `prefix2_options` SET `option_name` = 'prefix2_user_roles' WHERE `option_name` ='prefix1_user_roles' AND `blog_id` =0;

It’s possible that some plugins may need additional attention.  You may still need to deactivate and then re-activate some plugins, and you may even need to deactivate some plugins, delete their options from the prefix2_options table, then re-activate them.  Finally, you may find that the prefix is embedded in other places as well.

I found the following blog post to be very helpful as I was tracking down this problem:

Leave a Comment

The “Get Started With Office Live” window keeps popping up

I have Office 2007 installed on a Windows Vista system and I installed the optional Office Live add-in offered to me through Windows Update.  The first time you start Word, Excel, or PowerPoint, it is supposed to pop up a getting started window to allow you to get more information on Office Live, but there is a checkbox in the lower left corner allowing you to prevent the window from being displayed again.  The problem is, the checkbox doesn’t always work.  Microsoft published a KB article on it and in that article says this condition happens when the person running Office isn’t the person who installed the add-on.  The problem is that it is looking for a registry key that doesn’t exist in the current user’s registry and therefore it doesn’t write the value which allows the popup to honor the setting of the checkbox.

The fix is easy.  Just define an OfficeLive registry key at HKEY_CURRENT_USER -> Software -> Microsoft.  This worked for me.  Kind of a sloppy error, though, if you ask me.

Resources:

Leave a Comment

Upgrading to IE8 breaks debugging with Visual Studio 2005

Since Microsoft published IE8 as a Windows Update and my boss said he upgraded to it, I figured it was safe to upgrade to it as well.  I’ve been enjoying the changes for a couple days now, but when I attempted to debug an ASP.NET application with Visual Studio 2005, it would no longer stop at a breakpoint.  Pretty frustrating if you ask me.  I’ve found a few articles online describing problems, most of which I haven’t encountered yet.  You may want to implement all these workarounds.

The problem I was having appears to be related to how IE8 uses multiple processes.  Apparently VS 2005 doesn’t know which process to attach to.  Here are three solutions:

  1. Don’t have IE8 running at the time you want to debug.  This worked for me.
  2. Modify the registry as described in the second link above.  This worked for me as well.  Here are the steps:
    1. Open RegEdit
    2. Browse to HKEY_LOCAL_MACHINE -> SOFTWARE -> Microsoft -> Internet Explorer -> Main
    3. Add a DWORD value called TabProcGrowth with a value of 0
    4. Turn off protected mode browsing in IE (Security page of Internet Options) if you are running on Vista or newer.
  3. Uninstall IE8 to revert back to IE7.  I don’t really want to do this though.  I’ve grown particularly fond of a few of the new features in IE8, such as previous session restore (although I wish it would allow me to restore more than just the last session) and improvements in search.

I don’t know if this is a problem with VS 2008, but some of the articles seem to imply it only applies to VS 2005.  Maybe it’s time to upgrade Visual Studio :-)

Comments (33)

Determining what a SQL Server connection is doing

Quick note here describing how to find out what a connection to a Microsoft SQL Server is doing.  First you need to find the connection.

Display current connections

Use the sp_who2 stored procedure to find the current connections.  Use the following information to determine the connection of interest.

  • SPID - The ID of the connection.  You will need this in the next step.
  • Status - Typically this will be RUNNABLE, but occasionally it will be sleeping or SUSPENDED.
  • Login - Typically the user who’s connection you are investigating (e.g. your own).
  • HostName - The name of the computer making the connection.
  • DBName - The database to which the connection is made.
  • Command - The command being executed.  Only displays the high-level command (e.g. SELECT INTO, DELETE, etc.).

Note that you can also specify an SPID to the sp_who2 stored procedure to get information about a specific connection.

Display the command

Use the following command to display the full SQL command being executed (where 53 is the SPID for the connection).
dbcc inputbuffer(53)
This command will display a result row with three columns:

  • EventType
  • Parameters
  • EventInfo

EventInfo contains the information you are looking for.

Leave a Comment

 Page 3 of 16 « 1  2  3  4  5 » ...  Last »