Saturday, August 25, 2007

'asp' is an unrecognized tag prefix or device filter

I'm using Visual Studio 2005 with SP 1. Recently the IDE started showing errors for my asp tags:

'asp' is an unrecognized tag prefix or device filter

There were a lot of online reports that this was a reflection of Master Pages. For me, I was not using Master Pages. My fix was to:

  1. Close all VS instances
  2. Delete folder contents at "C:\Documents and Settings\[Username]\Application Data\Microsoft\VisualStudio\8.0\ReflectedSchemas"
  3. Restart VS (it will recreate schemas)

Friday, August 24, 2007

Loading PowerShell scripts at startup

If you want to execute a lot of custom scripts/functions when PowerShell starts up, you can either put them all in your startup profile, or use the method below.

Assuming you have a startup profile named Microsoft.PowerShell_Profile.ps1 in:

%UserProfile%\\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile

Create a subdirectory called something like Includes and place all your custom script files in this directory. Finally add the following code into the startup profile:

foreach ($f in get-childitem $(join-path $(split-path $profile -Parent) "Includes"))
{
. $f.fullname
}


Now, each time PowerShell is started, it will automatically execute all your customer shell scripts/functions.

Powershell Profiles

Extracted from: http://msdn2.microsoft.com/en-us/library/bb613488.aspx

When you add aliases, functions, and variables to Windows PowerShell, you are actually adding them only to the current Windows PowerShell session. If you exit the session or close Windows PowerShell, the changes are lost.

To retain these changes, you can create a Windows PowerShell profile and add the aliases, functions, and variables to the profiles. The profile is loaded every time that Windows PowerShell starts.

To load a profile, your Windows PowerShell execution policy must permit you to load configuration files. If it does not, the attempt to load the profile fails and Windows PowerShell displays an error message.

Understanding the Profiles

You can have four different profiles in Windows PowerShell. The profiles are listed in load order. The most specific profiles have precedence over less specific profiles where they apply.

%windir%\system32\WindowsPowerShell\v1.0\profile.ps1

This profile applies to all users and all shells.

%windir%\system32\WindowsPowerShell\v1.0\ Microsoft.PowerShell_profile.ps1

This profile applies to all users, but only to the Microsoft.PowerShell shell.

%UserProfile%\My Documents\WindowsPowerShell\profile.ps1

This profile applies only to the current user, but affects all shells.

%UserProfile%\\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

This profile applies only to the current user and the Microsoft.PowerShell shell.

Creating a Profile

When you create or import variables, aliases, or functions, or add a Windows PowerShell snap-in, these elements are added only to the current console. If you exit the session or close the window, they are gone.

To save the variables, aliases, functions, and commands that you use routinely, and make them available in every Windows PowerShell console, add them to your Windows PowerShell profile.

You can also create, share, and distribute profiles to enforce a consistent view of Windows PowerShell in a larger enterprise.

Windows PowerShell profiles are not created automatically. To create a profile, create a text file with the specified name in the specified location. Typically, you will use the user-specific, shell-specific profile, known as the Windows PowerShell user profile. The location of this profile is stored in the $profile variable.

To display the path to the Windows PowerShell profile, type:

$profile

To determine whether a Windows PowerShell profile has been created on the system, type:

test-path $profile

If the profile exists, the response is True; otherwise, it is False.

To create a Windows PowerShell profile file, type:

new-item -path $profile -itemtype file -force

To open the profile in Notepad, type:

notepad $profile

To create one of the other profiles, such as the profile that applies to all users and all shells, type:

new-item -path C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 -itemtype file -force

The profile is effective only when the file is located exactly in the path and with the file name that is stored in the $profile variable. Therefore, if you create a profile in Notepad and then save it, or if you copy a profile to your system, be sure to save the file in the path and with the file name specified in the $profile variable.

If you create a profile in Notepad, enclose the file name in quotation marks to preserve the PS1 file name extension. For example:

"Microsoft.PowerShell_profile.ps1"

Without the quotation marks, Notepad appends the .txt file name extension to the file, and Windows PowerShell will not recognize it.

Use the profile to store the aliases, functions, and variables that you use routinely. One very helpful opens your user profile in your favorite text editor. For example, the following command creates a function called pro that opens the user profile in Notepad.

function pro { notepad $profile }

A well-designed profile can make it even easier to use Windows PowerShell and to administer your system.

Monday, August 13, 2007

PowerShell Prompt Utility

This utility allows you to launch a Windows PowerShell command-prompt directly from Windows Explorer via a right-click. Extract, right-click and select "Install".

Download Here

Saturday, August 11, 2007

UPS development tracking tools

You can integrate UPS (United Parcel Service) package tracking into your application using the tools found at UPS below. This supports both an HTTP and XML interface. You will need to sign up and get a UPS license to track packages, which is free.

http://www.ups.com/content/us/en/tracking/tools/index.html

Monday, August 6, 2007

Set EXECUTE on SQL stored procedures

If you have created and restored a SQL database, the stored procedures may need to have EXECUTE privilege set on them. If there are lots of these procedures, it can be tedious to do it by hand. The query below will output the T-SQL command(s) to set EXECUTE on each procedure. You can then copy/paste the result and execute it.

USE [DbNameHere]
SELECT 'GRANT EXECUTE ON ' + name + ' TO [NT AUTHORITY\NETWORK SERVICE]'
FROM sysobjects
WHERE type = 'P' AND name like 'sp_%'

Friday, August 3, 2007

Column guides in Visual Studio

Here are instructions for adding visual column indicators to the Visual Studio editor. This helps when trying to keep your code lines within a certain character limit.

Make the following new registry string values.

For Visual Studio 2003:
Location: [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1\Text Editor]
String Value: Guides=RGB(128,0,0) 80, 120

For Visual Studio 2005:
Location: [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\Text Editor]
String Value: Guides=RGB(128,0,0) 80, 120

This sets column markers at 80 and 120 characters respectively.

Wednesday, August 1, 2007

Using .NET Regular Expressions in SQL 2005

Here is an MSDN article on using .NET 2.0 Regular Expressions in Microsoft SQL 2005.

Download Here

C# Generics (.NET 2.0)

Here is an MSDN article on using .NET 2.0 Generics. It's one of the better ones I have found.

Download Here

C# Coding Standards

Here is a good document describing a set of C# coding standards.

Download Here

Virtual CD Driver for XP

This utility allows you to create a virtual CD for Windows XP. Once created, you can mount ISO files and view them just like it was a directory structure.

Download Here

DOS Prompt Utility for Visual Studio

This utility allows you to launch a Visual Studio command-prompt directly from Windows Explorer via a right-click. Extract your version (VS 2003, VS 2005), right-click and select "Install".

Download Here

Book Recommendations

Here are some great books, in my opinion, on software development, design, C#, etc. Click to view/buy on Amazon.

Agile Estimating and Planning, Prentice Hall, ISBN #0131479415

Agile Principles, Patterns, and Practices, Prentice Hall, ISBN #0131857258

Learning jQuery 1.4, PACKT, ISBN #978-1849510042

CSS Mastery, 2nd Edition, Advanced Web Standards Solutions, friends of ED, ISBN #1430223979

Windows PowerShell In Action, Manning Publications, ISBN #1932394907

Can't RDP? How to enable / disable virtual machine firewall for Azure VM

Oh no!  I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore.  I did ...