Cisco VPN Client and Windows 8

I upgraded to Windows 8 (from Windows 7) several months ago and one of the things that stopped working is the Cisco VPN client. As of this writing, the most recent version is 5.0.07.0440. This build installs properly but fails when you try to establish a connection. I found a solution wanted to share it since it’s been working great for over 3 months without an issue.

1) Close the VPN client, make sure it’s not running.
2) Open up regedit and navigate to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CVirtA
3) Make a backup of this, just in case. Right click the CVirtA key in the explorer and export the settings for this key as a reg file.
4) Edit the DisplayName value, stripping off the characters until “%;”. For example…
For x64 you can change the value from something like “@oem8.inf,%CVirtA_Desc%;Cisco Systems VPN Adapter for 64-bit Windows” to “Cisco Systems VPN Adapter for 64-bit Windows”. For x86, you’ll change the value from something like “@oem8.inf,%CVirtA_Desc%;Cisco Systems VPN Adapter” to “Cisco Systems VPN Adapter”.
5) Open the VPN client and try connecting again
6) If this doesn’t work, restore your original settings by double clicking the reg file you saved in step 3.

Special thanks to Raman-MSFT from this MSDN post for this solution!

Samsung PM830 SSD not recognized by SSD Magician

I bought a Dell XPS 13 Ultrabook in March with a 256GB SSD drive and I love this machine. The drive inside is a Samsung PM830 and it boots Windows 8 from scratch in less than 7 seconds (cold boot, this is not resuming sleep).

As a techie, I like maintaining my system and keeping it in order. Part of that involves making sure your disk performance is good. Everybody knows you aren’t supposed to defrag SSDs because it eats into the limited number of writes an SSD can make and also it won’t increase performance. SSDs don’t have moving parts; having the file operations sequential doesn’t seem to make a difference. I talked with my friend Bill and he mentioned a command called TRIM and recommended looking at the Samsung SSD utility which is called Samsung SSD Magician.

First thing I did was pull up a command prompt and see if I have TRIM enabled (starting with Windows 7, it should be enabled by default if you’re using an SSD). Here’s how you can check (NOTE: you’ll need to open the command line with admin privileges for these to work).
fsutil behavior query disabledeletenotify

Here’s how to interpret what that command outputs (taken from the fsutil documentation):

DisableDeleteNotify = 0 means Windows WILL send the TRIM command to the SSD when a file is deleted.
DisableDeleteNotify = 1 means Windows WILL NOT send the TRIM command to the SSD when a file is deleted.

On my machine, TRIM is enabled which is great. If it wasn’t and I wanted to enable it, here’s how you’d do that:
fsutil behavior set disabledeletenotify 0

NOTE: If you wanted to disable it, you’d provide a 1 instead of a 0. I’d like credit this information to a post I found on the Corsair Product Forums.

From what I understand, TRIM increases write performance by enabling notifications (sent by the OS) that occur when files get deleted. Click here to read more about TRIM. Next, I went to the Samsung website and tried to download their utility. The website makes you provide a model number before you can download anything. I have no idea how to find this number; I’m guessing you’d have to physically look at the drive. After some searching, my best guess at the model number is MZ-7PC256B.

I downloaded and installed the SSD Magician program, which wouldn’t install properly in Windows 8. Not a problem- you can use compatibility mode and run it as Windows 7. That will let you complete the install and get the program up and running. When I launched the program up, it started to scan the drives. All of the sudden, I get a message box:
“No Samsung Brand SSD found in the system”

The utility still spits out a lot of information about the drive, it just won’t let you do anything (like performance optimizations, etc). Using the tool, I was able to find the firmware version for the drive (which surprised me, since I hadn’t thought about drives having firmware). The firmware version I have installed is:
CXM12D1Q

After some research, I’ve come to the conclusion that you can’t use this tool on an SSD that came pre-installed on a Dell. Other people investigating have hinted at Samsung providing a very similar version of the drive with a custom firmware, so that Dell can control upgrades to it’s firmware. Unfortunately by doing that, they also made the SSD Magician tool not recognize the drive. At that point, I gave up and uninstalled it.

