Wednesday, April 11, 2012

Get Started Using NuGet on Visual Studio 2010

You’ve been hearing things about NuGet, but aren’t sure where it is our how to use it. This is a basic instruction on how to get started.

Why NuGet? Developer Productivity. It makes it easier to do things like add Asp.Net Ajax or other libraries and utilities to your project without constantly searching the web for the download and installation process. It is great for items you add to your solutions regularly, but don’t always remember the steps because it has been a while since the last time.

NuGet

  1. Go to NuGet.org to download and install NuGet, a Visual Studio extension that makes it easier to download and install third party libraries in a Visual Studio project.
  2. Restart Visual Studio, if you had it open.
  3. Open the project you want to add the utility or library to.
  4. Click “Manage NuGet Packages” under the Visual Studio 2010 “Project” menu. image
  5. Search for a utility you are interested in, such as “AjaxControlToolkit”, “Modernizr”, or “MvcScaffolding”.
  6. Click the “Install” button.

Wednesday, March 28, 2012

Uninstalling a Failed SQL Server 2008 Installation

frustrationLast night at a SQL Server User Group meeting, one of the attendees was describing the trouble he was having uninstalling a failed SQL Server installation. There was some kind of problem that caused it to fail on the database engine installation. That sounded exactly like a problem I had installing SQL Server 2008R2 as a named instance alongside SQL Server 2005 just a few weeks before.

My installation was failing because I was attempting to install SQL Server 2008 (not R2) from an actual Microsoft DVD (most of the time I am installing from an MSDN iso download). After much of the installation was complete, a dialog popped up prompted for media containing a path to a SQL Server 2008 R2 executable. I wasn’t trying to install R2, so I’m not sure why the prompt. I ignored the prompt and continued the installation which failed (no surprise there). After the error, I decided I would just uninstall the non-R2 instance and install SQL Server 2008 R2, but the uninstall wizard would not work.

For posterity sake, the blog post that I used to uninstall the failed installation was Fun with software : uninstalling SQL Server 2008 R2 Evaluation Edition by Aaron Bertrand. The article is about uninstalling an eval edition, but it worked for me on an RTM or SP1 copy.

 

photo credit: peterhess / CC BY 2.0

Tuesday, February 28, 2012

Hyper-V Lab Experiment; Attack of the Snapshots

DeLorean time machineThis is a brief chronicle of the effect of re-creating a Virtual Machine from a Virtual Hard Drive that had Snapshots taken and not merged back into the parent image.

Background

In August 2010, I created a Hyper-V lab with a Windows 7 development VM and a Server 2008R2 testing VM. The VM hard disks, virtual machines, and snapshots were stored on the SATA hard disk. The Hyper-V Server 2008R2 host was installed on a bootable USB pen drive.

Apparently around November 2010 and over the course of 2011 I created a few snapshots of the Windows 7 VM.

Fast forward to a couple weeks ago

My Hyper-V environment lost power and when it restarted the BIOS failed to recognize the Kingston USB pen drive that Hyper-V was booting from. Result: My lab was down. This happened one other time, but after some fiddling with the BIOS, I  was able to get the USB drive to be recognized.

In order to prevent this from happening in the future, I replaced the USB pen drive by installing Hyper-V Server 2008R2 on an IDE drive, plugged it into my lab box and booted. I created a new Virtual Machine using the existing Window 7 Virtual Hard Drive and powered up my development VM. Upon a quick glance everything looked fine.

Missing Files and Programs

A few days later while logged into my Dev VM, I noticed several of my files and directories were missing, Microsoft Office wasn’t installed, and SQL Server said the trial had expired. What?!?

A quick check of the Windows Event log and there was an entry that Windows was not shut down properly on November 11, 2010, but was back up and running on Feb 12, 2012. Suddenly I was missing over a year of development activity; not really. 

Don’t Panic!

November 11, 2010 was the date the first snapshot was taken. All the activity since then was in the snapshot differencing disks (3 files with a .AVHD extension).

I had a Windows Image Backup and regular full backups, but instead of restoring from backup, I decided to have a little fun with the Hyper-V management console instead.

A little research and I found this article about merging differencing disks. It isn’t the best reference you can find because it doesn’t have screenshots of the process like this one. I actually backed up the parent VHD and child AVHD files and renamed the AVHD files VHD, but it appears the renaming process is unnecessary. Otherwise after using the Hyper-V management console to merge each of the AVHD files to their parent drives, I powered up the dev VM after merging and everything was back to the state prior to the initial power outage. Success!

Moral of the Story

If you use a Hyper-V snapshot to test a Windows Update or some other configuration change that you want to be able to roll back out of, make sure to merge the snapshot back into the VM. Don’t leave it in a snapshotted state. Especially not with multiple active snapshots.

Reference: Hyper-V: Avoid using differencing disks on virtual machines that run server workloads in a production environment.

photo credit: pnoeric / CC BY-SA 2.0

Thursday, February 16, 2012

Error 2337 Installing SQL Server 2008R2 in Virtual PC 2007

Issue

Last year I was preparing for an fwPASS presentation on Report Viewer 3.0 by installing SQL Server 2008R2 in a virtual machine using Virtual PC 2007. I kept getting an error 2337 indicating that the disk may have been corrupt or damaged. I was installing it from a .iso image I downloaded from my MSDN Ultimate subscription. I used the Virtual PC “capture iso image” functionality to mount the iso as a disk. I downloaded another copy of the iso image and repeated the process with the same results. Due to time constraints, I reverted back to SQL Server 2005 and Report Viewer 2.0 for that presentation, highlighting features new to 3.0 using screenshots.

