|
 Wednesday, March 14, 2007

Notepad++ Shortcuts - Vista 64bit Update

In a previous post I gave an example of how to run Notepad++ from the command line by typing the letter n. This was the solution for Windows XP. Shortcutting the name is a tip I learned from Scott Hanselman, check out his blog for tons of other good stuff.

I recently upgraded to Vista (x64) and found out that my reg edit wouldnt work any more so I created a new one.

You can use this new reg edit to run Notepad++ from the command line in Vista (x64).

Code 

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\n.exe]
@="C:\\Program Files (x86)\\Notepad++\\notepad++.exe"

 

Shell Integration

Notepad++ does not install shell integration in Vista (x64 in my case) so I created another registry entry for this as well. This will enable the right click and selection of "Notepad++" into the windows context. Like this:

Download the shell integration file belwo.

 

Downloads
'n' Shortcut: n.zip (.31 KB)

Shell Integration:

vista_x64_notepadpp_shell_integration.zip (.34 KB)
#    Comments [5] |
 Monday, March 12, 2007

C# Google Geocode (Latitude and Longitude) Class

Update 2007/05/07: There is also a Microsoft MapPoint v4.5 project I've written that does the same thing. Click here to go to that post.


Retrieve the Latitude and Longitude of any addresses in the United States, Canada, France, Germany, Italy, Spain and Japan (link) with this class. View the class below and download the class at the bottom of this post.

Code


using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Net;
using System.Web.UI;


namespace GoogleGeocoder
{
   public interface ISpatialCoordinate
   {
      decimal Latitude {get; set; } 
      decimal Longitude {get; set; } 
   }

   /// <summary>
   /// Coordiate structure. Holds Latitude and Longitude.
   /// </summary>
   public struct Coordinate : ISpatialCoordinate
   {
      private decimal _latitude; 
      private decimal _longitude;

      public Coordinate(decimal latitude, decimal longitude)
      {
         _latitude = latitude;
         _longitude = longitude; 
      }

      #region ISpatialCoordinate Members

      public decimal Latitude
      {
        get 
        { 
            return _latitude; 
        }
        set 
        { 
            this._latitude = value; 
        }
      }

      public decimal Longitude
      {
        get 
        { 
            return _longitude; 
        }
        set 
        { 
            this._longitude = value;
        }
      }

   #endregion
   }

   public class Geocode
   {
      private const string _googleUri = "http://maps.google.com/maps/geo?q=";
      private const string _googleKey = "yourkey";
      private const string _outputType = "csv"; // Available options: csv, xml, kml, json

      private static Uri GetGeocodeUri(string address)
      {
         address = HttpUtility.UrlEncode(address);
         return new Uri(String.Format("{0}{1}&output={2}&key={3}", _googleUri, address, _outputType, _googleKey));
      }

      /// <summary>
      /// Gets a Coordinate from a address.
      /// </summary>
      /// <param name="address">An address.
      /// <remarks>
      /// <example>1600 Amphitheatre Parkway Mountain View, CA 94043</example>
      /// </remarks>
      /// </param>
      /// <returns>A spatial coordinate that contains the latitude and longitude of the address.</returns>
      public static Coordinate GetCoordinates(string address)
      {
         WebClient client = new WebClient();
         Uri uri = GetGeocodeUri(address);


         /* The first number is the status code, 
         * the second is the accuracy, 
         * the third is the latitude, 
         * the fourth one is the longitude.
         */

         string[] geocodeInfo = client.DownloadString(uri).Split(',');

         return new Coordinate(Convert.ToDecimal(geocodeInfo[2]), Convert.ToDecimal(geocodeInfo[3]));
      }

   }
}


How To Use


  1. Replace "yourkey" with your google api key. Get one here.
  2. Include in your project, reference the class through a using directive.
  3. Call get the coordinates like this:
    1. Coordinate coordinate = Geocode.GetCoordinates("1600 Amphitheatre Parkway Mountain View, CA 94043");
      decimal latitude = coordinate.Latitude;
      decimal longitude = coordinate.Longitude;