Click here for information I’d recommend reading through if you’re frustrated like me (NOTE: the link is to a conversation that is several pages long, be sure to read through it all). In this post, somebody may have an inside connection to Dell and provides a link to a new version of firmware. This will let you flash from CXM12D1Q to CXM03D1T. The other users (rightly so) are skeptical about it, but the person does claim it increases performance slightly. I’d personally recommend NOT doing this upgrade, but feel free to roll the dice and try it out.

Executing commands when starting cmd.exe

If you use the command prompt in Windows often, you might find it useful to setup a script to fire when it’s opened. Something similar to a bashrc file getting executed in Linux when you login. You can setup something like this using the registry.

Crack open regedit and navigate to:
HKEY_CURRENT_USER\Software\Microsoft\Command Processor

Once here, you can add a value called AutoRun and provide the path to the script to run. For example, if you want to run C:\myScript.bat when the prompt is open, you’d create a new string value called AutoRun with a value of C:\myScript.bat

Click here for more information about cmd.exe

Windows Phone

Not long after I wrote my last article about Tablet Computing, a really good Black Friday deal came up at the Microsoft Store. I headed over there and got two HTC Radar phones for free, both loaded with the Windows Phone 7.5 (Mango) software. I had to cancel Verizon and switch to T-Mobile, but it was well worth it.

I can’t describe how great this phone is. It’s really changed the way I use computers; I end up using them a lot less. All the small tasks I would usually have to plop down in front of a PC to do can quickly be done from the phone. Facebook, emails, checking stocks, looking at website analytics. It has a great web browser and there are a decent amount of applications for it (including games).

I love how Windows Phone links together all of the information about your contacts. I can pull up someone and link all their info together by several accounts, like their Facebook, LinkedIn, Twitter, Outlook, and then their Windows Live ID. The phone will fill in the contact’s picture automatically and then aggregate all of that person’s information on one screen. When you pull them up, you can see all their latest status updates (regardless of the network).

When I signed up for the phone, it came with two $25 dollar gift cards (one for each phone) that were good for the Microsoft Marketplace. I filled in the paperwork required for that and forgot about it. About two weeks later, my mailbox was stuffed with envelopes from Windows Phone. They must have messed up and I ended up getting $150 worth of gift cards! I’ve used this chance to buy a lot of different games and applications and see what there is out there to offer.

I personally think that Microsoft nailed it with this phone. To me, it seems like it’s just a matter of time before people eventually switch over to this (whether that happens or not is up for debate). If you read my blog, you might remember my “I hate cell phones” rant and you’d be glad to know that, as part of the switch from piece of crap feature phone to smart phone, I’ve also made sure to keep my etiquette. I don’t bust the phone out in meetings or while I’m talking to people.

Editing your PHP settings with Go Daddy Web Hosting

I have a Windows Web Hosting account through Go Daddy and I recently installed the Coppermine image gallery program using Go Daddy Hosting Connection. When I started to upload pictures, the Coppermine program was running out of memory while doing batch adds. This meant it wouldn’t create thumbnails and ultimately wouldn’t add my pictures.

Since Coppermine uses PHP, we need to increase the memory usage allowed. To do this, we need to edit the php.ini file. This file contains all the settings that Go Daddy web servers will consider when running PHP for your account. Please note, the below procedure is for Windows with PHP 5; if you have another installation, please see this article.

First, let’s output the php.ini file. Here’s a sample script you can create and put your root directory. Name the file test.php and upload it to your FTP root.
<? system("type c:\\cgi\\php5\\php.ini"); ?>

Execute that script by loading it up in your web browser. It should now output the full php.ini that Go Daddy uses by default. Save that to disk and open it up in your favorite text editor.

In that file, search for “Resource Limits” and you’ll find a section like this:
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 30 ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing ...
max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 32M ; Maximum amount of memory a script may consume (128MB)

I just had to bump up my memory_limit from 32M to 64M. After you make that change, save the file as “php5.ini” and upload it to your FTP root.

