You are hereProgramming & Web Design

Programming & Web Design

warning: Creating default object from empty value in /home/hagrinad/public_html/modules/taxonomy/ on line 33.

Programming & Web Design

Visual Studio 2010 Conditional Breakpoints with Strings

By hagrin - Posted on 24 December 2011

Here's a really simple tip that isn't exactly readily obvious to novice .Net programmers. You can check out my post on conditional breakpoints in Visual Studio 2005 for a more in-depth explanation as to what a conditional breakpoint is and why you would want to set one.

However, something I didn't cover was "what if I want to have a conditional breakpoint when a string variable is a certain value?". Seems simple enough but if you try something like strVariable = "something" or strVariable == "something", neither will work. So exactly how do you evaluate a string in a conditional breakpoint?

Simply do strVariable.Equals("something"). Intellisense even works!

Happy debugging!

Fixing the HTTP 500.21 Error - "Handler "PHP53_via_FastCGI" has a bad module "FastCgiModule" in its module list"

By hagrin - Posted on 10 November 2011

Recently, I have been working on several projects that I had only brainstormed for a few months and now it was time to actually start developing. One of those projects called for me to setup a new Windows 7 desktop to use PHP on IIS. After installing PHP through the "newish" Web Platform Installer from Microsoft, I tried browsing my PHP site and received a HTTP 500.21 error in my browser - "Handler "PHP53_via_FastCGI" has a bad module "FastCgiModule" in its module list".

Luckily for me, this is a very easy fix. Just follow these steps -

  1. Open up your Control Panel and go to the Programs section and choose "Turn Windows features on or off".
  2. Under Internet Information Services, select World Wide Web Services, then Application Development Features and check the box for CGI.
  3. Click OK and install.
  4. Load up your PHP webpage!

It's that easy! Good luck to everyone with their Windows based PHP development.

SharePoint 2007 / WSS 3.0 - Fixing the "Unable to Add Selected Web Part" ... "The File is Currently Checked Out" Error

By hagrin - Posted on 17 June 2011

Yesterday, I had to post a YouTube video to our SharePoint WSS 3.0 intranet site. If you're not familiar with embedding a YouTube post into a SharePoint page, your best bet is to use the Content Editor Web Part. However, when I went to add the CEWP today, I was receiving the following error -

Unable to add selected web part(s). Content Editor Web Part: The file is currently checked out or locked for editing by another user.

Huh? Before that, I also noticed that when I was trying to add the CEWP web part to our home page, I was able to see the content, yet no other user was able to see the same content.

If you're struggling with this error, you'r in luck because the fix is simple. Just open up SharePoint Designer, navigate to the page that is giving you the error, right click on the page and select "Undo Check Out". That's it - once you do that, try to add the CEWP and it should work. Hope this helps!

C#.Net - Get Remote Computer Uptime

By hagrin - Posted on 15 June 2011

Recently, at one of my jobs, the company's virtual servers were experiencing random, unnoticed reboots that would occur so quickly that their monitoring software, ManageEngine's OpManager (which does an extremely pitiful job at reporting correct uptimes by the way), wouldn't even send out a down alert. Admins were only being notified when they logged onto the box and actually saw a reboot reason message box.

Therefore, to supplement OpManager, we wanted a script/page that gave an overview of all the servers and their uptimes/last reboot. I came up with the following code which will query on a single machine -

using System.Management;


ManagementScope scope = new ManagementScope("\\\\COMPUTERNAME\\root\\cimv2");
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
// Display the remote computer information
// - list of available attributes
Console.WriteLine("Uptime : {0}", m["LastBootUpTime"]);
Console.WriteLine("Computer Name : {0}", m["csname"]);

You can easily put the machines you want to query in a database or an array and run this code through a loop to query the uptimes of all your machines in an organization. You can also clean up the formatting of the LastBootUptime to be more readable, but that's up to the developer.

Hope this code snippet helps someone manage their networks.

SQL Reporting Services: Fixing the "No Letter Spacing" When Printing Problem

