A cacophony of ramblings from my potpourri of notes
 Saturday, January 03, 2009
Visual Studio Keyboard Shortcuts for Editing (MSDN Flash -Jan. 19, 2009)

Knowing all the keyboard shortcuts for editing shows off our programming prowess, just like it would it did for programmers that could use VI.   Rather than describing the well known ones like CTRL+F and CTRL+H, I am going to review some that are more unique to Visual Studio Programming:

Find

  • CTRL+I/CTRL+Shift+I
    imageIncremental Search: Turns on incremental search so that characters typed next will be search for in sequence within the file.  Use CTRL+Shift+I to search up and ESC to cancel.
  • CTRL+Shift+F and Ctrl+Shift+H
  • Find in Files:  Displays the find dialog with Look in: set to Entire Solution, so that a search will look across all files in the solution and display the results in the Find Results window.  Using the up and down arrows, you can select which result to navigate to and then press ENTER to go there.  Similarly, Ctrl+Shift+H will perform a search and replace across files in the solution.
  • CTRL+K, CTRL+R
    Find All References: Takes into consideration the fact that you are navigating source code and, therefore, looks for all references for the item the cursor on.  F3 and Shift+F3 will navigate back and fourth between all the references found.

Editing

  • CTR+Shift+V
    Cycle Clipboard Ring:  Did you know that Visual Studio has a clipboard ring?  With this keyboard shortcut you copy different text areas, one after the other, without pasting the text in between.  After copying you can paste using CTRL+Shift+V - each time will cycle back through what you copied, allowing you to select what to paste, from the set of copied items you placed into the clipboard ring.
  • CTRL+Shift+L
    Delete the selected line.  CTRL+L cuts the selected line into the paste buffer. 
  • CTRL+Shift+T
    Transpose Words: Transpose the current word with the following word, pivoting on the operator separating them.  For example, given FirstName = firstName, the transpose keyboard shortcut on FirstName would switch the code to firstName = FirstName.  Similarly, Multiply(x,y) would switch to Multiply(y, x).

Outlining

  • CTRL+M, M
    Toggle outline expansion for the current context.

Ctrl M, M

  • CTRL+M, P
    Turn off outlining entirely.  Reopening the file will re-enable the outlining.

Coding

  • CTRL+. and CTRL+K, S
     image
    Whenever a smart tag appears (for example after renaming a method or variable), use CTRL+. to display the smart tag menu and then ENTER to select which menu to use.  (I can't imagine coding without rename anything significant without rename and this keyboard shortcut.)  Similarly, CTRL+K, S displays the surround with context menu, allowing you to surround the selected text with a region for example (C#).
  • CTRL+K, L and CTRL+K, P, also CTRL+K, I
    List Members: I frequently see other people (okay, I do this myself) deleting the period so that they can see the listing of IntelliSense options again.  CTRL+K, L is the keystroke to do this without deleting.  Similarly, rather than deleting the left parenthesis, use CTRL+K, P to display the parameter info for the function you are calling. CTRL+K, I will display the help tip for the method you are calling.
  • CTRL+K, C and CTRL+K, U
    Comments out the currently selected code.  These shortcuts are for end-of-line comments rather than block comments.  Use CTRL+K, U to un-comment the selected text. 
  • Shift+ALT+ENTER
    Full Screen: Toggles in and out of full screen mode.  Great for when you are heads down coding a method and want the most real estate you can get on a single screen.
  • CTRL+E, W
    Toggle Word Wrap:  If you frequently find lines within the code editor going beyond the screen you can toggle on word wrap so that lines wrap.  (Personally, I suggest a coding standard that encourages developers not to write 200 character lines).  In my books the limit is 72 (a little too small for comfort :)
  • CTRL+Shift+F12
    Next Error:  I should have mentioned this one last week.  After compiling, you can navigate between errors using CTRL+Shift+F12. 

Saturday, January 03, 2009 11:48:10 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]  Computer Related | .Net

 Friday, January 02, 2009
Starting out the Year with a Run and a (Polar Bear) Swim

This new year is the second one for me that I start out with a run and a swim in the morning.  There is nothing particularly special about either of these events except it has a kinda symbolism for starting out the year right.

New Year's Day was a little more challenging this year.  It started out with a weather advisory from the National Weather Service for Spokane, WA area:

HEAVY RAINFALL COUPLED WITH MELTING SNOW WILL RESULT IN FLOODING OF SOME CITY STREETS AS WELL AS SMALL STREAMS AND LOW LYING RURAL AREAS. SNOWFALL THIS MORNING WILL CHANGE TO RAIN THIS AFTERNOON AND CONTINUE OVERNIGHT. RAINFALL IS EXPECTED TO BE HEAVY WITH AROUND 1 INCH OF RAIN EXPECTED BY FRIDAY MORNING. CITY STORM DRAINS COVERED WITH SNOW AND ICE COULD QUICKLY RESULT IN STREET FLOODING.