That did the trick and I was able to upload pictures no problem. If you do all of the above and it doesn’t work, try logging into your HCC and recycling your application pool.

Taking a screenshot using XNA 4.0 and C#

I’ve been working a lot on an old game that a few friends and I made in college. We ported it to C# using the XNA framework and it’s working great! You can read more about that project by clicking here.

The old code was C++ with OpenGL. One of the functions I had a hard time porting was taking a screenshot. Older versions of XNA seemed to have a way to do it, but the newest version, 4.0, didn’t have an easy way to do it. Here’s what I ended up doing:
public void ScreenShot(string prefix) {
    #if WINDOWS
    int w = GraphicsDevice.PresentationParameters.BackBufferWidth;
    int h = GraphicsDevice.PresentationParameters.BackBufferHeight;

    //force a frame to be drawn (otherwise back buffer is empty)
    Draw(new GameTime());

    //pull the picture from the buffer
    int[] backBuffer = new int[w * h];
    GraphicsDevice.GetBackBufferData(backBuffer);

    //copy into a texture
    Texture2D texture = new Texture2D(GraphicsDevice, w, h, false, GraphicsDevice.PresentationParameters.BackBufferFormat);
    texture.SetData(backBuffer);

    //save to disk
    Stream stream = File.OpenWrite(prefix + "_" + Guid.NewGuid().ToString() + ".png");
    texture.SaveAsPng(stream, w, h);
    stream.Close();

    #elif XBOX
    throw new NotSupportedException();
    #endif
}

Here’s an article you can check out that explains the new behavior:
http://blogs.msdn.com/b/shawnhar/archive/2010/03/30/resolvebackbuffer-and-resolvetexture2d-in-xna-game-studio-4-0.aspx

ASP.NET resources

I haven’t done a lot of .NET since back in the good old 2.0 days.

The jobs I held right after graduating from college were extremely heavy on .NET and MS SQL technologies. I joined Intel in 2005, about a year before the .NET 3 framework was released (with the WCF, WWF, WPF, etc). At Intel I mostly worked with COM technologies; C++ and VBScript. I got to do some .NET development, but it was pretty limited.

I joined Go Daddy in 2008 where I mostly did C++ and PHP on Linux. I really enjoyed it but when I got the chance to switch teams at the end of 2010, I was really excited. All of the code for my new team is in C#/.NET. Since then, I’ve been digging in and figuring out all the new features I’ve missed out on.

I found a lot of great resources when I was looking at all the new features of .NET 4.
Click here for a blog entry with a TON of info about .NET 4
Click here for an article which summarizes the new .NET 4 Base Class Library
Click here for an article about new releases, including the ASP.NET MVC 3 framework
Click here to check out a Search Engine Optimization tool

Of all those links above, the one I’d recommend the most is the last one (the Search Engine Optimization tool). This tool is awesome. You enter the landing page URL and it’ll crawl and download your entire site. After it’s done that, It’ll examine what was downloaded for issues.

It breaks problems it finds into categories. For example, it’ll find any pages you forgot to put a title or description. It’ll also help find broken links.

Most of what the tool does is what’s described in the Google document I linked to in a previous article about optimizing your website (It had a couple tips about getting started; like using Google Analytics and different kinds of webmaster tools).
Click here to check out my previous article about optimizing your website

However, having the tool readily available (which takes about 30 seconds or less to run against my website) is great. It saves everything it finds so you can run it multiple times and visibly see the progress you’re making. No matter how good a job you do, you’re going to miss something (and this’ll help you find it).

I recently upgraded to .NET 4 on my Go Daddy account and I’ve really been liking it.
Click here to read about my .NET 4 migration experience

One of the features I am starting to fall in love with (which I hated when it first came out) is LINQ. This is such a great query language. My favorite part so far is dealing with XML using LINQ. My co-worker showed me this sweet tool called LINQPad. It has a lot of great LINQ examples and works similar to Query Analyzer for MS SQL.
Click here to check out LINQPad

That’s all for now, time to get some sleep!

Getting the assembly version in ASP.NET