By hagrin - Posted on 07 June 2011

Seemingly out of nowhere, my users were complaining that while their SQL Reporting Services (SSRS) reports were displaying fine on screen once they printed them the font was all screwed up and possibly stretched horizontally. The font looked stretched and there was no spacing between the letters of a word. It happened on all machines using all printers to all users. It broke in a 3 hour window where no patching, reboots or changes were really made.

Our environment consists of -

  • SQL Server 2008 Standard Edition with SP2 64-bit
  • Windows Server 2008 64-bit
  • SQL Server Reporting Services
  • Virtualized using VMWare

After looking at program settings, print queues, etc., a very random internet search provided me with the starting blocks to how to fix this problem. It seems that the problem occurs when after the SQL Server is rebooted, the first person who logs in (usually via Remote Desktop) logs in with a session in 16:9 aspect ratio (widescreen). Weird right?

To fix this problem, you must do the following in this order -

  • Reboot the SQL Server
  • After the SQL Server has finished rebooting, Remote Desktop into the server using the following command - mstsc /v:SERVERNAME /admin /w:1024 /h:768 (this forces the needed 4:3 aspect ratio)
  • Now, try running your reports.

As a side note, just restarting the services did not fix this problem - a reboot was required. Hopefully, this helps some people and people are able to find this post (it was difficult to title this post to make it as helpful as possible). Good luck!

How To: Fix Visual Studio 2008 Design View Hang / Not Working

By hagrin - Posted on 31 May 2010

Recently, I had to do some home .Net development (I mainly do .Net work only at ... work), but when I had some Internet issues and had to work offline, I loaded up my copy of Visual Studio 2008. I opened up my web project and everything seemed to be working fine until I tried to switch to design view on any page or control. Once I tried going to Design View, Visual Studio would stop responding and only a forced quit would close the application. Here's the environmental settings I was working with -

  • Windows Vista Ultimate 64-bit Edition
  • Visual Studio 2008 Service Pack 1
  • Microsoft Office 2010 64-bit

Nothing out of the ordinary as you could see. Obviously, whenever I run into a problem like this, I load up a search engine and search for a solution and found quite a few complaints about this problem. However, after reading the "de facto" solution post from Microsoft, I felt as if I needed to more accurately spell out how to fix this problem since I only found the correct solution after reading through several posts.

  1. Close Visual Studio.
  2. Open up your Control Panel.
  3. Go to your installed Programs and Features.
  4. Look for an entry called Microsoft Visual Studio Web Authoring Component.
  5. Right click on this entry.
  6. Choose Change.
  7. Select the option to Repair.
  8. Re-open Visual Studio and try using design view in your web application.

Obviously, if you don't have this program, you need to install it. Fixing this problem, for me, was really that simple while other posts talked about editing your registry key for Office LastProduct, making sure you had Visual Studio SP1 installed, etc. However, I found that this was the easiest solution that worked for me.

Fixing the "The components for the 64-bit debugger are not registered" Error

By hagrin - Posted on 05 January 2010

Recently, on my new 64-bit home development machine, I fired up Visual Studio 2008 for the first time in a while and decided to start cranking out C# solutions to the Project Euler questions. Since I have already completed 14 questions about a year ago, I was able to code a solution to Question #1 very quickly. I decided to debug the solution and ... wham. I received the following error -

Error while trying to run project: Unable to start debugging.

The components for the 64-bit debugger are not registered. Please repair your Visual Studio 2008 Remote Debugger installation via 'Add or Remove Programs' in Control Panel.

To resolve this issue, you will need your Visual Studio 2008 installation disk. On this disk, you will find the following path -

..\Remote Debugger\x64

Inside this folder should be an executable called "rdbgsetup.exe". Run this EXE, open up Visual Studio and you will now be able to remotely debug your projects.

Exception from HRESULT: 0x800A03EC - Excel, .Net, SQL and Windows Server 2008

By hagrin - Posted on 16 March 2009

For the last 5 days, I have been encountering an error when trying to automate the creation of an Excel document through a scheduled SQL Server job. The error I was receiving was -