Well... at least everywhere that I went, it wasn't rain but snow!  As has been the case for most days over the past two+ weeks, I start out by shoveling the drive way (I secretly still enjoy starting the day this way).  However, the result was that I was a little late picking up John Martinek.  Fortunately, he had paged me earlier suggesting that we cancel so he wasn't quite ready anyway.  Glad I didn't get that page or the day wouldn't nearly have been as fun since I probably wouldn't have left the house.  Along with John's wife, Kelly, we drove down to Coeur d'Alene for the Hangover Handicap.

Hangover Handicap

The Hangover Handicap run is put on by TESH, Inc, a non-profit rehabilitation organization helping those who are disabled and/or disadvantaged to reach their highest level of independence.  The course runs along lake Coeur d'Alene, ID, an exact match for a portion of the Coeur d'Alene Ironman run section. 

image

There was certainly nothing special about my time.  In fact, we arrived a few minutes late so we didn't even start until only the walkers could be seen in the distance.  I knew a a few folks from Itron in the race (Doug Dominey and Fran Johnson) so once I was able to catch them, I doubled back a few times to say, "Hi" and run with John some.  In total, I stats were as follows:

Distance (including doubling back): 5.24 miles
Time: 42:32
Pace: 8:07 min/mile

Nothing to write home about but we ran on snow the whole way, it was snowing heavily, and I can say I even enjoyed myself (not the usual poking yourself in the eye type of experience. :)  After grabbing an apple cider from a local restaurant, we headed down to the lake for a swim.

John and Mark

2009 Coeur d'Alene Polar Bear Swim

It seemed we were going to be just in time for the plunge but on the way there a truck (4X4) go stuck in front of us - I was driving a Honda Odyssey.  We of course stopped and once they got going we were stuck too.  Traffic started to line up quickly behind us.  Eventually, we got the line to reverse and we rolled back for a running start.  We got to the top of the hill and started sliding down the other site, narrowly missing a parked car on the way down.  I slowly rushed to the plunge area to join the other 1,000 or so "crazies."  Unfortunately, the bell went off just as we were entering the area.  Bummer.... I pushed through the watchers, raced down the beach, stripped, and dived in after everyone was already out.  (Heck, I had come all that way, I wasn't going to miss it now.)

Once I got out, John and Kelly came over to see if I was still alive.  John's doing the Ironman this year so he had no choice but to pressure him to go for a swim. He reluctantly agreed, and to ensure I wasn't asking him to do something I wouldn't do - I joined him for a my second swim of the day.  (I think that credits me for having done the polar bear swim 3 times in two years.)

CDAPress had a great description of the event in the newspaper the next day.  I say great because it does a good job of having absolutely no explanation of why people do this type of thing but that they do it anyway. :)

I highly recommend this experience.  Really, it sounds stupid (in fact, it is stupid) - however, having done it now, I can say it is actually pleasurable - really!  The coming up for a breath isn't great - you feel almost short of breath.  However, once you stand in the snow and soak up the experience - there is just something inside you that makes you want to yell... YEAHHH!!! 

(P.S.  Don't do it twice on the same day like I did, that isn't so great.)  


Friday, January 02, 2009 5:30:16 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]  Personal | My Sports

 Saturday, December 20, 2008
Visual Studio Keyboard Shortcuts for Compiling (MSDN Flash - Dec. 29, 2008)

There is not much point in writing code if you can't compile it so, in this edition's keyboard shortcut tips and tricks, we are going to discuss compiling your code.  For both Visual C# and Visual Basic schemes, you can compile the entire solution using Ctrl+Shift+B.  However, three keys (requiring two hands and an elbow) is a little unfriendly for what should be a relatively frequent operation.  Fortunately, the Visual C# scheme also allows F6 for the same activity and you could map the same key for Visual Basic (unless splitting the window is a frequent occurrence for you :). 

This works well when you only working with one or two projects in a solution, but what about when you solutions has 20+ projects in (a common occurrence if you have test projects for each production assembly).  Fortunately, you can use Shift+F6 (in the Visual C# scheme) if you only want to compile just the current project.  A great way to check for compilation issues on recent changes - perhaps removing squiggles that are not cleared up by the just-in-time compiler (an issue considerably reduced in Visual Studio 2010).

Another useful build related keyboard shortcut in the Visual C# scheme is Ctrl+Break.  This shortcut cancels the currently executing build - a useful command, especially when a single syntax error is generating a plethora of errors and you want to go back and fix it quickly.

For those of you with one of the Visual Studio Team System SKUs that included code analysis, there are are commands for running it.  Visual Studio Team System's code analysis analyzes the compiled assemblies for suspicious code (a bad code smell) and then flags the issue using a warning.  (I have found this to be invaluable for my team in automatically catching issues even before the point of code review - frequently issues that are hard to spot with the naked eye.)  You can turn on code analysis within the project properties:

image

However, there are two potential issues.  Firstly, turning on code analysis adds noticeable time to you build - this is worth it before checkin, but sometimes a distraction from the task at hand.  Secondly, warnings in dependent projects will no longer appear in an incremental build, causing them to be lost until you perform a rebuild all.  One work around for both of these is to assign a keystroke to code analysis (perhaps Ctrl+Alt+F6):

image

One more minor note:  If you install VMWare 6.5, it will re-map F6 to "Start debugging in a virtual machine," causing an "Unable to detect the current startup project" error dialog to appear.  To correct this, re-map F6 back to Build.BuildSolution.

Posted for MSDN Flash: Keyboard Visual Studio Tips & Tricks for Dec 29, 2008


Saturday, December 20, 2008 7:16:19 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]  

 Monday, December 15, 2008
