Archive for March, 2012

Error: Task failed because “sgen.exe” was not found

I was happily building my project when up popped this message:

Task failed because “sgen.exe” was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for “sgen.exe” in the “bin” subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A. You may be able to solve the problem by doing one of the following:  1) Install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5.  2) Install Visual Studio 2008.  3) Manually set the above registry key to the correct location.  4) Pass the correct location into the “ToolPath” parameter of the task.

I knew why I got it. Earlier in the day, I Had moved the files from the C:\Program Files\Microsoft SDKs\Windows folder to my D: drive to get rid of some pesky “you’re running out of space” messages.

So I opened RegEdit and changed the “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A” key to the right path and then rebuilt.

Same error.

The solution was easy. I just closed Visual Studio 2008 and reopened it, and my next rebuild worked.


Leave a comment

Determine the number of users on your web site

It is the eternal question: How many users are connected to my IIS web site? A little poking, and I found that I could answer that question Performance Monitor.

First, click on the Add button (the “+” sign, highlighted in green). That will display the “Add Counters” window.

Performance Monitor

Performance Monitor

From the “Performance object” drop down list, select “Web Service”. This will change the list of counters on the list on the lower left. Select “Current Anonymous Users” and / or “Current NonAnonymous Users”, depending on what you want to track.
If you highlight the counter you wish to track. Look at the “Last” to see the latest count.

Performance Monitor

Performance Monitor

I’m certainly open to better ways of doing it, but it worked for me.

Leave a comment

Removing duplicate entries from a string

I had a string whose chances of having duplicate items was rather high. But, I needed to reduce that change to zero. I came across Ali Raza’s site, and he had a solution for VB.NET. It uses an ArrayList, and my preferred weapon of choice is a List. My question was how to join items in the List into one big string. I came across dotnetperls for that piece of the puzzle, and here is the final bunch:

// existingIds is semicolon-delimited string
string[] list = existingIds.Split(';');
List<string> duplicates = new List<string>() { };
for (int i = 0; i < list.Length; i++)
     if (!duplicates.Contains(list[i]))
Session["RecentDocs"] = string.Join(";", duplicates.ToArray());

Leave a comment