Physical and Hyper-V Success

Since then I have successfully installed SQL Server 2008R2 successfully multiple times on bare metal physical servers and in VM’s using Hyper-V Server 2008.

VPC Still an Issue

Fast forward to this week. I was setting up a development sandbox in a VM. Again I was installing SS2008R2 by mounting the image in VPC 2007 and was faced with the same Error 2337. Seriously? This issue hasn’t been resolved yet? A quick search on the error resulted in this helpful post Getting error 2337 installing SQL Server on a VPC on the SQL Skills blog.

Solution

I didn’t have any blank DVD’s on hand for burning the image, so I decided I would use MagicDisc to mount the iso file on my host machine, instead of using VPC’s capture iso functionality. That solved the problem.

Tuesday, November 22, 2011

Troubleshooting Relative URI’s in Silverlight Projects

My Visual Studio Solution contains a minimum of a project for the Silverlight application and a project for the web page that hosts the Silverlight application. The Silverlight application reads and rights files to the local file system.

The solution is structured similar to this:

mySolution (has a minimum of the following two projects)

  • MyApplication.Web - the project that hosts the Silverlight xap file (could be a simple index.html page and Silverlight.js javascript page)
  • MyApplication - the Silverlight application project

When debugging in Visual Studio, the files that the Silverlight application is trying to read from are not necessarily available to the application depending on how you structure the application and which project you put the data files into initially.

While under development, intuition may lead you to believe that if it is the Silverlight application that is actually reading the files, the Data folder should be placed in the Silverlight application project root, not the web project. That would be incorrect.

Example 1

new Uri("/Data/ReadThisFile.xml", UriKind.Relative)

UriKind.Relative with a leading slash (/) in front of the Data folder is relative to the page that is hosting the XAP file. In my solution this is the project root of the web application, not the Silverlight project. The data file would be located at f:\mySolution\myApplication.Web\Data\ReadThisFile.xml


Example 2



new Uri("Data/ReadThisFile.xml", UriKind.Relative)
Without the leading slash in front of the Data folder as in this example, the file is expected to be relative to the Silverlight xap file. In my solution the xap file is in the default location, the ClientBin folder, which is a sub folder of the project root of the web application. The data file in this case would be located at f:\mySolution\myApplication.Web\ClientBin\Data\ReadThisFile.xml


Troubleshooting with Process Monitor


If you are getting File not found exceptions, the file isn’t where your application thought it was supposed to be. A relatively easy way to find out where the application is looking for the file is to use SysInternals Process Monitor.


Once you install and run the Process Monitor, you can set the filters to narrow down the captured events to locate the path to the file. The primary filters I used were “Result is not SUCCESS” and “Path contains ReadThisFile.xml”


 image


The filtered results would look similar to the following, if the the application throws a File not found type of error. (click to enlarge)


image

Monday, November 21, 2011

Could not load file or assembly System.IdentityModel

I added functionality to a Silverlight application I created several months ago and when I attempted to run it in debug mode, I received this error:

Could not load file or assembly 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.

I found very little evidence of why I was getting this error now. My search results did not turn up much useful information either. I did find this link on Stack Overflow, so on a whim I revised the web.config of the web project that hosts the Silverlight application to a add a clear statement to the assemblies node.

<configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.0" >
        <assemblies>
          <clear/>
        </assemblies>
      </compilation>
    </system.web>
</configuration>

After making that change, the assembly loads without errors. This was on my development workstation. The application did not throw any errors on the production server after publishing it without the clear statement in the web.config.

Wednesday, October 26, 2011

10 Reasons to Join a PASS or .Net User Group

user groupI am a member and leader at multiple chapters of technology-based international professional associations, like PASS (Professional Association for SQL Server) and INETA. Through that affiliation, I have experienced many, many benefits that such a small percentage of our industry takes advantage of.

  1. Great people – Attendees, speakers, organizers, volunteers, sponsors, and venue hosts. Attend regularly and I promise you will make life long friends.
  2. A place to talk shop with peers, learn about other organizations and practices, scope out job opportunities, help others with their challenges, and mentor people new to the field.
  3. Great content – free training, new technology previews, and deep dives into specific topics.
  4. Access to experts – speakers almost always provide their contact info and give you permission to ask questions outside of the presentation. Get help on your challenges from other attendees during the social networking time. Sometimes you even get to meet Industry celebrities and national conference presenters, such as Brent Ozar, Brad McGehee, and Scott Guthrie.
  5. Food and beverage
  6. Free swag – books, software (Development software, Operating Systems, 3rd party tools, Xbox games, and more), hardware (keyboards, mice, web cams, etc.), training vouchers, discount coupons, quirky and unusual items (such as Bucky Balls),  travel mugs, tote bags, back packs, and the list goes on.
  7. News and announcements about other events and happenings in the industry – training conferences like the PASS Summit and SQL Cruise, all day training opportunities, such as Day of .Net, Codemash, SQL Saturday, virtual training events, contests, free eBooks promotions, Job opportunities.
  8. Save money travelling to regional training or events by carpooling with your fellow user group friends.
  9. Opportunities to present – show off your own proficiency in your craft, get experience to prepare you to speak on regional or national level, establish credibility as a teacher/communicator.
  10. Opportunities to be a board member or volunteer to hone your leadership and logistical skills enhances your career marketability. Also, volunteering or leading a local chapter or regional event is great way to prepare you to become a board member on a national scale, if that is of interest to you.

Really there are few reasons not to attend, join, volunteer, or lead a professional organization. If you’re interested in professional organizations in general, read my popular post about 10 reasons to join a professional association.

What have I missed?