Unattended Installation of Team Foundation Server 2008 on Windows 2008 with SQL Server 2008

The following are my instructions for installing a new Team Foundation Server 2008 with SP1 onto Windows 2008 with SQL Server 2008.

Throughout, I followed the TFS install guide and tried to automate where it didn't distract me too much from the task at hand.  I followed the Single-Server Team Foundation Server Installation.

Folder Layout

For the scripts to work successfully, you need the following placed into a local directory (probably without spaces in the name):

.\dotnetfx35.exe
.\SQLServer2008\   (SQL Server 2008 install)
.\TFS2008\             (TFS 2008 install)
.\TFS90sp1-KB949786-ENU.exe
.\TFSSetup.exe         (A custom TFS 2008 Setup utility I created for unattended installation)
.\WSS3wSP1.x86.exe

Prerequisites

Start with a mostly virgin Windows 2008 server.  I say mostly because I joined the machine to the domain and installed all Windows Updates.  In addition,  I created a single TFSSERVICE domain account.

Installation

  1. Turn on remote administration. [Optional]
      REG ADD "hklm\system\currentcontrolset\control\terminal server" /f /v fDenyTSConnections /t REG_DWORD /d 0
  2. Install IIS 7.0
      ServerManagerCmd -install Web-Server
      ServerManagerCmd -install Web-Http-Redirect
      ServerManagerCmd -install Web-Asp-Net
      ServerManagerCmd -install Web-Windows-Auth
      ServerManagerCmd -install Web-Mgmt-Compat
  3. Installed the .NET Framework 3.5 Service Pack 1 (Full Package) 
      // use /norestart to prevent autorestart
      .\dotnetfx35.exe /qb
  4. Installed SQL Server 2008.
      .\SQLServer2008\Setup.exe /ACTION=Install /FEATURES=SQLENGINE,FULLTEXT,AS,RS,SSMS,ADV_SSMS /INDICATEPROGRESS 
      /QUIETSIMPLE /ERRORREPORTING=1 /INSTANCEDIR="%ProgramData%\Microsoft SQL Server" /SQMREPORTING=True
      /INSTANCENAME="MSSQLSERVER" /AGTSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" /AGTSVCSTARTUPTYPE="Automatic"
      /ISSVCSTARTUPTYPE="Automatic" /ISSVCACCOUNT="NT AUTHORITY\NetworkService" /ASSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE"
      /ASSVCSTARTUPTYPE="Automatic" /ASDATADIR="C:\ProgramData\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Data"
      /ASLOGDIR="%ProgramData%\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Log"
      /ASBACKUPDIR="%ProgramData%\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Backup"
      /ASTEMPDIR="%ProgramData%\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Temp"
      /ASCONFIGDIR="%ProgramData%\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Config"
      /ASPROVIDERMSOLAP="1" /ASSYSADMINACCOUNTS="BUILTIN\Administrators" /SQLSVCSTARTUPTYPE="Automatic"
      /SQLSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" /SQLSYSADMINACCOUNTS="BUILTIN\Administrators"
      /BROWSERSVCSTARTUPTYPE="Automatic" /RSSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE"
      /RSSVCSTARTUPTYPE="Automatic" /RSINSTALLMODE="FilesOnlyMode" /FTSVCACCOUNT="NT AUTHORITY\LOCAL SERVICE"
    The only customization I made was to move the data storage to C:\ProgramData\... rather than the default C:\Program Files\....  I prefer this because I like to keep all data separate from the program executables themselves.  One other thing to note is that my log files are on the same disk as the databases - consider improving for your scenario.
    NOTE: The first phase of the SQL Server 2008 install is to install Windows Installer 4.5 if it isn't already installed.  Unfortunately, this requires a reboot after which you need to re-run the SQL Server 2008 setup.  Consider running an autologon.exe utility at the beginning of your installation (so that the password prompt occurs before you leave the computer to do the install) in order to set the computer to automatically logon after rebooting.  You will also want to use the Runonce registry setting to re-run the SQL Server 2008 install.
  5. Installed Windows SharePoint Services 3.0 with SP1
      IF NOT DEFINED TFSSERVICEPASSWORD ( SET /P TFSSERVICEPASSWORD=Enter the TFS Service password: ) 
      
      WSS3wSP1.x86.exe /Extract:"%TEMP%\WSS3wSP1" /passive /quiet
      "%TEMP%\WSS3wSP1\setup.exe" /config "%~dp0Wss4TfsSingleServerConfig.xml" 
      CHOICE /T 1 /D Y /M Waiting...
      RD /Q /S "%TEMP%\WSS3wSP1
      
      SET PSCONFIG="%COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\12\bin\psconfig.exe"
      %PSCONFIG% -cmd configdb -create -server localhost -database SharePoint_Config -user %USERDOMAIN%\TFSSERVICE -password %TFSSERVICEPASSWORD% -admincontentdatabase SharePoint_Admin_Content 
      %PSCONFIG% -cmd adminvs -provision -port 2500 -windowsauthprovider onlyusentlm 
      
      SET STSADM="%COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\12\bin\stsadm.exe" 
      %STSADM% -o extendvs -exclusivelyusentlm -url http://%COMPUTERNAME%.%USERDNSDOMAIN% -ownerlogin %USERDOMAIN%\tfsservice -owneremail "tfs@%USERDNSDOMAIN%" -sitetemplate sts -description "Team Foundation Server" 
      %STSADM% -o siteowner -url "http://%COMPUTERNAME%.%USERDNSDOMAIN%" -secondarylogin %USERDOMAIN%\%USERNAME% 
      
      %PSCONFIG% -cmd adminvs -provision -port 2500 -windowsauthprovider onlyusentlm
    This script extracts WSSwSP1 to a temp directory and then executes the setup unattended using the Wss4TfsSingleServerConfig.xml file with ServerRole Web Frond End (WFE).  The WSS setup doesn't perform any configuration.  Instead, the psconfig.exe and stsadm.exe configure the server following the install.  Note that I use port 2500 as my SharePoint central administration port (something I have standardized on).  In addition, I use a fully qualified name for the WSS url.
    The Wss4TfsSingleServerConfig.xml contains the following:
    <Configuration>
        <Package Id="sts">
            <Setting Id="REBOOT" Value="ReallySuppress"/>
            <Setting Id="SETUPTYPE" Value="CLEAN_INSTALL"/>
        </Package>
        <DATADIR Value="%ProgramData%\Microsoft SQL Server\MSSQL$SHAREPOINT\Data" />
        <Logging Type="verbose" Path="%temp%" Template="Microsoft Windows SharePoint Services 3.0 Setup(*).log"/>
        <Setting Id="SERVERROLE" Value="WFE"/>
        <Setting Id="UsingUIInstallMode" Value="0"/>
        <Display Level="none" CompletionNotice="no" AcceptEULA="Yes" />
    </Configuration>
    
  6. Slipstreamed Team Foundation Server SP 1 into the .\TFS2008wSP1 directory.
    .\TFS90sp1-KB949786-ENU.exe /extract:"%TEMP%\TFS2008SP1"
    msiexec /a .\TFS2008\at\vs_setup.msi /p "%TEMP%\TFS2008SP1\TFS90sp1-KB949786.msp" TARGETDIR="%CD%\TFS2008wSP1\AT" /L*vx c:\temp\install.log
    CHOICE /T 1 /D Y /M Waiting...
    RD /Q /S "%TEMP%\TFS2008SP1"
  7. Since there are no unattended command line switches for the Team Foundation Server install, I created a custom executable called TFSSetup.exe that I created to automate an unattended install of Team Foundation Server SP1.  A few things to note about the custom executable:
    • It accepts the license terms and assumes the product key is defaulted.
    • The deployment directory is the default directory for the TFS setup.
    • It assumes a Single Server TFS deployment and uses the default database server name (%COMPUTERNAME%)
    • It assumes the TFS Service name is %USERDOMAIN%\TFSSERVICE and that the password is stored in the environment variable TFSSERVICEPASSWORD (if it is not, the program will prompt for the password).
    • The SharePoint settings are http:\\%COMPUTERNAME%:2500 for the admin site and http:\\%COMPUTERNAME%.%USERDNSDOMAIN%/Sites for the Sites URL.
    • Alerts are not enabled.