Uses


For each record in your system, get the lat/long and save it to the database. This can be used for calculating distances. e.g.: "Find all stores within ___ miles of this zip code.

 

***Notes***


The maximum # of Geocode requests that can be completed in one day are 50,000 (details).

 

Download
Geocode.zip (1.05 KB)

kick it on DotNetKicks.com
#    Comments [22] |

aspnet_wp.exe could not be started?

I got this odd error message from an internal web service today that stumped me for ~30 minutes. It was:

"aspnet_wp.exe could not be started. The error code for the failure is 80070545. This error can be caused when the worker process account has insufficient rights to read the .NET Framework files. Please ensure that the .NET Framework is correctly installed and that the ACLs on the installation directory allow access to the configured account."



I took a look on some forums and blogs and other users who encountered this error said that they checked permisisons on the framework, the temp directory, the ASP.NET Temp directory and the application path. I did the same. Everything was ok, but the app was still broken. Other users said to uninstall and reinstall .NET 1.1 and that fixed it. I didn't think that was necessary.


How to fix it...

I did some more poking around and noticed that the .NET framework that was executing this was 1.1. It should have been 2.0. Like below:


 

 

***Update***:  This problem still intrigued me, so it was looked into some more. It seems that some how a recent install (either WSE 3.0 or AJAX) has caused an issue. All of our 1.1 apps were not responding. Because this server we were working with is a testing box we were able to elevate the permisisons of the ASPNET user higher than "user" and the apps started working again. We elevated the ASPNET user to "Administrator" for the time being. We plan to replace this box in the very near future (few weeks) so its not that big of an issue for us since only developers have access to the system, and, well, its a test system. :) Please note, this is not a desirable thing to do in a production environment.

#    Comments [0] |
 Saturday, March 10, 2007

Open Source .NET Wiki

I've been on the hunt for a good .NET wiki that was open source and I think I've finally found one. The folks over at ScrewTurn Software have developed ScrewTurn Wiki.

Its GPL'd, built on .NET 2.0, does not require SQL Server 2005, works in a medium trust enviroment (that means that you hosted types can use it!) and has many other features which are listed here. The only two things that you'll need are:

  1. IIS5 (or better) with .NET 2.0 installed.
  2. One write enabled directory in the root of the wiki

 

If you need to see it in action, check out the .NET Tiers website. The guys over at .NET Tiers are also using this for their site.

This is definately something that can come in handy in the corporate world when you don't have something like SharePoint installed (which offers built in Wiki support).

 

kick it on DotNetKicks.com
#    Comments [2] |
 Friday, March 09, 2007

Visual Studio SP1 with Vista


 

At work, we just upgraded our machines to Quad Xeon x64 machines with four gigs of ram. NICE..... :) But for some reason the manufacturer loaded 64 bit XP, even though we requested Vista. We upgraded it to 64 bit Vista quite easily, problem solved.

I did run into an issue while installing Service Pack 1 for Visual Studio 2005. I was attempting to install the SP1 Vista Update and I kept getting this error that told me that the proper "patches" were not in place, therefore the SP1 Vista Update would not install. To resolve this error you have to actually install SP1 (the regular one) and then the update. IMHO the documentation isnt that great in this area, I got confused...  See for yourself:

"For developers using Visual Studio 2005 on Windows Vista, Microsoft provides an update to Service Pack 1 called Visual Studio 2005 Service Pack 1 Update for Windows Vista. This update builds on the improvements made in SP1 and delivers a first class experience for developers wanting to take advantages of the new features in Windows Vista."

I was taking this as "this is the SP if you're on Vista".

So... to upgrade to SP1 on Vista... do the following:

1. Install SP1

2. Instal The SP1 update for Vista

3. Get you're code on...

#    Comments [0] |