Exception from HRESULT: 0x800A03EC

Let's take a step back. The same code I had written worked on my development machine, worked on other target servers while scheduled as SQL jobs, but the code would not work on the following target server -

  • Windows Server 2008 Standard
  • 64-bit platform
  • SQL Server 2005
  • Excel/Office 2007 Professional

After adding some StackTrace code to my program, I was able to determine that the EXE was failing on the Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs line. After trying multiple iterations of the SaveAs command (a quick Google search provided some potential solutions), I continued to get the same 0x800A03EC error code. I went down the road of thinking it was a problem with my 32-bit development environment and had our Sysadmin build me a 64-bit virtual machine for me to compile my application; however, this also yielded the same error. I made sure that the Excel assemblies on the development environment and the target machine were the same version. On the target server, I went to dcomcnfg, selected the Microsoft Excel Application entry and made sure it was using the "interactive user" and still no luck. I made sure that, for testing only, all the SQL services ran under my domain admin account to account for SQL security differences and still nothing.

At this point I decided that I was spinning my wheels and I would call Microsoft and use one of my MSDN support cases.

After speaking to several departments, I finally reached the Office department who tried to help. After explaining my issue quite a few times over and over, I finally got the response I had dreaded - it can't be done that way. Ugh. I had feared I would get this response after reading that using Open XML to create Office documents was the recommended approach and that using the Office COM references was no longer supported (if it ever was) and Windows 2008 has additional security that prevents the old approach from working properly. Well, I guess that explains why it wasn't working.

So where do I go from here? Even though Microsoft support couldn't provide me with sample code or a link to some code, I was able to find this knowledge base article detailing how to to create Excel files using Open XML. Hopefully, this approach will work on my target server environment.

Adding a Link to a SharePoint Document Library

By hagrin - Posted on 03 March 2009

Updated - 13 November 2009 - I have updated this post to improve on the JavaScript listed below so that the Back Button works properly.

Recently, a client wondered how they could add an external document to a document library that existed on their Intranet. The problem with just saving their document and uploading it to the Intranet is a matter of document "freshness" as changes are made by the document owner. Therefore, creating an external link to that document is a much better solution. However, adding a link to a document library would seem difficult on its face.

To get around this issue, I took the following steps -

1. Create a TXT file.
2. Open the TXT file and add the following HTML -

<title>External Link</title>
<script type="text/javascript">

3. Save the file as a HTML file.
4. Upload to your Document Library.

You now have a working JavaScript redirection to the external document in your document library. Also, you can click the Back Button in your browser and you will return back to your Document Library.

How To: Fix "The report server database is an invalid version" Error

By hagrin - Posted on 04 August 2008

Recently, I decided to go through my work computer's event log to see if I was racking up any errors and found one error repeated quite frequently -

Source: Report Server Windows
Event ID: 117
Description: The report server database is an invalid version.

Now, I have Microsoft's SQL Server 2005 installed on my work machine for development purposes and the error seems to be directly related to the Reporting Services functionality. After looking at the help for this error in the Help files, Microsoft's web site and even a few search engine searches, I couldn't find the full answer anywhere. However, I finally fixed the error and here's how to do it.
Reporting Services Configuration Manager

  1. Open up the "Reporting Services Configuration Manager" by going to Start -> Programs ->Microsoft SQL Server 2005 -> Configuration Tools -> Reporting Services Configuration.
  2. On the left hand side, click on "Database Setup". (there should be a red "x" to the left of Database Setup.
  3. Choose the appropriate Server Name.
  4. For the Database Name, click "New" and do not use the default name "ReportServer" since it's possible a .MDF file was already created with this name. I used "ReportServer2".
  5. Make sure to choose the "Credentials Type" and enter the account information for a user who has create database permissions.
  6. Click "Upgrade". Make sure you get all green check marks (even a warning message means the process probably didn't complete properly).
  7. Click "Apply" at the bottom.

You should now be good to go and no longer receive this error in your Event Log.