Possible Errors:

Error: This installation package could not be opened.  Contact the application vendor to verify that this is a valid Windows Installer package.

Verify that the source directory (with the RTM version of TFS) is pointing to the AT directory.

Error: The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2203.

This is caused because some of the files are read-only.  Run Attrib -R .\* /S /D on both the SP1 and TFSRTM directories.

Error: The upgrade patch cannot be installed by the Windows Installer service because the program to be upgraded may be missing, or the upgrade patch may update a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade patch.

Error: The server parameter specified with the configdb command is invalid. Failed to connect to the database server or the database name does not exist.  Ensure the database server exists, is a Sql server, and that you have the appropriate permissions to access the database server.  To diagnose the problem, review the extended error information located at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12LOGS\PSCDiagnostics_12_14_2008_18_24_58_443_440016503.log.  Please consult the SharePoint Products and Technologies Configuration Wizard help for additional information regarding database server security configuration and network access.

This error occurred because I included both the dbuser and dppassword when executing psconfig.exe configdb.  Upon removing both those parameters, the error was avoided.

Error: The SQL Server Browser service is stopped.
Error: The SQL Server Browser service is not set to start automatically.

Error: TF220041: The specified Windows SharePoint Services site URL (http://<DefaultSiteURL>/Sites) is not the default site collection site: (Sites).
The default site collection site might have been renamed or removed. Make sure that the site exists and verify the correct URL,
and then attempt installation. If the problem persists, you can choose to install and configure Windows SharePoint Services as
part of the Team Foundation Server installation process.

This error occurs when you specify the Windows SharePoint Server URL without the "/Sites" suffix.  Team Foundation Server 2008 does not work correctly against the root.  You must specify includes the "/Sites" suffix to avoid this error.


Monday, December 15, 2008 4:31:04 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]  Computer Related | .Net

 Monday, December 08, 2008