I typically update the .NET assembly for this website by hand whenever I have a new major release and I’d like to be able to get the version.

Unlike a Windows Forms application, there is no Application.ProductVersion. I Googled for answers and it looked like I needed to do this:
using System.Reflection;
string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

However, that causes a SecurityException to be thrown. I’m running my website at Go Daddy in a shared hosting environment and the permissions are limited.

Here’s how I solved the problem:
using System.Reflection;
Type t = typeof(*pick any class that's in the assembly you want the version of*);
AssemblyName an = new AssemblyName(Assembly.GetAssembly(t).FullName);
string version = an.Version.ToString();

Some examples that I found use Assembly.GetExecutingAssembly(), but I found that this doesn’t work. It’ll compile, but always returns back 0.0.0.0 as the version. That’s why you’ll have to use Assembly.GetAssembly() and provide a type as shown above.

Upgrading your Go Daddy account to .NET 4.0

Right now this website is written in .NET and I’ve only recently decided to try to upgrade it. About 6 months ago, I did an upgrade which brought me from IIS 6 to IIS 7. I had to migrate my database to SQL Server 2005 to accommodate the upgrade but it worked. Behind the scenes, Go Daddy migrates your account to another box which is running Windows Server 2008 and IIS 7.

Now that I’m on IIS 7, I’d like to upgrade my .NET support to .NET 4.0. I recently bought a great book called C# 4.0 in a Nutshell: The Definitive Reference and after skimming through it, I’d like to start using some of the new .NET 4 features.

Go Daddy has full support for .NET framework 4, but only if it’s a Grid account. The Grid technology basically scales your website by copying the virtual directory content to other boxes and providing load balancing. It’s free to upgrade to a grid account, so here’s how you do it!

Sign into your Go Daddy account. In the “My Account” screen, pull up “Web Hosting” under your products. It should look like this:

In the above picture, you’ll notice I highlighted my account with a red box. Click that hyperlink (the part that has the box around it). It’ll bring up some billing options.

Once you click, it’ll pull up billing options that look like the above picture. Once that comes up, go to the “Edit Account Details” tab. Under the plan drop down, you’ll be able to change your account to a Grid account. Non-grid accounts are called classic.

Once that change is made, it’ll take some time for it to go through. When I changed to grid, it took about 2 hours to be processed. Behind the scenes, it’s copying your information over to a server built for the Grid technology.

Once you’re migrated, you’ll want to launch the Hosting Control Center (this is the product I work on). In the “My Account” screen, you can click the “Launch” button to bring up the control center:

Once this is up, you can click “Settings” and it’ll show the icons just like the picture above. To enable .NET 4, you’re going to want to click the icon “Add-On Languages”.

That will bring you to this screen. Here, simply pick “ASP 4.0″ and click “Continue”.

Problems I ran into (and what I did to fix them)
My upgrade didn’t happen without issue. The problems that came up were really easy to work through, though.

The first thing you’re going to want to check are your directory permissions. I noticed when I got migrated that it reset all of my writable directories (for example, logs).

After that, I had to work through 2 issues with IIS. First issue was that I was getting a 500 error. My web.config was still using the old IIS 6 way of displaying errors, so I had to update it to use the new IIS 7 way out outputting errors. Here’s what that looks like:

<configuration>
 <system.webServer>
  <httpErrors errorMode="Detailed" />
  <asp scriptErrorSentToBrowser="true" />
 </system.webServer>
 <system.web>
  <customErrors mode="Off" />
  <compilation debug="true" />
 </system.web>
</configuration>

After that was done, I could see there was a problem with one of my custom http modules (I’m running my application in integrated pipeline mode). I wrote a simple module to work like Apache’s mod_redirect. It’s used to canonicalize my URLs to one final URL ( for example, brianclifton.com instead of brianclifton.com/ ). It also redirects old content.

I had to remove the module from the <system.web> section. I already had the new entry in <system.webServer> (I guess .NET 2/3/3.5 let both entries co-exist). Here’s what my new entry looks like:

<system.webServer>
 <modules runAllManagedModulesForAllRequests="true">
  <add name="UrlRedirector" preCondition="" type="BrianClifton.UrlRedirector"/>
 </modules>
<system.webServer>

After that change, the site loaded up great!

I only ran into one more problem, which happened when I was trying to write this article. Because I have to enter HTML into the blog entry, ASP.NET freaked out because it could have unsafe content in the text. Even though I had a page directive specifying ValidateRequest=”false”, I had to make another web.config entry under the <system.web> section…

<httpRuntime requestValidationMode="2.0" />

That did the trick and it’s been running great since!

Software that I like

As a programmer, I’m pretty picky about what software I use. Why? Because I’m on a computer for most of the day. If I still worked in a factory and I only had to use a computer for watching silly YouTube videos of people getting in accidents, life would be a lot different.

I wanted to compile a list of my favorite programs and try to explain why I like them. You can click the title of each program below to visit the home page where you’ll get more information / screenshots.

Microsoft Visual Studio
I love Visual Studio. You can get the express editions of the software (which are fully featured) for free.

I remember learning how to write C++ on Mac OS 7 using a pirated copy of CodeWarrior 5 because I was a teenager and I couldn’t afford a legit copy. When I started college in 1999, I had already switched to PC and used my academic discount and bought Visual Studio 6 for about $150, which I thought was a bargain at the time. Now it’s free which is amazing.

To help put things in perspective, I created this website and every piece of software on the “Projects” tab of my web site using Visual Studio. If you want to learn programming on Windows, go download it.

Google Chrome
I seriously hate FireFox. It takes like 30 seconds to start up, it has horrible memory leaks, and it crashes a lot. Those reasons aside, I think the name is just plain stupid. The only thing I did like about FireFox (being a web developer) is the Firebug extension.

I was a hardcore IE user for years until Chrome came out. I even used IE on Macintosh up until version 4 (about when I switched to PC). With Google behind it, I figured I’d give Chrome a try and ended up loving it. I like how unobtrusive the browser is; it has a minimalistic feel to it. I’ve never had it crash. I keep my browser instances and tabs open for days, sometimes weeks.

(Linux people, feel free to insert a joke here about how Windows can’t go that long without a reboot)

I’ll be honest, I don’t really care about a browser’s rendering engine or which has a “better” implementation of CSS. I like using software that works. Period. Any web developer knows that you’re going to have to test your work on every browser anyways; you don’t have to pick the most standards compliant one as your favorite. Chrome uses the WebKit engine which is essentially the same as what’s in Safari. I still have to go back and use IE sometimes for sites that won’t work in Chrome but that doesn’t happen often.

FileZilla
As far as FTP clients go on Windows, this is about the best you’re going to find. There’s not much more to say other than it’s free and it works great. Before I found this in 2002, I used a piece of crap FTP program some of you might remember called LeechFTP.

mIRC
I’ve spent a lot more of my time on IRC than I’d like to admit. I first got involved with IRC on Macintosh in 1994. I used a complete garbage client called Ircle. None of my real life friends were interested in computer programming so I turned to the internet to meet people that were into C++. I learned most of what I know about programming by hanging around for years in #C and #C++ on EFNET.

mIRC is hands down the best client out there. I wrote my own client at one point using MASM (as a learning exercise) and although it worked, it sucked. I got sick of seeing the authors face pop up so I actually paid the shareware fee. It’s been worth every cent, although I don’t go on IRC as much anymore.

KeePass
It’s getting to the point where everything has a password. Want to post a comment on someone’s blog or forum? You’ll probably need to sign up and have another user/password that you’ll almost guaranteed forget as soon as you click the submit button.

I started using this program to keep track of all my passwords because it seriously got out of control. I have the program open now and there are over 80 passwords entered in here that I actively use. I like to think I’m a smart guy but because the password rules are different on every website you can’t use the same password on everything (and even if you could, it’s a horrible idea from a security perspective).

An 8-12 character password with 3 uppercase letters, 2 symbols, and that isn’t close to my last 9 passwords? I have a hard enough time remembering what I ate for lunch yesterday.