SQL Server 2008 Install Nightmare

It all started with an installation of Visual Studio 2008 SP1, which included SQL Server Express 2005.  From there I wished to install SQL Server 2008 Standard on the default port and upgrade SQL Server 2005 Express to SQL Server 2008 express.  Unfortunately, this proved to be a troublesome desire.  I have no idea what the cause is exactly, except that I was not the only one on my team to have issues.

At this point, I am not sure the order that things occurred exactly, but I have a host of error messages and ways to handle them.  I can't say it will work for you - I sure hope you didn't have to go through all these to install SQL Server 2008 - but I did so I decided to share the experience.

Uninstall procedure:

The most important step with any failed SQL Server 2008 installation is uninstalling the failed attempt - yes, SQL Server 2008 needs to be uninstalled if an installation fails as it doesn't automatically roll back. 

At the moment there is no complete knowledge base article on how to manually uninstall SQL Server 2008.  However, there are instructions for how to uninstall an instance of SQL Server 2005 manually and there is a lot of similarity with SQL Server 2008, so review and follow those instructions were it makes sense.  Below is a list of the steps I followed:

  1. Uninstall the the installation from Programs and Features/Add Remove Programs, selecting Microsoft SQL Server 2008 and double clicking to run the uninstaller. (You always need to begin with this step or the command line equivalent.)  Do not use the Windows Installer Cleanup Tool to remove SQL Server 2008 without first trying to do so from Programs and Features/Add Remove Programs. During the uninstall, you can choose (via series of check boxes), which components of SQL Server 2008 to uninstall - including any shared components for when you have multiple instances.  In the case of multiple instances, each instance needs to be uninstalled independently.
  2. Run
         SC.EXE query | find /i "SERVICE_NAME: MSSQL" 
    to verify that there are no services instances for SQL Server that should have been deleted but weren't.  Any items that appear unexpectedly, should be removed with the command
         SC.EXE delete <service name> 
    Where service name is the name of the service returned by sc.exe query.
    If SC.EXE fails to uninstall the services and there are no other instances of SQL Server installed, delete registry keys HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSSQLSERVER and HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SQLAgent
  3. Search for <Instance Name> in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall.  If you find any, usually on a value called InstanceId, run
         MSIEXEC /X <GUID>
    where the <GUID> is the key name containing the InstanceId value.
  4. Delete the following registry keys/values if they exist
    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\<Feature>.<Instance Name>
    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\<Instance Name>
    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL\<Instance Name>
  5. Delete %ProgramFiles%\Microsoft SQL Server\<Feature>.<Instance Name> if it exists.
  6. Finally, search for the <Feature>.<Instance Name> in the registry and consider deleting any remaining items. In some cases this involves deleting the value because the other values within the same key are for a different instance.  In other cases, the entire key will need to be deleted because there is no other instance data within the key.  Hopefully, you won't encounter anything significant, but this is a good final step.

<Feature> has a value like MSSQL10 or MSAS10
<Instance Name>
is the name of the SQL Server instance you are trying to uninstall.

 

Pheww, now that we have completely uninstalled, lets review potential errors you might encounter:

Error: A later version of Microsoft SQL Server Compact is already installed.

Strange, since all I wanted was to install the SQL Server 2008 Tools.  Here are the steps to correct:

    1. Uninstall all parts of the SQL Server Compact Framework 3.5 SP1. 
    2. Rerun SQL Server 2008 install. 
    3. After installing SQL Server 2008 Tools, downloaded and reinstalled the SQL Server Compact Framework SP1.  The tools are located here:

Error: The following error has occurred: Could not open key: UNKNOWN\Components\CBFF54E0ED12B0946A1C52E5E82ABC38\E7BEEF5F746F8AB9076051A5574.  Verify that you have sufficient access to that key, or contact your support personnel. (Errors could be for other GUIDs as well)

The following error has occurred: Could not open key: UNKNOWN\Components\CBFF54E0ED12B0946A1C52E5E82ABC38\E7BEEF5F746F8AB9076051A5574.  Verify that you have sufficient access to that key, or contact your support personnel.

Errors could be for other GUIDs as well including UNKNOWN\Components\493032C95B52CBD448DD2B5A52C50E9A\3EC761FD7E06AE4499CE52705CF173EA.

This error is a permissions error in the registry.  If you search the registry for the first GUID you will find the key is likely mapped to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\<user SID>\Components\<GUID>.  Beneath this key is a sub key for the second GUID.  However, selecting the subkey will result in an access denied message.

To correct the problem:

1. Verify that you are running RegEdit as administrator (to avoid UAC issues with Windows Vista and Windows 3008+).

2. Edit the permission of the parent key(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\<user SID>\Components) and click the Advanced button. (Optionally, you could edit the permissions on the parent GUID (CBFF54E0ED12B0946A1C52E5E82ABC38 in my example) but the same problem is likely to exist with other keys so you may as well deal with this in mass.)

image

3.  From the Advanced dialog, select the Owner tab and check the Replace owner on subcontainers and objects check box.  Also, verify that System is the owner (else add System and be sure to select it so it will become the owner). 

4. Next click Apply.

4.  You may be presented with an error dialog, "Registry Editor could not set owner on the key currently selected, or some of its subkeys."  You can safely ignore this warning as long as you are then able to view the subkey.  If not :(, you may have to follow the same process but in safe mode or download Process Explorer and search for any process that is holding onto the key so that you can shut it down.  (The idea that a process is preventing you from viewing the key is a stretch in my mind but I have had heard the Platform team of Microsoft's product support group suggest this.)

5.  Lastly, select the "Effective Permissions" tab and verify that both your own User Id and the System user have Full Control.  If not, add both users via the Permissions tab.

If this still fails, consider resetting registry permissions back to the default settings using the following command:

    Registry security: secedit /configure /cfg %windir%\inf\defltbase.inf /db defltbase.sdb /verbose /areas REGKEYS

Error: SQL Server setup has encountered the following error. sku

Manually uninstall SQL Server 2008 installation and try installing again.

Error: Error 1316.A network error occurred while attempting to read file ssceruntime-enu.msi.

Connect mentions this error.  I followed a similar procedure.

  1. Extract the ISO file or copy the SQL Server CD onto the local drive. 
  2. Copy the .\<platform>\Setup\SSCERuntime.msi file to SSCERuntime-enu.msi within the same directory.  This seemed appears to work around the error.  I haven't tested this exhaustively, but I suspect this is a 64-bit problem only so the <platform> directory is most likely x64. (Please comment and let me know if you see this on other platforms.)

Error: Error result: -2068578301

Manually uninstall SQL Server 2008 installation and try installing again

Error: SQL Server installation failed. To continue, investigate the reason for the failure, correct the problem, uninstall SQL Server, and then rerun SQL Server Setup.

Sometimes, the error log points to a message indicating there was a network error.  During the occasions that I encountered this error message within the log, my installation failed with two red X icons in the concluding dialog, only one of which had a corresponding message (I wish I had taken a screen shot.)  The solution for me was to manually uninstall.

Error: Could not find the Database Engine startup handle.

This error appears after an installation completes unsuccessfully and a different error dialog appeared earlier in the installation.  Manually uninstall all the instance related installations items, address the previous dialog, and re-attempt the install.

Error (during repair): The SQL Server feature 'SQL_Engine_Core_Inst' is not in a supported state for repair, as it was never successfully configured. Only features from successful installations can be repaired. To continue, remove the specified SQL Server feature.

This error appears if you attempt a repair of a failed installation.  The work around it to manually uninstall the all items related to the instance, and re-attempt the install by addressing the original error.

Error: A MOF syntax error occurred.

Manually uninstall and then re-attempt the install.

Error: SQL Express 2008 ERROR: Failed to generate a user instance of SQL Server and
Error: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed."

Okay, admittedly this error doesn't appear during install, but it is an install related error none the less.

Recently I upgraded my SQL Express 2005 instance (installed by Visual Studio 2008) to SQL Server Express 2008.  (Visual Studio 2008 Express editions will automatically be upgraded when installing Service Pack 1, but not so with all other instances.)  After upgrading, none of my data driven unit tests were successfully passing.  Instead, they were failing with the message:

The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests" in the MSDN Library.
Error details: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed."

It took some sleuthing to determine the solution.  Firstly, I checked the error files located in my %USERPROFILE%\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS (the connecting user's SQL Express data directory) directory.  That indicated errors were in loading the modal.mdf and corresponding log file within afore mentioned directory.  However, when connecting to the SQL Express instance from SQL Server Management Studio, there were no such issues.  This was because the instances connected to by SQL Server Management Studio were in the %PROGRAMFILES%\Microsoft SQL Server directory. 

Generally, when a new MDF file is connected to by SQL Express, it copies the master, model, MSDB, and tempdb databases (mdf and log files) into the connecting user's SQL Express data directory.  (This is frequently why the first time connecting for each user takes longer.)  Such a copy was unnecessary in my case because the databases already existed.  Unfortunately, the databases were from the SQL Server Express 2005 instance, and not the upgraded database from SQL Server 2008 Express.

To correct the problem, I

  1. Shut down SQL Server Express
  2. Deleted the users SQL Express directory "%USERPROFILE%\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS"
  3. Restarted SQL Server Express:

Here's a cmd script for what is needed:

SC.EXE stop "MSSQL$SQLEXPRESS"
CHOICE /C:N /D:N /N /T:5
RD /S /Q "%USERPROFILE%\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS"
SC.EXE start "MSSQL$SQLEXPRESS"

More Errors:

Unfortunately, this is not anything even close to an exhaustive list of errors.  If you have other messages I have not covered, the key place to check is %Programfiles%\Microsoft sql server\100\Setup bootstrap\Log\<DateTime>.  To begin, open the Summary_<computername>_<DateTime>.txt file to see an overview of the results.  If that doesn't help, consider reviewing one of the Detail*.txt files.  These errors are all addressed in KB909967 - How to troubleshoot SQL Server 2008 Setup issues.

Another item that seemed to cause instability in my SQL Server 2008 installation was mounting the SQL Server 2008 iso file (especially mounting it over the network).  I recommend that you extract the ISO into a local directory and then installing from the local directory.

Overwhelmingly, the correction is to manually uninstall the attempted install instance.


Monday, December 08, 2008 8:56:10 PM (Pacific Standard Time, UTC-08:00)  #    Comments [4]  Computer Related | .Net

 Friday, December 05, 2008
MSDN Flash: Keyboard Visual Studio Tips & Tricks for Dec 15. 2008

Originally, I was going to focus on shortcuts for the various build/compilation options within Visual Studio 2008.  However, things become a little more complicated in terms of which keyboard shortcut to use because it depends on your keyboard mapping scheme.  In this edition, therefore, I am going to discuss the Keyboard Options dialog - where different keyboard schemes are available for selection. 

During the first launch of Visual Studio 2008, you are prompted with which keyboard scheme to use.  The typical options are (Default), Visual C# 2005, and Visual Basic 6. Fortunately, you can change your selection via the Tools->Customize... menu and the Keyboard... button on the ensuing dialog (Alt+T, Alt+C, Alt+K). The same dialog is available from Tools->Options... and the Keyboard node of the environment.

image

The first dropdown on the right hand side of the dialog is where you can change your keyboard mapping scheme.  (In this write-up, we will ignore the left hand tree of the dialog except to say the same dialog is used for the rest of Visual Studio's options as well.)  After selecting which scheme you want, push Reset (Alt+E) to have all the keyboard settings for the selected scheme mapped. 

Once you have the scheme you want, type within the Show commands containing text box.  Notice that the commands list automatically filters down to those which contain the value entered anywhere within the name.  In the screen shot above, "build" is used to filter the commands to those that have "build" in them.  There are numerous functions within Visual Studio that do not map to menu options and, therefore, there is no intuitive way to know of their existence except from the Keyboard Options or the Customize... options dialog.  The Show commands containing text box makes finding commands relatively easy, however. Consider, for example, determining the keyboard shortcut for deleting the current line.  In the Show commands containing text box, type "delete" or "line" and then browse through the available commands to discover that such a command exists (Edit.LineDelete) and that by default Ctrl+Shift+L will invoke it.

Within the list of commands, you can select one of the commands and view the shortcut it is mapped to, if any.  Build.BuildSelection is shown here to map to Shift+F6 (Global), where "Global" here means that this keystroke will work regardless of the context within Visual Studio (such as whether the Text Editor or Class Designer windows are active).  It is helpful to browse through the various commands and see what they are mapped to.  Furthermore, if you wish to map a new or different keystroke, you can type it in the Press shortcut keys text box.  What is helpful, is that if the key typed already has a mapping, the existing mapping will show up in the Shortcut currently used by text box, allowing visibility as to whether you want to change the mapping or perhaps select a different keyboard shortcut.

In summary, the Keyboard Options dialog is a great technique within Visual Studio for determining what commands are available, what commands are mapped to which keyboard shortcuts, and for mapping new keyboard shortcuts to the commands.


Friday, December 05, 2008 1:44:03 PM (Pacific Standard Time, UTC-08:00)  #    Comments [1]  Computer Related | .Net

 Monday, November 17, 2008
MSDN Flash: Keyboard Visual Studio Tips & Tricks for Nov 17. 2007

Frequently, while browsing code, we want to drill down into a method to see the implementation and then jump back out again to continue browsing code at the caller. One invaluable keystroke for doing this is F12. Placing your cursor on any identifier, you can use F12 to drill into its declaration. This works both for types as well as their members. In fact, you can use the same keystroke to jump to the definition of types in the .NET Framework. This is a great way to browse through the type's members to see header information, including the documentation of the parameters. To jump back, you can use Ctrl+-. In this way you can navigate back and forth through your code.

image 

 image

image

 image

image 

As quoted from a post by me on MSDN Flash, Nov 17, 2007.


Monday, November 17, 2008 6:49:32 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]  Computer Related | .Net

 Monday, November 03, 2008
Dynamically Typed Objects with C# 4.0

One of the announcements that emerged from the PDC is C# 4.0's support for dynamically typed objects.  These are objects whose type is not determined until runtime.  Variables that point to such types are declared with a new contextual keyword, dynamic.  Support was added so that API calls into dynamically type languages (such as scripting languages) could be supported.  Another example where dynamically typed object support is useful is calling into IDispatch objects (something supported by VB but not C# until now).

In order to investigate how dynamic objects worked I decided to create a working sample that dynamically went against an XML element. Working with Michael Stokesbary, I was able to put together the following sample:

Consider the following XElement:

XElement element = XElement.Parse(
    @"<Person>
             <FirstName>Inigo</FirstName>
             <LastName>Montoya</LastName>
        </Person>");

From here we can assign it to a dynamic variable and read out the data as follows:

dynamic personXml = new DynamicXml(element); 
Console.WriteLine("Hello, my name is {0} {1}", personXml.FirstName, personXml.LastName);

and

personXml.FirstName = "Bob";

As this code shows, with a dynamic type over XML, you can use XML element names as the property names to retrieve data from the XML element.

To implement the DynamicXML type, all you need to do is define an type that implements System.Scripting.Actions.IDynamicObject with its one MetaObject GetMetaObject(Expression parameter) method.  The easier way to do this is to derive from Dynamic, a class that is currently available in the Iron Python implementation.  (In the future, we should expect that Microsoft will provide such a class in the framework but no specific plans on this have been announced.)  Once deriving from Dynamic, the only remaining task is to override the object GetMember(GetMemberAction action) and void SetMember(SetMemberAction action, object value) members.  Rudimentary implementations are shown below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Scripting.Actions;
using System.Xml.Linq;
using System.Xml.XPath;
public class DynamicXml : Dynamic
{
    private XElement Element { get; set; } 

    public DynamicXml(System.Xml.Linq.XElement element)
    {
        Element = element;
    } 

    public override object GetMember(GetMemberAction action)
    {
        object result = null;
        XElement firstDescendant = Element.Descendants(action.Name).FirstOrDefault();
        if (firstDescendant != null)
        {
            if (firstDescendant.Descendants().Count() > 0)
            {
                result = new DynamicXml(firstDescendant);
            }
            else
            {
                result = firstDescendant.Value;
            }
        }
        return result;
    } 

    public override void SetMember(SetMemberAction action, object value)
    {
        XElement firstDescendant = Element.Descendants(action.Name).FirstOrDefault();
        if (firstDescendant != null)
        {
            if(value.GetType() == typeof(XElement))
            {
                firstDescendant.ReplaceWith(value);
            }
            else
            {
                firstDescendant.Value = value.ToString();
            }
        }
        else
        {
            throw new ArgumentException(string.Format("Element name, '{0}', does not exist.", action.Name));
        }
    }
}

That's it... that's all that is needed to understand how to implement a dynamic object.

Caveats:

  • Multiple elements with the same name are not supported in this implementation.  To do so we wanted to use the index operator with the dynamic type but this is not supported in the PDC 2008 CTP bits - it will be.
  • This example does not work with attributes.  What would the syntax be if it did?  One cool idea of Mike's was to use the verbatim identifier as in personXml.@FirstName. - the XPath like way to retrieve attributes. Unfortunately, this wouldn't work work since the @ sign is removed at compile time so the IDynamicObject.GetMember() call receives FirstName for the action Name.
  • There is no support for reading the root element name.  The example assumes you only navigate into the children (to avoid infinite recursion) when navigating.

In the process of writing this dynamic XML implementation, I found a few idiosyncrasies in the current dynamic type support found in the PDC 2008 CTP:

  • There is no type checking for dynamic arguments.  Consider the sample code below:
         string text1 = "Text";
         dynamic text2 = text1;
         Assert.AreEqual<string>(text1, text2);

Not only does the code sample compile (by design), but it throws an exception of type ArgumentNullException (not by design - Mads agree's this probably isn't correct).


Monday, November 03, 2008 11:14:16 PM (Pacific Standard Time, UTC-08:00)  #    Comments [8]  Computer Related | .Net | Headlines

 Tuesday, October 28, 2008
My Favorite Windows 7 Features

I am a pretty tough critique when it comes to Microsoft Software announcements (perhaps because in many cases I hear about what is happening before it goes public).  However, there are some cool Windows 7 features that I am very excited about:

  • Multi-monitor Support including screen orientation, accelerator keys for projection to multiple monitors (mirror/dual), multi-monitor projection support, and multi-monitor support for remote desktop (Wahoo!)
  • Mounting VHDs as a drive or (more amazing) booting from a VHD - Impressive!

1 Disappointment:  Support for mounting ISOs?


Tuesday, October 28, 2008 8:48:34 AM (Pacific Standard Time, UTC-08:00)  #