<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://windowscoding.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"><channel><title>windowscoding.com;</title><link>http://windowscoding.com/blogs/</link><description>One Stop place to learn about next-gen programming languages and techniques.</description><dc:language>en-US</dc:language><generator>CommunityServer 2008 SP1 (Build: 30619.63)</generator><item><title>How-to: Using a Stored Procedure extended property to preserve custom logic in the CSLA generated code.</title><link>http://windowscoding.com/blogs/blake/archive/2010/07/30/how-to-using-a-stored-procedure-extended-property-to-preserve-custom-logic-in-the-csla-generated-code.aspx</link><pubDate>Fri, 30 Jul 2010 09:20:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:469</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;In the &lt;a href="http://windowscoding.com/blogs/blake/archive/2010/07/29/how-to-using-the-csla-partial-methods-to-preserve-custom-code-and-promote-active-regeneration.aspx"&gt;previous article&lt;/a&gt; on how to use the partial methods in the &lt;a href="http://www.codesmithtools.com/generate-csla-code-with-templates.aspx"&gt;CodeSmith CSLA templates&lt;/a&gt; to &lt;a href="http://windowscoding.com/blogs/blake/archive/2010/07/29/how-to-using-the-csla-partial-methods-to-preserve-custom-code-and-promote-active-regeneration.aspx"&gt;preserve custom code&lt;/a&gt; mostly focused on the code side of things. For those of you who might be using Stored Procedures might be wondering... How do I accomplish preserving my custom stored procedure logic? Don&amp;#39;t worry, CodeSmith already though of this and didn&amp;#39;t leave you out in the dark! The CSLA templates by default will not automatically execute the generated stored procedures but it can! To do this you need to set the &lt;strong&gt;AutoExecuteStoredProcedures &lt;/strong&gt;property to True. Now, when your database related metadata changes so will your stored procedures.&lt;/p&gt;
&lt;p&gt;This is a great feature until you need to implement custom logic into your stored procedure. By default we will generate logic that will prevent a stored procedure from being overwritten if you have AutoExecuteStoredProcedures turned to true or you try to drop the stored procedure. Here is the example that we are going to be modifying that will result in the same exact output as our &lt;a href="http://windowscoding.com/blogs/blake/archive/2010/07/29/how-to-using-the-csla-partial-methods-to-preserve-custom-code-and-promote-active-regeneration.aspx" target="_blank"&gt;previous sample&lt;/a&gt;.&lt;/p&gt;
&lt;pre class="brush: sql;light: true; fontsize: 100; first-line: 1; "&gt;SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
IF EXISTS (SELECT * FROM tempdb..sysobjects WHERE id=OBJECT_ID(&amp;#39;tempdb..#tmpErrors&amp;#39;)) DROP TABLE #tmpErrors
GO
CREATE TABLE #tmpErrors (Error int)
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO
PRINT N&amp;#39;Dropping CSLA_Calendar_Select&amp;#39;
GO
IF EXISTS(SELECT 1 FROM fn_listextendedproperty (NULL, &amp;#39;SCHEMA&amp;#39;, &amp;#39;dbo&amp;#39;, &amp;#39;PROCEDURE&amp;#39;, &amp;#39;CSLA_Calendar_Select&amp;#39;, default, default) WHERE name = &amp;#39;CustomProcedure&amp;#39; and value = &amp;#39;1&amp;#39;)
BEGIN
    RAISERROR (&amp;#39;The procedure CSLA_Calendar_Select has an Extended Property &amp;quot;CustomProcedure&amp;quot; which means is has been customized. Please review and remove the property if you wish to drop the procedure.&amp;#39;,16,1)
    INSERT INTO #tmpErrors (Error) SELECT 1
END
GO

IF OBJECT_ID(N&amp;#39;CSLA_Calendar_Select&amp;#39;) IS NOT NULL
	DROP PROCEDURE CSLA_Calendar_Select

GO
IF @@ERROR!=0 AND @@TRANCOUNT&amp;gt;0 ROLLBACK TRANSACTION
GO

IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO

IF EXISTS (SELECT * FROM #tmpErrors) ROLLBACK TRANSACTION
GO

IF @@TRANCOUNT&amp;gt;0 BEGIN
PRINT &amp;#39;The stored procedure drop has succeeded&amp;#39;
COMMIT TRANSACTION
END
ELSE PRINT &amp;#39;The stored procedure drop has failed&amp;#39;
GO

DROP TABLE #tmpErrors
GO

--region [dbo].[CSLA_Calendar_Select]

------------------------------------------------------------------------------------------------------------------------
-- Generated By:   Blake Niemyjski using CodeSmith: v5.2.3, CSLA Templates: v3.0.0.1888, CSLA Framework: v3.8.4
-- Procedure Name: [dbo].[CSLA_Calendar_Select]
------------------------------------------------------------------------------------------------------------------------

SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
IF EXISTS (SELECT * FROM tempdb..sysobjects WHERE id=OBJECT_ID(&amp;#39;tempdb..#tmpErrors&amp;#39;)) DROP TABLE #tmpErrors
GO
CREATE TABLE #tmpErrors (Error int)
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO

PRINT N&amp;#39;Creating [dbo].[CSLA_Calendar_Select]&amp;#39;
GO

IF EXISTS(SELECT 1 FROM fn_listextendedproperty (NULL, &amp;#39;SCHEMA&amp;#39;, &amp;#39;dbo&amp;#39;, &amp;#39;PROCEDURE&amp;#39;, &amp;#39;CSLA_Calendar_Select&amp;#39;, default, default) WHERE name = &amp;#39;CustomProcedure&amp;#39; and value = &amp;#39;1&amp;#39;)
    BEGIN
        RAISERROR (&amp;#39;The procedure [dbo].[CSLA_Calendar_Select] has an Extended Property &amp;quot;CustomProcedure&amp;quot; which means is has been customized. Please review and remove the property if you wish to create the stored procedure.&amp;#39;,16,1)
        INSERT INTO #tmpErrors (Error) SELECT 1
    END
GO

CREATE PROCEDURE [dbo].[CSLA_Calendar_Select]
	@p_ID nvarchar(50) = NULL,
	@p_CalendarName nvarchar(50) = NULL,
	@p_Name nvarchar(50) = NULL,
	@p_EventStart datetime = NULL,
	@p_EventEnd datetime = NULL,
	@p_Resource nvarchar(150) = NULL
AS

SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[CalendarName],
	[Name],
	[EventStart],
	[EventEnd],
	[Resource]
FROM
    [dbo].[Calendar]
WHERE
	([ID] = @p_ID OR @p_ID IS NULL)
	AND ([CalendarName] = @p_CalendarName OR @p_CalendarName IS NULL)
	AND ([Name] = @p_Name OR @p_Name IS NULL)
	AND ([EventStart] = @p_EventStart OR @p_EventStart IS NULL)
	AND ([EventEnd] = @p_EventEnd OR @p_EventEnd IS NULL)
	AND ([Resource] = @p_Resource OR @p_Resource IS NULL)

GO
IF @@ERROR!=0 AND @@TRANCOUNT&amp;gt;0 ROLLBACK TRANSACTION
GO

IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO

IF EXISTS (SELECT * FROM #tmpErrors) ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT&amp;gt;0 BEGIN
PRINT &amp;#39;Stored procedure creation succeeded.&amp;#39;
COMMIT TRANSACTION
END
ELSE PRINT &amp;#39;Stored procedure creation failed.&amp;#39;
GO
DROP TABLE #tmpErrors
GO

--endregion&lt;/pre&gt;
&lt;p&gt;Let&amp;#39;s open up SQL Management Studio and run the script above. Once you run the query above, you can see that the table was dropped and recreated.&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;Dropping CSLA_Calendar_Select&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;The stored procedure drop has succeeded&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;Creating [dbo].[CSLA_Calendar_Select]&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;Stored procedure creation succeeded.&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Now that you can see that the stored procedure is being overwritten, let&amp;#39;s modify the stored procedure to return the same results as our previous example.&lt;/p&gt;
&lt;pre class="brush: sql;light: true; fontsize: 100; first-line: 1; "&gt;ALTER PROCEDURE [dbo].[CSLA_Calendar_Select]
	@p_ID nvarchar(50) = NULL,
	@p_CalendarName nvarchar(50) = NULL,
	@p_Name nvarchar(50) = NULL,
	@p_EventStart datetime = NULL,
	@p_EventEnd datetime = NULL,
	@p_Resource nvarchar(150) = NULL
AS

SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[CalendarName],
	[Name],
	[EventStart],
	[EventEnd],
	[Resource]
FROM
    [dbo].[Calendar]
WHERE
	([ID] = @p_ID OR @p_ID IS NULL)
	AND ([CalendarName] = @p_CalendarName OR @p_CalendarName IS NULL)
	AND ([Name] = @p_Name OR @p_Name IS NULL)
	AND ([EventStart] = @p_EventStart OR @p_EventStart IS NULL)
	AND ([EventEnd] = @p_EventEnd OR @p_EventEnd IS NULL)
	AND ([Resource] = @p_Resource OR @p_Resource IS NULL)
	AND [EventStart] &amp;gt;= CONVERT(varchar,DATEADD(MONTH,DATEDIFF(MONTH,0,GETDATE()),0),101)&lt;/pre&gt;
&lt;p&gt;Since you modified the stored procedure, you want to mark it as a custom Stored Procedure. If you choose not to do this, then you will need to modify this stored procedure any time you wish to regenerate or drop and recreate this stored procedure. This can be done by right clicking on the stored procedure, selecting properties and then selecting the Extended Properties node. You will want to create a new extended property with a name of&amp;nbsp;&lt;strong&gt;CustomProcedure &lt;/strong&gt;and a value of &lt;strong&gt;1&lt;/strong&gt;. The following SQL Script will also create the extended property.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.21.02/Stored-Procedure-Properties-_2D00_-CSLA_5F00_Calendar_5F00_Select.png" alt="" /&gt;&lt;/p&gt;
&lt;pre class="brush: sql;light: true; fontsize: 100; first-line: 1; "&gt;EXEC sys.sp_addextendedproperty @name=N&amp;#39;CustomProcedure&amp;#39;, @value=N&amp;#39;1&amp;#39; , @level0type=N&amp;#39;SCHEMA&amp;#39;,@level0name=N&amp;#39;dbo&amp;#39;, @level1type=N&amp;#39;PROCEDURE&amp;#39;,@level1name=N&amp;#39;CSLA_Calendar_Select&amp;#39;
GO&lt;/pre&gt;
&lt;p&gt;Now when you execute the SQL script to drop and create the stored procedure it will error out and preserve your changes!&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;Dropping CSLA_Calendar_Select&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;Msg 50000, Level 16, State 1, Line 3&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;The procedure CSLA_Calendar_Select has an Extended Property &amp;quot;CustomProcedure&amp;quot; which means is has been customized. Please review and remove the property if you wish to drop the procedure.&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;(1 row(s) affected)&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;The stored procedure drop has failed&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;Creating [dbo].[CSLA_Calendar_Select]&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;Msg 50000, Level 16, State 1, Line 4&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;The procedure [dbo].[CSLA_Calendar_Select] has an Extended Property &amp;quot;CustomProcedure&amp;quot; which means is has been customized. Please review and remove the property if you wish to create the stored procedure.&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;(1 row(s) affected)&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;Msg 2714, Level 16, State 3, Procedure CSLA_Calendar_Select, Line 13&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;There is already an object named &amp;#39;CSLA_Calendar_Select&amp;#39; in the database.&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;(1 row(s) affected)&lt;/i&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;i&gt;Stored procedure creation failed.&lt;/i&gt;&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=469" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/how-to/default.aspx">how-to</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CSLA/default.aspx">CSLA</category></item><item><title>How-to: Using the CSLA partial methods to preserve custom code and promote active regeneration.</title><link>http://windowscoding.com/blogs/blake/archive/2010/07/29/how-to-using-the-csla-partial-methods-to-preserve-custom-code-and-promote-active-regeneration.aspx</link><pubDate>Thu, 29 Jul 2010 10:06:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:468</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;One of the best features of code generation is the reality of being able to actively generate you code while preserving custom changes. This allows you to implement custom logic while constantly making changes to your metadata and getting the latest template changes. &lt;a href="http://www.codesmithtools.com/"&gt;CodeSmith &lt;/a&gt;has worked hard on making this happen in both the &lt;a href="http://plinqo.com/" target="_blank"&gt;PLINQO &lt;/a&gt;and &lt;a href="http://www.codesmithtools.com/generate-csla-code-with-templates.aspx" target="_blank"&gt;CSLA Templates&lt;/a&gt;. The CSLA templates offer many partial method overrides to make your life easier. It is recommended that you place any partial methods that you implement in the non-generated partial class; this is always the ClassName.cs or ClassName.vb source code file.&lt;/p&gt;
&lt;p&gt;A list of partial methods can be found at the bottom of the every generated partial class. Here is an example of the generated partial methods.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="brush: csharp;light: true; fontsize: 100; first-line: 1; "&gt;#region DataPortal partial methods

partial void OnCreating(ref bool cancel);
partial void OnCreated();
partial void OnFetching(CalendarCriteria criteria, ref bool cancel);
partial void OnFetched();
partial void OnMapping(SafeDataReader reader, ref bool cancel);
partial void OnMapped();
partial void OnUpdating(ref bool cancel);
partial void OnUpdated();
partial void OnAddNewCore(ref Calendar item, ref bool cancel);

#endregion&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Visual Basic&lt;/strong&gt;&lt;/p&gt;
&lt;div&gt;
&lt;pre class="brush: vb;light: true; fontsize: 100; first-line: 1; "&gt;#Region &amp;quot;DataPortal partial methods&amp;quot;
    
Partial Private Sub OnCreating(ByRef cancel As Boolean)
End Sub
Partial Private Sub OnCreated()
End Sub
Partial Private Sub OnFetching(ByVal criteria As CalendarCriteria, ByRef cancel As Boolean)
End Sub
Partial Private Sub OnFetched()
End Sub
Partial Private Sub OnMapping(ByVal reader As SafeDataReader, ByRef cancel As Boolean)
End Sub
Partial Private Sub OnMapped()
End Sub
Partial Private Sub OnUpdating(ByRef cancel As Boolean)
End Sub
Partial Private Sub OnUpdated()
End Sub
Partial Private Sub OnAddNewCore(ByVal item As Calendar, ByRef cancel As Boolean)
End Sub
    
#End Region&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;In this example we will take an EditableRootList called CalendarList, whose purpose is to hold a list of Calendar business objects. The default generated code will select all calendar entries with a specific criterion. The code below is the code that is generated in the CalendarList.DataAccess partial class:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="brush: csharp;light: true; fontsize: 100; first-line: 1; "&gt;private void DataPortal_Fetch(CalendarCriteria criteria)
{
    bool cancel = false;
    OnFetching(criteria, ref cancel);
    if (cancel) return;

    RaiseListChangedEvents = false;

    // Fetch Child objects.
    string commandText = string.Format(&amp;quot;SELECT [ID], [CalendarName], [Name], [EventStart], [EventEnd], [Resource] FROM [dbo].[Calendar] {0}&amp;quot;, ADOHelper.BuildWhereStatement(criteria.StateBag));
    using (SqlConnection connection = new SqlConnection(ADOHelper.ConnectionString))
    {
        connection.Open();
        using (SqlCommand command = new SqlCommand(commandText, connection))
        {
            command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));

            using(var reader = new SafeDataReader(command.ExecuteReader()))
            {
                if(reader.Read())
                {
                    do
                    {
                        this.Add(new Calendar(reader));
                    } while(reader.Read());
                }
            }
        }
    }

    RaiseListChangedEvents = true;

    OnFetched();
}&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Visual Basic&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="brush: vb;light: true; fontsize: 100; first-line: 1; "&gt;Private Shadows Sub DataPortal_Fetch(ByVal criteria As CalendarCriteria)
    Dim cancel As Boolean = False
    OnFetching(criteria, cancel)
    If (cancel) Then
        Return
    End If

    RaiseListChangedEvents = False

    &amp;#39; Fetch Child objects.
    Dim commandText As String = String.Format(&amp;quot;SELECT [ID], [CalendarName], [Name], [EventStart], [EventEnd], [Resource] FROM [dbo].[Calendar] {0}&amp;quot;, ADOHelper.BuildWhereStatement(criteria.StateBag))
    Using connection As New SqlConnection(ADOHelper.ConnectionString)
        connection.Open()
        Using command As New SqlCommand(commandText, connection)
            command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag))
            Using reader As SafeDataReader = New SafeDataReader(command.ExecuteReader())
                If reader.Read() Then
                    Do
                        Me.Add(New Calendar(reader))
                    Loop While reader.Read()
                End If
            End Using
        End Using
    End Using

    RaiseListChangedEvents = True

    OnFetched()
End Sub&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As you can see that this isn&amp;#39;t optimal because we only want to select all&amp;nbsp;Calendar&amp;nbsp;entries from the first of the current month. &lt;i&gt;In the real word we would only want to select maybe a month of two or data...&lt;/i&gt; This can easily be done by overriding the partial method and modifying the sql statement. We will now go to the partial non generated class (CalendarList.cs or&amp;nbsp;CalendarList.vb):&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="brush: csharp;light: true; fontsize: 100; first-line: 1; "&gt;#region Custom Data Access

partial void OnFetching(CalendarCriteria criteria, ref bool cancel)
{
    RaiseListChangedEvents = false;

    // Fetch Child objects.
    string commandText = string.Format(&amp;quot;SELECT [ID], [CalendarName], [Name], [EventStart], [EventEnd], [Resource] FROM [dbo].[Calendar] {0} AND [EventStart] &amp;gt;= CONVERT(varchar,DATEADD(MONTH,DATEDIFF(MONTH,0,GETDATE()),0),101)&amp;quot;, ADOHelper.BuildWhereStatement(criteria.StateBag));
    using (SqlConnection connection = new SqlConnection(ADOHelper.ConnectionString))
    {
        connection.Open();
        using (SqlCommand command = new SqlCommand(commandText, connection))
        {
            command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));

            using (var reader = new SafeDataReader(command.ExecuteReader()))
            {
                if (reader.Read())
                {
                    do
                    {
                        this.Add(new Calendar(reader));
                    } while (reader.Read());
                }
            }
        }
    }

    RaiseListChangedEvents = true;

    // Cancel the existing Dal method.
    cancel = true;
}

#endregion&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Visual Basic&lt;/strong&gt;&lt;/p&gt;
&lt;div&gt;
&lt;pre class="brush: vb;light: true; fontsize: 100; first-line: 1; "&gt;#Region &amp;quot;Custom Data Access&amp;quot;
Private Shadows Sub DataPortal_Fetch(ByVal criteria As CalendarCriteria)
    Dim cancel As Boolean = False
    OnFetching(criteria, cancel)
    If (cancel) Then
        Return
    End If

    RaiseListChangedEvents = False

    &amp;#39; Fetch Child objects.
    Dim commandText As String = String.Format(&amp;quot;SELECT [ID], [CalendarName], [Name], [EventStart], [EventEnd], [Resource] FROM [dbo].[Calendar] {0} AND [EventStart] &amp;gt;= CONVERT(varchar,DATEADD(MONTH,DATEDIFF(MONTH,0,GETDATE()),0),101)&amp;quot;, ADOHelper.BuildWhereStatement(criteria.StateBag))
    Using connection As New SqlConnection(ADOHelper.ConnectionString)
        connection.Open()
        Using command As New SqlCommand(commandText, connection)
            command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag))
            Using reader As SafeDataReader = New SafeDataReader(command.ExecuteReader())
                If reader.Read() Then
                    Do
                        Me.Add(New Calendar(reader))
                    Loop While reader.Read()
                End If
            End Using
        End Using
    End Using

    RaiseListChangedEvents = True

    OnFetched()
End Sub
#End Region&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;As you can see all we needed to do was implement the OnFetching partial method and override the sql query that was then sent to the database server. You can do anything you want in this partial method. The last thing to do is set the reference cancel variable to true if you wish to have everything after the partial method call ignored. If you set this to false then the existing generated code will also run. In this case, we want to cancel out. A scenario where you would want to return false, is if you wanted to do some processing before accessing the database.&lt;/p&gt;
&lt;p&gt;If you come across something that you wish had a partial method, please log it on the &lt;a target="_blank" href="http://code.google.com/p/codesmith/issues/list"&gt;CodeSmith template issue tracker&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=468" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/how-to/default.aspx">how-to</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CSLA/default.aspx">CSLA</category></item><item><title>Breaking CSLA 4.0 property changes when using private backing fields.</title><link>http://windowscoding.com/blogs/blake/archive/2010/07/28/Breaking-CSLA-4-0-property-changes-when-using-private-backing-fields.aspx</link><pubDate>Wed, 28 Jul 2010 06:01:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:467</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I came across this&amp;nbsp;&lt;a href="http://www.lhotka.net/cslabugs/edit_bug.aspx?id=813" target="_blank"&gt;bug &lt;/a&gt;last night, which was&amp;nbsp;occurring&amp;nbsp;right as &lt;a href="http://www.lhotka.net/weblog/CSLA4Release.aspx" target="_blank"&gt;CSLA4 was released&lt;/a&gt;. It had to deal with the&amp;nbsp;&lt;a href="http://www.codesmithtools.com/generate-csla-code-with-templates.aspx"&gt;CodeSmith CSLA templates&lt;/a&gt; when you set &lt;strong&gt;UseMemberVariables &lt;/strong&gt;to true. The error is quite obscure and not very intuitive as the signs of a bug are only found when you check to see if your business object IsValid. The scenario in this case is when you set a required managed property, the rules never fully evaluate the set value. A bunch of other side effects could occur as well. Here is the error you could receive:&lt;/p&gt;
&lt;p&gt;CategoryId&amp;nbsp;required&lt;br /&gt;&amp;nbsp;&amp;nbsp;Expected:&amp;nbsp;True&lt;br /&gt;&amp;nbsp;&amp;nbsp;But&amp;nbsp;was:&amp;nbsp;&amp;nbsp;False&lt;/p&gt;
&lt;p&gt;Here is the code that was causing the error:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="brush: csharp;light: true; fontsize: 100; first-line: 1; "&gt;protected override void AddBusinessRules()
{
    BusinessRules.AddRule(new Csla.Rules.CommonRules.Required(_categoryIdProperty));
}

private static readonly PropertyInfo&amp;lt; System.String &amp;gt; _categoryIdProperty = RegisterProperty&amp;lt; System.String &amp;gt;(p =&amp;gt; p.CategoryId, string.Empty);
private System.String _categoryId = _categoryIdProperty.DefaultValue;
public System.String CategoryId
{
    get { return GetProperty(_categoryIdProperty, _categoryId); }
    set { SetProperty(_categoryIdProperty, ref _categoryId, value); }
}

[Test]
private void CreateCategory(string categoryID)
{
    Category category = Category.NewCategory();
    category.CategoryId = categoryID;
    Assert.IsTrue(category.IsValid, category.BrokenRulesCollection.ToString());

    category = category.Save();

    Assert.IsTrue(category.CategoryId == categoryID);
}&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Visual Basic&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="brush: vb;light: true; fontsize: 100; first-line: 1; "&gt;Protected Overrides Sub AddBusinessRules()
    BusinessRules.AddRule(New Csla.Rules.CommonRules.Required(_categoryIdProperty))
End Sub

Private Shared ReadOnly _categoryIdProperty As PropertyInfo(Of System.String) = RegisterProperty(Of System.String)(Function(p As Category) p.CategoryId, String.Empty)
Private _categoryId As System.String = _categoryIdProperty.DefaultValue
Public Property CategoryId() As System.String
    Get 
        Return GetProperty(_categoryIdProperty, _categoryId) 
    End Get
    Set (value As System.String)
        SetProperty(_categoryIdProperty, _categoryId, value)
    End Set
End Property

&amp;lt;Test()&amp;gt; _
Private Sub CreateCategory(ByVal categoryID As String)
    Dim category As Category = PetShop.Tests.ParameterizedSQL.Category.NewCategory()
    category.CategoryId = categoryID

    Assert.IsTrue(category.IsValid, category.BrokenRulesCollection.ToString())
    category = category.Save()

    Assert.IsTrue(category.CategoryId = categoryID)
End Sub&lt;/pre&gt;
&lt;p&gt;As you can see the code looks and works fine in CSLA 3.8 but it isn&amp;#39;t the case in 4.0. Once I tracked down what was causing the error, I saw that there wasn&amp;#39;t any checks in CSLA4 to see if the property had the RelationshipTypes.PrivateField overload when you are calling the GetProperty or SetProperty methods with a backing field. The long term fix when using private member backing fields is to set the RelationshipTypes to&amp;nbsp;&lt;strong&gt;RelationshipTypes.PrivateField&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="brush: csharp;light: true; fontsize: 100; first-line: 1; "&gt;private static readonly PropertyInfo&amp;lt; System.String &amp;gt; _categoryIdProperty = RegisterProperty&amp;lt; System.String &amp;gt;(p =&amp;gt; p.CategoryId, string.Empty, RelationshipTypes.PrivateField);
private System.String _categoryId = _categoryIdProperty.DefaultValue;
public System.String CategoryId
{
    get { return GetProperty(_categoryIdProperty, _categoryId); }
    set { SetProperty(_categoryIdProperty, ref _categoryId, value); }
}&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Visual Basic&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="brush: vb;light: true; fontsize: 100; first-line: 1; "&gt;Private Shared ReadOnly _categoryIdProperty As PropertyInfo(Of System.String) = RegisterProperty(Of System.String)(Function(p As Category) p.CategoryId, String.Empty, RelationshipTypes.PrivateField)
Private _categoryId As System.String = _categoryIdProperty.DefaultValue
Public Property CategoryId() As System.String
    Get 
        Return GetProperty(_categoryIdProperty, _categoryId) 
    End Get
    Set (value As System.String)
        SetProperty(_categoryIdProperty, _categoryId, value)
    End Set
End Property&lt;/pre&gt;
&lt;p&gt;This has been fixed in a nightly build of the CodeSmith CSLA Templates and will be in &lt;a target="_blank" href="http://code.google.com/p/codesmith/issues/list?can=1&amp;amp;q=label:Version-3.0.1"&gt;version 3.0.1&lt;/a&gt; of the CodeSmith CSLA Templates. The CSLA team will also be releasing version 4.0.1 of CSLA sometime soon. If you don&amp;#39;t have this overload set in CSLA 4.0.1 then you will receive the following exception:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;strong&gt;&lt;i&gt;Properties with private backing fields must be marked as RelationshipTypes.PrivateField&lt;/i&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you are using the CodeSmith CSLA templates, remember to update to the latest templates and regenerate. If you are not, well you should be using the CodeSmith CSLA Templates as it is about to &lt;b&gt;save you a ton of time&lt;/b&gt; adding the&amp;nbsp;RelationshipTypes.PrivateField overload to all of your properties!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=467" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CSLA/default.aspx">CSLA</category></item><item><title>How to upgrade a Community Server website thats running  2.1, 2007 or 2008 site to Community Server 2008 or Telligent Community 5.5</title><link>http://windowscoding.com/blogs/blake/archive/2010/07/27/how-to-upgrade-a-community-server-website-thats-running-2-1-2007-or-2008-site-to-community-server-2008-or-telligent-community-5-5.aspx</link><pubDate>Tue, 27 Jul 2010 16:42:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:465</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;
&lt;div&gt;
&lt;p&gt;I have done a few of these upgrades for a few big sites like &lt;a href="http://bink.nu/"&gt;Bink.nu&lt;/a&gt; and&lt;a href="http://sober.com/"&gt; Sober.com&lt;/a&gt;. Here is the safest way without a ton of headaches. Please contact me if you need help, I&amp;#39;m willing to do the upgrade for people as well... Please do SQL backups after every step!&lt;/p&gt;
&lt;h3&gt;Database Instructions&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Upgrade from Community Server 2.1 to 2007.0&lt;/li&gt;
&lt;li&gt;Create a SQL backup.&lt;/li&gt;
&lt;li&gt;Run&amp;nbsp;&lt;a href="http://www.red-gate.com/products/SQL_Compare/"&gt;SQL Compare&lt;/a&gt;&amp;nbsp;against a fresh database of cs2007 to the upgraded database and make sure everything transferred correctly.&lt;/li&gt;
&lt;li&gt;If there were changes, create a SQL backup.&lt;/li&gt;
&lt;li&gt;Run the upgrade from 2007.0 to the last service pack release of 2007. (I think it was SP3).&lt;/li&gt;
&lt;li&gt;Create a SQL backup.&lt;/li&gt;
&lt;li&gt;Upgrade from CS 2007 SP3 to CS 2008.&lt;/li&gt;
&lt;li&gt;Create a SQL backup.&lt;/li&gt;
&lt;li&gt;Run&amp;nbsp;&lt;a href="http://www.red-gate.com/products/SQL_Compare/"&gt;SQL Compare&lt;/a&gt;&amp;nbsp;against a freshly created CS 2008 database against the upgrade database to ensure everything is correct.&lt;/li&gt;
&lt;li&gt;If there were changes, create a SQL backup.&lt;/li&gt;
&lt;li&gt;Upgrade to CS 2008.5 using the upgrade utility.&lt;/li&gt;
&lt;li&gt;Create a SQL backup.&lt;/li&gt;
&lt;li&gt;Upgrade to latest service pack.&lt;/li&gt;
&lt;li&gt;Run&amp;nbsp;&lt;a href="http://www.red-gate.com/products/SQL_Compare/"&gt;SQL Compare&lt;/a&gt;&amp;nbsp;against a freshly created CS 2008.5 SP3 database against the upgrade database to ensure everything is correct.&lt;/li&gt;
&lt;li&gt;--------------- Continue here if you are going to the latest version of TC 5.5-------&lt;/li&gt;
&lt;li&gt;Upgrade to TC 5.5.&lt;/li&gt;
&lt;li&gt;Run&amp;nbsp;&lt;a href="http://www.red-gate.com/products/SQL_Compare/"&gt;SQL Compare&lt;/a&gt;&amp;nbsp;against a freshly created CS TC 5.5 database against the upgrade database to ensure everything is correct.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;&lt;strong&gt;Site File upgrade.&lt;/strong&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;The important thing here is that you need to do the upgrade process in order and make notes of changes. When doing this for a live database, do a run through of everything and make notes of things changing or failing and get them resolved a head of time.&lt;/li&gt;
&lt;li&gt;For the upgrade to 2007, read the readme and make sure you copy the storage files into the correct spot.&lt;ol&gt;
&lt;li&gt;I would extract the complete 2007 site files and copy the photo storage folders and everything to the correct spot.&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li&gt;To upgrade to 2008, you need to run the upgrade utility.&lt;ol&gt;
&lt;li&gt;I would extract the complete 2008 site files and read the read me. I would copy the site files to the correct spots as they were.&lt;/li&gt;
&lt;li&gt;Once you are running this tool (somewhat buggy), I would make sure that you check the log file and copy over the file storage in the utilities folder to the file storage folder on the destination site.&lt;/li&gt;
&lt;li&gt;Then I would copy the old file storage folders to the same locations in the new site... I&amp;#39;ve had cases where they are hard linked and then you get missing files. I would only ever delete these folders after completely upgraded and you have them backed up...&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li&gt;To upgrade to 2008.5, I&amp;#39;m pretty sure it&amp;#39;s using the upgrade utility again, go back to step 3.&lt;/li&gt;
&lt;li&gt;To upgrade to TC 5.5, you need to extract the clean website (to a new directory).&lt;ol&gt;
&lt;li&gt;Next, copy over only the file storage folder (leave the old file storage folders \photos\, \blogs\, \forums\ for now (just to be safe).&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Final Steps.&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Copy the files from steps 4 or 5 to the web server.&lt;/li&gt;
&lt;li&gt;Replace permissions on all upgraded files.&lt;/li&gt;
&lt;li&gt;You will need to make sure that all of your custom scripts are updated accordingly.&lt;/li&gt;
&lt;li&gt;Make sure all images and links are working.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=465" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/Community+Server/default.aspx">Community Server</category></item><item><title>How-to: Preserve column names in generated PLINQO entities.</title><link>http://windowscoding.com/blogs/blake/archive/2010/07/27/how-to-preserve-column-names-in-generated-plinqo-entities.aspx</link><pubDate>Tue, 27 Jul 2010 14:39:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:466</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;p&gt;There may come a time where you need to rename a column in your generated entity for whatever reason. The following tip and trick article will show you how to quickly accomplish this.&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s assume you have a generated property for the column AccountId and it is defined like this:&lt;/p&gt;
&lt;pre class="brush: csharp;light: true; fontsize: 100; first-line: 1; "&gt;[System.CodeDom.Compiler.GeneratedCode(&amp;quot;CodeSmith&amp;quot;, &amp;quot;5.0.0.0&amp;quot;)]
private int _accountId = default(int);

/// &amp;lt;summary&amp;gt;
/// Gets the AccountId column value.
/// &amp;lt;/summary&amp;gt;
[System.Data.Linq.Mapping.Column(Name = &amp;quot;AccountId&amp;quot;, Storage = &amp;quot;_accountId&amp;quot;, DbType = &amp;quot;int NOT NULL IDENTITY&amp;quot;, IsPrimaryKey = true, IsDbGenerated = true, CanBeNull = false)]
[System.Runtime.Serialization.DataMember(Order = 1)]
[System.CodeDom.Compiler.GeneratedCode(&amp;quot;CodeSmith&amp;quot;, &amp;quot;5.0.0.0&amp;quot;)]
public int AccountId
{
    get { return _accountId; }
    set
    {
        if (_accountId != value)
        {
            OnAccountIdChanging(value);
            SendPropertyChanging(&amp;quot;AccountId&amp;quot;);
            _accountId = value;
            SendPropertyChanged(&amp;quot;AccountId&amp;quot;);
            OnAccountIdChanged();
        }
    }
}&lt;/pre&gt;
&lt;p&gt;If you take a look at the DBML file, it will look like this:&lt;/p&gt;
&lt;pre class="brush: xml;light: true; fontsize: 100; first-line: 1; "&gt;&amp;lt;Type Name=&amp;quot;Account&amp;quot;&amp;gt;
  &amp;lt;Column Name=&amp;quot;AccountId&amp;quot; Storage=&amp;quot;_accountId&amp;quot; Type=&amp;quot;System.Int32&amp;quot; DbType=&amp;quot;int NOT NULL IDENTITY&amp;quot; IsPrimaryKey=&amp;quot;true&amp;quot; IsDbGenerated=&amp;quot;true&amp;quot; CanBeNull=&amp;quot;false&amp;quot; /&amp;gt;
&amp;lt;/Type&amp;gt;&lt;/pre&gt;
&lt;p&gt;Say you want to change the name of the property and have it preserved across generation. You will need to open the generated DBML file with the designer and change the name. I recommend always opening up the DBML file with an Xml Text editor (right click on the dbml file and select open with) and update the definition like this.&amp;nbsp;&lt;span style="color:red;"&gt;Please note that opening the DBML file in the class designer will cause custom DBML data to be lost!&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="brush: xml;light: true;fontsize: 100; first-line: 1; "&gt;&amp;lt;Type Name=&amp;quot;Account&amp;quot;&amp;gt;
  &amp;lt;Column Name=&amp;quot;AccountId&amp;quot; Member=&amp;quot;Id&amp;quot; Storage=&amp;quot;_id&amp;quot; Type=&amp;quot;System.Int32&amp;quot; DbType=&amp;quot;int NOT NULL IDENTITY&amp;quot; IsPrimaryKey=&amp;quot;true&amp;quot; IsDbGenerated=&amp;quot;true&amp;quot; CanBeNull=&amp;quot;false&amp;quot; /&amp;gt;
&amp;lt;/Type&amp;gt;&lt;/pre&gt;
&lt;p&gt;Notice that an Member Attribute was added and the Storage Attribute value was changed. These are the two attributes that you will need to modify in order to rename properties in the DBML file. If you regenerate and take a look at the generated partial class. You will see that the AccountID property was dropped and the Id Property was created:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class="brush: csharp;light: true; fontsize: 100; first-line: 1; "&gt;[System.CodeDom.Compiler.GeneratedCode(&amp;quot;CodeSmith&amp;quot;, &amp;quot;5.0.0.0&amp;quot;)]
private int _id = default(int);

/// &amp;lt;summary&amp;gt;
/// Gets the AccountId column value.
/// &amp;lt;/summary&amp;gt;
[System.Data.Linq.Mapping.Column(Name = &amp;quot;AccountId&amp;quot;, Storage = &amp;quot;_id&amp;quot;, DbType = &amp;quot;int NOT NULL IDENTITY&amp;quot;, IsPrimaryKey = true, IsDbGenerated = true, CanBeNull = false)]
[System.Runtime.Serialization.DataMember(Order = 12)]
[System.CodeDom.Compiler.GeneratedCode(&amp;quot;CodeSmith&amp;quot;, &amp;quot;5.0.0.0&amp;quot;)]
public int Id
{
    get { return _id; }
    set
    {
        if (_id != value)
        {
            OnIdChanging(value);
            SendPropertyChanging(&amp;quot;Id&amp;quot;);
            _id = value;
            SendPropertyChanged(&amp;quot;Id&amp;quot;);
            OnIdChanged();
        }
    }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=466" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/how-to/default.aspx">how-to</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/PLINQO/default.aspx">PLINQO</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/LINQ-To-SQL/default.aspx">LINQ-To-SQL</category></item><item><title>Upgrading from CSLA 3.8.4 to CSLA 4.0 using the CodeSmith CSLA templates version 3.0.0.</title><link>http://windowscoding.com/blogs/blake/archive/2010/07/26/upgrading-from-csla-3-8-4-to-csla-4-0-using-the-codesmith-csla-templates.aspx</link><pubDate>Mon, 26 Jul 2010 08:28:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:464</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We recently released a new major version of the CSLA templates that add support for many new features including Visual Studio 2010, CSLA 4.0 and Silverlight 4.0 support. They can be downloaded &lt;a href="http://code.google.com/p/codesmith/downloads/detail?name=CSLA-v3.0.0.1887.zip" target="_blank"&gt;here&lt;/a&gt;. When upgrading to the templates and you are going from CSLA 3.8 to the latest CSLA 3.8.4 templates, there really aren&amp;rsquo;t any changes you need to make other than updating your CodeSmith Project File template location to point to the new version of the templates. &amp;nbsp;The easiest way to do this is to open up Visual Studio and double click on the CodeSmith Project File and do a replace all on that file path as this will update all file paths in all CodeSmith Project Files.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.21.02/TemplatePath.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;If you are upgrading from CSLA 3.8 to CSLA 4.0 then additional work is required. The first step is to convert your solution to Visual Studio 2010 and set all the projects to use the .NET Framework v4.0. &lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.21.02/DotNet4.0.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Secondly, you will need to do is go into your CodeSmith Project Settings and change the &lt;strong&gt;FrameworkVersion &lt;/strong&gt;Property from v35 to v40. If you are planning on using Silverlight it is best to set the &lt;strong&gt;IncludeSilverlightSupport &lt;/strong&gt;property to true to save you additional merging steps.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.21.02/Edit-Output-_2D00_-Entities.csp.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The next step is to regenerate the files; you will notice that there are some build errors. &amp;nbsp;This is due to the entity partial classes are not regenerated and there are some required changes for Rules or for Silverlight. If you didn&amp;rsquo;t make any changes to the non-generated partial classes (E.G. Account.cs or Account.vb), then it is safe to delete the entire class and regenerate.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; if your Location property is set to a full path, I recommend setting it to &amp;ldquo;&lt;strong&gt;.\&lt;/strong&gt;&amp;rdquo; without the quotes.&lt;/p&gt;
&lt;p&gt;If this is not the case then I recommend backing up your solution if it is not under source control (&lt;strong&gt;highly recommended&lt;/strong&gt;). I would copy the CodeSmith Project File to a new folder and use a program like &lt;a href="http://www.scootersoftware.com/moreinfo.php"&gt;beyond compare&lt;/a&gt; to merge the partial classes together. &amp;nbsp;Since you have already regenerated, the generated partial classes will be in sync with CSLA 4.0 and won&amp;rsquo;t require a diff so your favorite diffing program will tell you that there is no work needing to be done.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.21.02/Account.cs-_2D00_-Text-Compare-_2D00_-Beyond-Compare.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see from the diff above, you will need to diff the changes. I&amp;rsquo;d recommend putting all of your Custom Code in region blocks as this makes merging much easier. This shouldn&amp;rsquo;t ever need to be merged again unless CSLA introduces some breaking changes.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=464" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category></item><item><title>CodeSmith supports Visual Studio 2010 RTM!</title><link>http://windowscoding.com/blogs/blake/archive/2010/04/19/codesmith-supports-visual-studio-2010-rtm.aspx</link><pubDate>Mon, 19 Apr 2010 12:59:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:428</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;We have been working with Microsoft over the past few months to ensure that CodeSmith works with Visual Studio 2010. The currently released version of CodeSmith 5.2.1 already supports Visual Studio 2010 Integration. Although the current support is titled as beta we have ran into very few Visual Studio 2010 bugs and will completely stand behind Visual Studio 2010.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.21.02/VS2010.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;Microsoft and Microsoft logo&amp;#39;s are trademarks of Microsoft Corporation.&lt;/i&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=428" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/.Net/default.aspx">.Net</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category></item><item><title>Unit testing the CodeSmith CSLA Templates</title><link>http://windowscoding.com/blogs/blake/archive/2010/04/08/unit-testing-the-csla-templates.aspx</link><pubDate>Thu, 08 Apr 2010 15:09:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:427</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;During the&amp;nbsp;development&amp;nbsp;of our CodeSmith CSLA templates we have spent a lot time unit testing the generated code to ensure everything was working correctly.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.21.02/PetShop-_2D00_-Microsoft-Visual-Studio-_2800_Administrator_2900_-_2800_2_2900_.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;In the future we would like to generate basic CRUD unit tests for any project. We decided to unit test the PetShop database to go along with our PetShop Sample application. We have a solution both in VB and C# that can be found in (Documents\CodeSmith\Samples\v5.2\Projects\Framework-Samples\Csla) when you install CodeSmith or grab the latest version from &lt;a href="http://code.google.com/p/codesmith/source/checkout"&gt;SVN&lt;/a&gt;. We have unit tests for all the Data Access implementations as well as collections. We test&amp;nbsp;primarily&amp;nbsp;against two tables, Category and LineItem.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.21.02/WindowClipping-_2800_26_2900_.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;These &lt;a href="http://www.nunit.org/?p=download"&gt;NUnit tests&lt;/a&gt; will give you a good understanding of how different operations are performed in CSLA. Feel free to submit to CodeSmith support or &lt;a href="http://community.codesmithtools.com/"&gt;forums &lt;/a&gt;any unit tests you think we don&amp;#39;t have. &amp;nbsp;If you find a bug in the CSLA templates, its a huge help to the community and us if you submit a failing unit test for the PetShop sample application that can reproduce your bug. This ensures we have more&amp;nbsp;testability&amp;nbsp;and no regressions in future versions. However, any unit test will be appreciated along with the respected sample schema.&lt;/p&gt;
&lt;p&gt;When contributing new unit tests, please try to follow our common testing pattern for&amp;nbsp;consistency&amp;nbsp;that outputs a description and how long it took to run the test.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.21.02/WindowClipping-_2800_27_2900_.png" alt="" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=427" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CSLA/default.aspx">CSLA</category></item><item><title>How-to: Upgrade your PLINQO or CSLA templates</title><link>http://windowscoding.com/blogs/blake/archive/2010/01/26/how-to-upgrade-your-plinqo-or-csla-templates.aspx</link><pubDate>Tue, 26 Jan 2010 08:35:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:422</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;This article will help you upgrade your solutions templates safely and easily to the latest major or minor version. &amp;nbsp;The latest templates can be found on our &lt;a href="http://code.google.com/p/codesmith/downloads/list"&gt;Google code project&lt;/a&gt; and the latest nightly build can be found &lt;a href="http://community.codesmithtools.com/nightly/"&gt;here&lt;/a&gt;. The first thing to do is to download the template framework you wish to update.&lt;/p&gt;
&lt;p&gt;After the templates have been downloaded and extracted. Remove or Replace the old templates with the new ones keeping the same folder structure or simply update your &lt;a href="http://community.codesmithtools.com/blogs/pwelter/archive/2007/06/10/introduction-to-codesmith-project-files.aspx"&gt;CodeSmith Project File(s)&lt;/a&gt; to point to the updated templates. If you have custom made changes, this is where you merge in your changes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I recommend using our templates via &lt;a href="http://code.google.com/p/codesmith/source/checkout"&gt;SVN&lt;/a&gt;. This will ensure easy upgradability while keeping any custom changes. To update all you need to do is right click and select update.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/svnUpdate.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The next step is to remove any template dependent references from your Visual Studio Project so the new references can be updated. These references would include the CodeSmith.Data assembly if you are using PLINQO or the Csla assembly. Both of these assemblies can be found in the Common folder in the root of the template directory. This can be done by clicking on your project references and clicking remove. The references will be automatically added when you run the templates. Please note that if the paths are the same then you can skip this step, but I recommend completing this step just to be on the safe side.&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/remove-reference.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Lastly, if you have any build breaks fix them by compiling. You shouldn&amp;rsquo;t have any build breaks but this can happen if you are migrating to the next major version (E.G. 4.0).&lt;/p&gt;
&lt;p&gt;If you encounter any bugs after upgrading please let us know by contacting support.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=422" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/how-to/default.aspx">how-to</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CSLA/default.aspx">CSLA</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/PLINQO/default.aspx">PLINQO</category></item><item><title>How-to: Use SQL CLR Functions and Functions in your CodeSmith templates.</title><link>http://windowscoding.com/blogs/blake/archive/2010/01/25/how-to-use-sql-clr-functions-and-functions-in-your-codesmith-templates.aspx</link><pubDate>Tue, 26 Jan 2010 03:44:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:425</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;In a previous &lt;a href="http://community.codesmithtools.com/blogs/blake/archive/2009/12/27/how-to-codesmith-and-sql-functions.aspx"&gt;post &lt;/a&gt;I had mentioned that we added SQL CLR Stored procedures as well as SQL Functions in the release of CodeSmith 5.2. Since then there has been a few questions since then on how to add this to your existing templates. The great news is, you can add the functionality in a few easy changes.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.21.02/Extended-Property-Editor-_2D00_-dbo.aspnet_5F00_CheckSchemaVersion.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;To enable SQL function support you need to set IncludeFunctions=&amp;quot;True&amp;quot; on any types inheriting from SchemaObjectBase (E.G. CommandSchema, CommandSchemaCollection, DatabaseSchema...).&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.21.02/IncludeFunctions2.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Once this has been done you will see SQL functions be added to your User Interface Command pickers as well as show up in the API like DatabaseSchema.Commands.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How do I check to see what type of SQL Function it a command is?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;CS_IsCLR&lt;/strong&gt;: Returns true if the command is a&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/ms190790.aspx"&gt;CLR Procedure&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CS_IsScalarFunction&lt;/strong&gt;: Returns true if the command is a&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/ms174318.aspx"&gt;Scalar Function&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CS_IsTableValuedFunction&lt;/strong&gt;: Returns true if the command is a&amp;nbsp;&lt;a href="http://technet.microsoft.com/en-us/library/ms191165.aspx"&gt;Table-Valued Function&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CS_IsInlineTableValuedFunction&lt;/strong&gt;: Returns true if the command is a&amp;nbsp;&lt;a href="http://technet.microsoft.com/en-us/library/ms189294.aspx"&gt;Inline Table-Valued Function&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CS_IsMultiStatementTableValuedFunction&lt;/strong&gt;: Returns true if the command is a&amp;nbsp;&lt;a href="http://www.sqlteam.com/article/intro-to-user-defined-functions-updated"&gt;Multi-Statement Table-Valued Function&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;It is also easy to take different actions in your template logic based on the type of function.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&amp;lt;% if(!IsTableValuedFunction) { %&amp;gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cmd.CommandText = &amp;quot;[&amp;lt;%= SourceCommand.Owner %&amp;gt;].[&amp;lt;%= SourceCommand.Name %&amp;gt;]&amp;quot;;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cmd.CommandType = CommandType.StoredProcedure;&lt;/div&gt;
&lt;div&gt;&amp;lt;% } else {%&amp;gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cmd.CommandText = &amp;quot;SELECT * FROM [&amp;lt;%= SourceCommand.Owner %&amp;gt;].[&amp;lt;%= SourceCommand.Name %&amp;gt;](&amp;lt;%=BuildArgumentList()%&amp;gt;)&amp;quot;;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cmd.CommandType = CommandType.Text;&lt;/div&gt;
&lt;div&gt;&amp;lt;%}%&amp;gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;public bool IsTableValuedFunction&lt;/div&gt;
&lt;div&gt;{&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;get&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (SourceCommand == null || !SourceCommand.ExtendedProperties.Contains(&amp;quot;CS_IsTableValuedFunction&amp;quot;))&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return false;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bool temp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bool.TryParse(SourceCommand.ExtendedProperties[&amp;quot;CS_IsTableValuedFunction&amp;quot;].Value.ToString(), out temp);&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return temp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;
&lt;div&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&amp;lt;%}%&amp;gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;What templates can I observe these changes in?&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;We have completely updated the Command wrapper templates to fully support SQL Functions. Please download the latest build of CodeSmith 5.2 and give them a try.&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=425" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/how-to/default.aspx">how-to</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/Tips+_2600_amp_3B00_+Tricks/default.aspx">Tips &amp;amp; Tricks</category></item><item><title>How-to: CodeSmith and SQL Functions.</title><link>http://windowscoding.com/blogs/blake/archive/2009/12/27/how-to-codesmith-and-sql-functions.aspx</link><pubDate>Mon, 28 Dec 2009 03:51:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:421</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;CodeSmith now supports SQL Functions and SQL CLR Functions with the release of CodeSmith 5.2. I will quickly show you how to add SQL Function support to your template.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/SQLFunctions.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The first thing you need to do in order to use SQL Functions is to set the &lt;b&gt;IncludeFunctions &lt;/b&gt;Property on any type that derives from SchemaObjectBase. &amp;nbsp;The following property types are capable of showing functions when you add the 
IncludeFunctions=&amp;quot;True&amp;quot; setting to the property: CommandSchema, CommandSchemaCollection and DatabaseSchema.&lt;/p&gt;
&lt;p&gt;&amp;lt;%@ Property Name=&amp;quot;SourceDatabase&amp;quot; Type=&amp;quot;SchemaExplorer.DatabaseSchema&amp;quot; Category=&amp;quot;Required&amp;quot; Description=&amp;quot;Database that contain the stored procedures.&amp;quot; &lt;strong&gt;IncludeFunctions=&amp;quot;True&amp;quot;&lt;/strong&gt; %&amp;gt;&lt;/p&gt;
&lt;p&gt;Now your SQL Functions will show up in SchemaExplorer when you iterate over your commands.&lt;/p&gt;
&lt;p&gt;&amp;lt;% foreach (CommandSchema command in SourceDatabase.Commands) { %&amp;gt;&lt;/p&gt;
&lt;p&gt;Name: &amp;lt;%= command.Name %&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;% } %&amp;gt;&lt;/p&gt;
&lt;p&gt;We have also added five extended properties to the CommandSchema. They are as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;CS_IsCLR&lt;/strong&gt;: Returns true if the command is a &lt;a href="http://msdn.microsoft.com/en-us/library/ms190790.aspx"&gt;CLR Procedure&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CS_IsScalarFunction&lt;/strong&gt;: Returns true if the command is a &lt;a href="http://msdn.microsoft.com/en-us/library/ms174318.aspx"&gt;Scalar Function&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CS_IsTableValuedFunction&lt;/strong&gt;: Returns true if the command is a &lt;a href="http://technet.microsoft.com/en-us/library/ms191165.aspx"&gt;Table-Valued Function&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CS_IsInlineTableValuedFunction&lt;/strong&gt;: Returns true if the command is a &lt;a href="http://technet.microsoft.com/en-us/library/ms189294.aspx"&gt;Inline Table-Valued Function&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CS_IsMultiStatementTableValuedFunction&lt;/strong&gt;: Returns true if the command is a &lt;a href="http://www.sqlteam.com/article/intro-to-user-defined-functions-updated"&gt;Multi-Statement Table-Valued Function&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A normal stored procedure will always return an int value as the &lt;a href="http://msdn.microsoft.com/en-us/library/ms174998.aspx"&gt;return value&lt;/a&gt;. However, a scalar function can return any data type.&lt;/p&gt;
&lt;p&gt;The attached template will show you how to get at this information.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=421" width="1" height="1"&gt;</description><enclosure url="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.PostAttachments/00.00.00.04.21/SQLFunctions.cst" length="1338" type="application/codesmith" /><category domain="http://windowscoding.com/blogs/blake/archive/tags/.Net/default.aspx">.Net</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/SQL+Server+2005/default.aspx">SQL Server 2005</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/how-to/default.aspx">how-to</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CLR/default.aspx">CLR</category></item><item><title>How-to: Build a custom UITypeEditor</title><link>http://windowscoding.com/blogs/blake/archive/2009/10/13/how-to-build-a-custom-uitypeeditor.aspx</link><pubDate>Tue, 13 Oct 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:419</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Recently I built a &lt;a target="_blank" href="http://www.codesmithtools.com/"&gt;CodeSmith&lt;/a&gt; sample UITypeEditor that allows a user to enter in custom data into a DropDownList. In the following article I&amp;rsquo;ll show you what you need to do in order to build your own UITypeEditor.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/CodeSmith-Studio.png" border="1px" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;First you need to create a public class that will hold the data of the drop down list. In this example I named my class DropDownListProperty.&lt;/p&gt;
&lt;p&gt;public class DropDownListProperty&lt;br /&gt;{&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;Next we will need to add the properties and the constructors.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public class DropDownListProperty&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private List&amp;lt;string&amp;gt; _values = new List&amp;lt;string&amp;gt;();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public DropDownListProperty()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SelectedItem = &amp;quot;None&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public DropDownListProperty(List&amp;lt;String&amp;gt; values)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(values.Count &amp;gt; 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SelectedItem = values[0];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SelectedItem = &amp;quot;None&amp;quot;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Values = values;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public List&amp;lt;string&amp;gt; Values &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (_values == null)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _values = new List&amp;lt;String&amp;gt;();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return _values;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(value != null)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _values = value;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Browsable(false)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string SelectedItem { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;You&amp;#39;ll notice that we have a public property called SelectedItem. This property will hold the initial value which will be the selected value when a user selects a choice. By default we set this to &amp;quot;None&amp;quot; in the constructor. We also set an attribute on the property Browsable(false). This tells the PropertyGrid not to display this property.&lt;/p&gt;
&lt;p&gt;We now want to override the ToString() method to the DropDownListProperty so the dropdown displays the current selected value. &lt;/p&gt;
&lt;p&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// The value that we return here will be shown in the property grid.&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;public override string ToString()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return SelectedItem;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;Now it is time to implement the class that controls how my class is displayed in the property grid. We will want to create a class that inherits from UITypeEditor.&lt;/p&gt;
&lt;p&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Provides a user interface for selecting a state property.&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;public class DropDownListPropertyEditor : UITypeEditor&lt;br /&gt;{&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;Next we will add a private member variable named _service. We will need to declare this member variable because we will want to tie into an event in a little bit. Now it is time to override the EditValue method.&lt;/p&gt;
&lt;p&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Displays a list of available values for the specified component than sets the value.&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name=&amp;quot;context&amp;quot;&amp;gt;An ITypeDescriptorContext that can be used to gain additional context information.&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name=&amp;quot;provider&amp;quot;&amp;gt;A service provider object through which editing services may be obtained.&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name=&amp;quot;value&amp;quot;&amp;gt;An instance of the value being edited.&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;The new value of the object. If the value of the object hasn&amp;#39;t changed, this method should return the same object it was passed.&amp;lt;/returns&amp;gt;&lt;br /&gt;public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (provider != null)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // This service is in charge of popping our ListBox.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _service = ((IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)));&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (_service != null &amp;amp;&amp;amp; value is DropDownListProperty)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var property = (DropDownListProperty) value;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var list = new ListBox();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list.Click += ListBox_Click;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (string item in property.Values)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list.Items.Add(item);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Drop the list control.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _service.DropDownControl(list);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (list.SelectedItem != null &amp;amp;&amp;amp; list.SelectedIndices.Count == 1)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; property.SelectedItem = list.SelectedItem.ToString();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value =&amp;nbsp; property;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return value;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;It is important not to be overwhelmed by the code above. The object value that is passed in is the DropDownListProperty class that holds our data. All we need to do is some safe type checking (value is DropDownListProperty) and then cast the value. The _service variable holds the property grid control that we are interacting with.&lt;/p&gt;
&lt;p&gt;We create a ListBox object as that will hold our list of data (Values property from the DropDownListProperty class). It also exposes a Click event that will allow us to know when someone clicks on the drop down list. We will add an event handler ListBox_Click&amp;nbsp; to the Click event so we can close the drop down list. If we skipped this step then the list would always be shown.&lt;/p&gt;
&lt;p&gt;The next few lines just adds all our data into the Listox and calls DropDownControl(Control).&amp;nbsp; This shows the populated ListBox control. &lt;/p&gt;
&lt;p&gt;Finally we will set the SelectedItem to the Item that the user selected. &lt;/p&gt;
&lt;p&gt;It is time to add the method that we wired up to the Click event.&lt;/p&gt;
&lt;p&gt;private void ListBox_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; if(_service != null)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _service.CloseDropDown();&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;The last peice to this puzzle is to override the GetEditStyle method and return that we want to display a DropDown UITypeEditorEditStyle&lt;/p&gt;
&lt;p&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Gets the editing style of the &amp;lt;see cref=&amp;quot;EditValue&amp;quot;/&amp;gt; method.&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name=&amp;quot;context&amp;quot;&amp;gt;An ITypeDescriptorContext that can be used to gain additional context information.&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;Returns the DropDown style, since this editor uses a drop down list.&amp;lt;/returns&amp;gt;&lt;br /&gt;public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // We&amp;#39;re using a drop down style UITypeEditor.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return UITypeEditorEditStyle.DropDown;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;Finally we will go back and add a Editor attribute to the DropDownListProperty class. This will tell the PropertyGrid that when this property type is loaded to use the new UITypeEditor class we created.&lt;/p&gt;
&lt;p&gt;[Editor(typeof(DropDownListPropertyEditor), typeof(System.Drawing.Design.UITypeEditor))]&lt;/p&gt;
&lt;p&gt;For more information please check out our &lt;a target="_blank" href="http://code.google.com/p/codesmith/"&gt;Google Code repository&lt;/a&gt;. Attached is the source code for these two classes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=419" width="1" height="1"&gt;</description><enclosure url="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.PostAttachments/00.00.00.04.19/DropDownListProperty.zip" length="2194" type="application/x-compressed" /><category domain="http://windowscoding.com/blogs/blake/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/.Net/default.aspx">.Net</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/User+Interfaces/default.aspx">User Interfaces</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category></item><item><title>It's the littlest of things that we do, that make CodeSmith shine.</title><link>http://windowscoding.com/blogs/blake/archive/2009/10/12/it-s-the-littlest-of-things-that-we-do-that-make-codesmith-shine.aspx</link><pubDate>Mon, 12 Oct 2009 12:25:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:418</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;During each release of CodeSmith, one thing we always do is test upgrade scenarios between each versions and check for backwards compatibility among other tests. Recently, I was amazed at how much change has taken place between CodeSmith 4.x and the latest CodeSmith 5.1.x release when it comes to the user interface. CodeSmith has made a huge effort to make CodeSmith rock solid, crazy fast,&amp;nbsp; and easy to use. I&amp;rsquo;d like to give everyone a quick inside look as to how I think CodeSmith has accomplished this.&lt;br /&gt;&lt;br /&gt;Our goal from the beginning was to make CodeSmith a top notch dependable tool. I think we have accomplished this through various forms. In the previous version of CodeSmith a user would have to report every bug they found by using the built in tool, support or the community. We have found that most of the time you&amp;rsquo;re in a hurry and stop using the tool or don&amp;rsquo;t report the issue. We have spent the time to make bug reporting much easier and provide us with as much possible as you want us to. So we can fix the bug with as little user intervention as possible. You can also choose in the options to send us feedback automatically, or you can choose the default option to send feedback at your digression.&lt;br /&gt;&lt;br /&gt;When a crash occurred in CodeSmith 4.x you had the option to send in a crash report via the following dialog. We have found that the previous approach doesn&amp;rsquo;t allow us to reproduce the issue as easily and most of the time doesn&amp;rsquo;t provide enough information.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/Crash-Report.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Since the introduction of CodeSmith 5.1.x we have added new functionality to CodeSmith that allows the user to selectively choose which pieces of information are sent back to us.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/CodeSmithStudio.exe-Error.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;If you click on the click here link you will be presented with the following dialog that lets you choose which pieces of information you want to send back.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/CodeSmithStudio.exe-Error-Details.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;This additional information allows our project managers and team see what issues end users like yourself are experiencing so we can get a bug fix out quickly. If you provide your email address, we will contact you and let you know that we are looking into the issue. We have gathered a lot of feedback through the use of error reporting that has changed how we as a company work on bugs in the product.&lt;br /&gt;&lt;br /&gt;User feedback is very important to us. We review all user feedback that comes into CodeSmith via support, surveys, and the community forums. With the latest build of CodeSmith, It has become even easier to contact CodeSmith and let us know what you think. From the Help menu select feedback and you are prompted with the following dialog that allows you to ask a question, submit an idea or bug report. We have also included the functionality to search previous submitted ideas and vote on them.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/Send-Feedback.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;You might be thinking to yourself, CodeSmith might be stable, but is it faster with the new release. The answer to that question is YES. We have spent a great deal of time focusing on Template Caching to ensure you never need to recompile a template unless a change has taken place. We have also introduced a new feature we call deep load. Deep loading allows us to grab all your schema information in advance so we don&amp;rsquo;t need to make multiple round trips back to your database. We have also spent time working with performance and memory profilers tweaking CodeSmith for optimal performance. If you come across a scenario where you think CodeSmith is slow, please let us know by submitting a bug report. &lt;br /&gt;&lt;br /&gt;We have made improvements to the user interface across the board to allow you to know exactly how CodeSmith is working. Take for example, previously when CodeSmith started up you were prompted with a dialog like the following when samples were extracted:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/CodeSmith-Extract-4.x.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;This dialog would freeze CodeSmith, so naturally you would think that CodeSmith had stopped working. We have since changed this to be multithreaded and also display you a progress bar.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/WindowClipping-_2800_6_2900_.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Another major change we have made is to simplify configuration.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/Options.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Can&amp;rsquo;t you tell this dialog was made by a developer ;). Let us know what you think of the new configuration dialog!&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/Options-_2800_2_2900_.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;We love being organized and providing you with all of our samples applications and templates. Below is a comparison between what you would have seen in CodeSmith 4.x and CodeSmith 5.x. Besides adding and updating a lot of the templates. We have now also made it easier to find the template you are looking for.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/Template-Explorer-_2800_2_2900_.png" alt="" /&gt;&lt;img src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/Template-Explorer.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;In CodeSmith 5.1 we have also included the sample applications to most of the Framework Templates. You can find this in the&amp;nbsp; Documents\CodeSmith\Samples\v5.1\Projects\Framework-Samples folder on your computer. &lt;br /&gt;&lt;br /&gt;I hope that if you were a previous user of CodeSmith and you try out the latest version of 5.x you notice these major changes as well as the minor changes like threading enhancements so you can navigate around CodeSmith features much quicker.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=418" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/.Net/default.aspx">.Net</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/User+Interfaces/default.aspx">User Interfaces</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category></item><item><title>CodeSmith CSLA Templates v1.0 released!</title><link>http://windowscoding.com/blogs/blake/archive/2009/07/29/codesmith-csla-templates-v1-0-released.aspx</link><pubDate>Wed, 29 Jul 2009 10:40:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:414</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Over a week ago we released our new CSLA Templates. I highly recommend everyone that uses CSLA to try them out as they will save you a ton of time. Also you&amp;#39;ll notice very quickly that it follows the CSLA best practices and has other features that you have been looking for like a working Data Access Layer (DAL). The best part is that you won&amp;#39;t have to worry about learning something new (the generated code) if you are already familiar with the &lt;a href="http://lhotka.net/"&gt;CSLA Framework&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Noteable features:&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Working data access layer with concurrency support.&lt;/li&gt;
&lt;li&gt;Support for completely overriding the generated rules.&lt;/li&gt;
&lt;li&gt;Generates three partial classes per business object.&lt;/li&gt;
&lt;li&gt;Generates a common business, data and UI layer.&lt;/li&gt;
&lt;li&gt;Quick start.&lt;/li&gt;
&lt;li&gt;Implements all 14 &lt;a href="http://store.lhotka.net/Default.aspx?tabid=1560&amp;amp;ProductID=16&amp;amp;List=1&amp;amp;SortField=ProductName,ProductName"&gt;object types&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Detects and generates properties and child objects for the
following database relationships (One to Zero or One, One to One, One
to Many, Many to One, Many to Many).&lt;/li&gt;
&lt;li&gt;All DateTime data types are generated as Csla.SmartDate&lt;/li&gt;
&lt;li&gt;Correctly handles Binary Database fields (E.G Images, TimeStamp)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="http://codesmith.googlecode.com/files/Csla-v1.0.778.zip"&gt;Download the templates&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codesmith.googlecode.com/files/Csla.PetShop-CSharp-v1.0.777.zip.zip"&gt;Download the PetShop sample application&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=414" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CSLA/default.aspx">CSLA</category></item><item><title>Tips &amp; Tricks: Debugging CodeSmith on Microsoft Windows 7</title><link>http://windowscoding.com/blogs/blake/archive/2009/06/03/tips-amp-tricks-debugging-codesmith-on-microsoft-windows-7.aspx</link><pubDate>Wed, 03 Jun 2009 08:46:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:404</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;We have updated the &lt;a href="http://community.codesmithtools.com/blogs/pwelter/archive/2007/06/09/tips-amp-tricks-debugging.aspx" target="_blank"&gt;Tips &amp;amp; Tricks: Debugging CodeSmith&lt;/a&gt; with the changes needed to debug on Windows7.&lt;/p&gt;
&lt;p&gt;Here is the quick overview of what you need to-do to enable debugging on a Microsoft Windows 7 machine:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Update the Just-In-Time debugger setting &lt;b&gt;DbgJITDebugLaunchSetting&lt;/b&gt;.&amp;nbsp; The setting is found in the registry at [&lt;b&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework&lt;/b&gt;].&amp;nbsp; &lt;/li&gt;
&lt;li&gt;Set the value of &lt;b&gt;DbgJITDebugLaunchSetting &lt;/b&gt;to 2. &lt;/li&gt;
&lt;li&gt;If you are using a 64bit operating system then you must also set the same key (&lt;b&gt;DbgJITDebugLaunchSetting&lt;/b&gt;) in this folder [&lt;b&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework&lt;/b&gt;] to 2. &lt;/li&gt;
&lt;li&gt;If you run into any issues try running CodeSmith Studio and Visual Studio as an administrator.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now when CodeSmith enters a break point you will see something like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/VisualStudioJustInTimeDebugger_5F00_4D240D9D.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="Visual Studio Just-In-Time Debugger" alt="Visual Studio Just-In-Time Debugger" src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/VisualStudioJustInTimeDebugger_5F00_thumb_5F00_103F65FE.png" width="648" border="0" height="367" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Click &lt;b&gt;&lt;i&gt;Yes, debug CodeSmithStudio&lt;/i&gt;&lt;/b&gt; to continue debugging.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=404" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/Tips+_2600_amp_3B00_+Tricks/default.aspx">Tips &amp;amp; Tricks</category></item><item><title>CodeSmith CSLA templates - Part 2: The quick start</title><link>http://windowscoding.com/blogs/blake/archive/2009/05/21/codesmith-csla-templates-part-2-the-quick-start.aspx</link><pubDate>Thu, 21 May 2009 14:00:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:392</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>4</slash:comments><description>&lt;p&gt;In &lt;a href="http://windowscoding.com/blogs/blake/archive/2009/04/24/codesmith-csla-templates-part-1.aspx"&gt;Part 1: The introduction&lt;/a&gt; was an overview of the CodeSmith CSLA templates we are developing at &lt;a href="http://www.codesmithtools.com/"&gt;CodeSmith&lt;/a&gt;. In this post, I am going to go over how to use the CSLA quick start and the new improvements resulting from customer feedback (Keep the feedback 
coming!). &lt;/p&gt;
&lt;p&gt;First launch CodeSmith Studio and under the Frameworks node open CodeSmith.CSLA. The CSLA.NET folder will eventually be going away and replaced with our in house CSLA templates (CodeSmith.CSLA).&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/CodeSmithStudio_5F00_6FC7D014.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="CodeSmith Studio" alt="CodeSmith Studio" src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/CodeSmithStudio_5F00_thumb_5F00_1F55C8D4.png" width="640" border="0" height="417" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There are a couple of folders in the CodeSmith.CSLA folder&lt;/p&gt;
&lt;table cellpadding="2" cellspacing="0"&gt;

&lt;tr&gt;
&lt;td&gt;
&lt;p align="center"&gt;&lt;b&gt;Folder Name&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;p align="center"&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Common&lt;/td&gt;
&lt;td&gt;Contains the supporting CSLA assemblies and the Visual Studio templates to create the project.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CSharp&lt;/td&gt;
&lt;td&gt;Contains the C# templates.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Source&lt;/td&gt;
&lt;td&gt;Contains the source code to the quick start and the API that the templates use.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;VB&lt;/td&gt;
&lt;td&gt;Doesn&amp;rsquo;t exist yet but will contain the VB.NET templates.&lt;/td&gt;
&lt;/tr&gt;

&lt;/table&gt;
&lt;p&gt;Now double click on the quick start template, the property grid should now be populated with the quick start properties.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/CodeSmithStudio4_5F00_4587FC5F.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="CodeSmith Studio (4)" alt="CodeSmith Studio (4)" src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/CodeSmithStudio4_5F00_thumb_5F00_3D803430.png" width="756" border="0" height="638" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Next select &amp;ldquo;&lt;b&gt;&amp;hellip;&lt;/b&gt;&amp;rdquo; button for the &lt;b&gt;Source Database&lt;/b&gt; property and select your database you wish to generate against. In this example I will select the PetShop database. The quick start will now populate the property grid most common settings. From here configure the settings to your liking and click generate. Microsoft Visual Studio should now launch unless you set &lt;b&gt;Launch Visual Studio&lt;/b&gt; property to &lt;b&gt;false&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/PetShopMicrosoftVisualStudioAdministrator_5F00_7505CF51.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="PetShop - Microsoft Visual Studio (Administrator)" alt="PetShop - Microsoft Visual Studio (Administrator)" src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/PetShopMicrosoftVisualStudioAdministrator_5F00_thumb_5F00_4206191D.png" width="756" border="0" height="634" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Next right click the PetShop.UI project and select Set as Startup Project&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/PetShopMicrosoftVisualStudioAdministrator3_5F00_2FF9D590.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="PetShop - Microsoft Visual Studio (Administrator) (3)" alt="PetShop - Microsoft Visual Studio (Administrator) (3)" src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/PetShopMicrosoftVisualStudioAdministrator3_5F00_thumb_5F00_5723F8F8.png" width="756" border="0" height="634" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now when you select build or debug your project will start generating.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/PetShopMicrosoftVisualStudioAdministrator4_5F00_6B7998B6.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;margin-left:0px;border-top:0px;margin-right:0px;border-right:0px;" title="PetShop - Microsoft Visual Studio (Administrator) (4)" alt="PetShop - Microsoft Visual Studio (Administrator) (4)" src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/PetShopMicrosoftVisualStudioAdministrator4_5F00_thumb_5F00_0EE6174F.png" width="229" border="0" height="663" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The UI Project is a place holder project for you to start building your application. So now that you have the general idea on getting up and running quickly with the quick start lets see what it takes to customize the type of each entity. Lets right click the Entities.csp template and select Manage Outputs.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/PetShopMicrosoftVisualStudioAdministrator5_5F00_2518F092.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="PetShop - Microsoft Visual Studio (Administrator) (5)" alt="PetShop - Microsoft Visual Studio (Administrator) (5)" src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/PetShopMicrosoftVisualStudioAdministrator5_5F00_thumb_5F00_43730BAE.png" width="640" border="0" height="443" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;After the manage outputs dialog comes up double click on the Entities.cst item.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/EditOutputEntities.csp2_5F00_421E4D02.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="Edit Output - Entities.csp (2)" alt="Edit Output - Entities.csp (2)" src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/EditOutputEntities.csp2_5F00_thumb_5F00_5456EDF7.png" width="868" border="0" height="741" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Earlier in the CSLA beta we had 14 different outputs instead of one. Now all the settings are in one output (Entities.cst). Say you wanted to change the types of your entities from an EditableRoot to a EditableRootChild object. Just use the familiar table picker and change it. It will check to make sure there is no conflict and that any child lists are populated. For example if you had no entities selected and you added a table to EditiableChild it would look through all the lists and if a list entity was not found it would add the table to the EditableChildList. This makes it extremely easy to configure your Business objects.&lt;/p&gt;
&lt;p&gt;Please give us your feedback on the new CSLA templates!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=392" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CSLA/default.aspx">CSLA</category></item><item><title>A fix for the Microsoft .Net Framework 3.5 SP1 Fatal Execution Error (VS Silent Death Bug).</title><link>http://windowscoding.com/blogs/blake/archive/2009/05/20/a-fix-for-the-microsoft-net-framework-3-5-sp1-fatal-execution-error-vs-silent-death-bug.aspx</link><pubDate>Wed, 20 May 2009 11:00:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:391</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;We released &lt;a href="http://community.codesmithtools.com/blogs/announcements/archive/2009/05/06/codesmith-5-1-now-available.aspx" target="_blank"&gt;CodeSmith 5.1&lt;/a&gt; with the new requirements of the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=AB99342F-5D1A-413D-8319-81DA479AB0D7&amp;amp;displaylang=en" target="_blank"&gt;Microsoft .Net Framework 3.5&lt;/a&gt;. One of our experiences in upgrading to the .Net Framework 3.5 is issues we have run into like our customers reporting Visual Studio disapearing or closing extremely quick when they try to generate code using CodeSmith&amp;#39;s Visual Studio Integration. The following link (&lt;a href="http://blog.huagati.com/res/index.php/2009/02/24/tools-part-11-add-ins-attempting-to-work-around-the-vs-silent-death-bug/" target="_blank"&gt;Tools - Part 11 - Add-ins - Attempting to work around the &amp;ldquo;VS Silent Death&amp;rdquo; bug&lt;/a&gt;) describes this issue in detail. Since his blog content is currently offline I&amp;rsquo;ll quote his content.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;One very annoying and elusive problem that sometimes slam down on VS2008 / .net 3.5 SP1 developers is the &amp;ldquo;VS Silent Death&amp;rdquo; bug. It manifests itself by simply making the Visual Studio IDE &amp;lsquo;disappear&amp;rsquo; at a random point such as when opening a project or when opening a certain type of file in Visual Studio.&lt;/p&gt;
&lt;p&gt;The annoying part is the lack of feedback from VS that leaves many baffled. The VS IDE just &amp;ldquo;disappears&amp;rdquo; without any feedback, although there is always an entry in the Windows event log (app log) for each crash stating something along the lines of &amp;ldquo;&lt;i&gt;.NET Runtime version 2.0.50727.1434 - Fatal Execution Engine Error (79FEC5F0) (80131506)&lt;/i&gt;&amp;rdquo; or &amp;ldquo;&lt;i&gt;.NET Runtime version 2.0.50727.3053 - Fatal Execution Engine Error (7A035E00) (80131506)&lt;/i&gt;&amp;ldquo;.&lt;/p&gt;
&lt;p&gt;The elusive part of the problem is that for some users it happens only on rare occasions, while for others it can occur with relatively high frequency. It can happen for a specific project or solution on one machine while the same project/solution works fine on an identical machine next to it (and vice versa). This makes it tricky to reproduce and troubleshoot &amp;ldquo;on demand&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;A mitigating factor is if any tools or add-ins used reference the .net 3.5 framework, so it can happen more frequently when VS add-ins are installed but also when using certain features in VS2008/.net 3.5 such as asp.net MVC, Entity Framework, Linq-to-SQL, WPF, etc. The fact that third party add-ins are commonly affected has made it easy to put the blame on the add-ins; Microsoft&amp;rsquo;s PowerCommands, Huagati DBML/EDMX Tools, Jetbrains Resharper, Ankh, Gallio, and many other third party add-ins have been affected and sometimes blamed for causing the crashes. So has the WPF designer, L2S designer, MVC libraries etc. However, debugging* and research* points to corrupt NGen images and assembly load problems.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Finally Microsoft wakes up&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;There have been numerous reports* to Microsoft on this issue through Microsoft Connect but despite the reporting party supplying crash dump files for several of the reports they have all been closed with &amp;ldquo;not reproducible&amp;rdquo;. In fact, until very recently I have not found a single acknowledgement from Microsoft of this bug, even when actively pursuing an answer (i.e. asking them directly). A few days ago a Microsoft blogger, Jim Nakashima, wrote in his msdn blog that they have reproduced it when working with MVC in Azure projects and that the CLR team is working on a fix:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/jnak/archive/2009/02/15/potential-crash-in-vs-when-using-the-mvc-rc-on-windows-azure.aspx"&gt;http://blogs.msdn.com/jnak/archive/2009/02/15/potential-crash-in-vs-when-using-the-mvc-rc-on-windows-azure.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Fantastic. Great. Terrific.&lt;/p&gt;
&lt;p&gt;So far there&amp;rsquo;s no &amp;ldquo;official&amp;rdquo; acknowledgement from MSFT of this bug or ETA for a hot fix on &lt;a href="http://msdn.microsoft.com"&gt;msdn.microsoft.com&lt;/a&gt;, or &lt;a href="https://connect.microsoft.com/VisualStudio/Feedback"&gt;connect.microsoft.com&lt;/a&gt;. Not even Microsoft&amp;rsquo;s primary communication channels to the developer community (a.k.a. &lt;a href="http://weblogs.asp.net/scottgu/archive/2009/01/27/asp-net-mvc-1-0-release-candidate-now-available.aspx"&gt;Scottgu&lt;/a&gt; or &lt;a href="http://www.hanselman.com"&gt;Scottha&lt;/a&gt;&amp;rsquo;s blogs) mention the problem except in user comments.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;Update:&lt;/b&gt; Microsoft has a patch, KB963676 that addresses this issue. After installing it on my repro-system it looks promising; I have not yet been able to trigger the &amp;lsquo;VS death&amp;rsquo; after applying the patch. No word (yet) on when it will be publicly available, but I assume that affected parties can request this hot patch through MS Support by referring to the MSKB #.&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;Update 2:&lt;/b&gt; The patch is now available for download from Microsoft connect. See Jim Nakashima&amp;rsquo;s announcement at &lt;a href="http://blogs.msdn.com/jnak/archive/2009/02/26/fix-available-asp-net-mvc-rc-crash-in-a-windows-azure-cloud-service-project.aspx"&gt;http://blogs.msdn.com/jnak/archive/2009/02/26/fix-available-asp-net-mvc-rc-crash-in-a-windows-azure-cloud-service-project.aspx&lt;/a&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Source&amp;nbsp; (&lt;a href="http://blog.huagati.com/res/index.php/2009/02/24/tools-part-11-add-ins-attempting-to-work-around-the-vs-silent-death-bug/" target="_blank"&gt;Tools - Part 11 - Add-ins - Attempting to work around the &amp;ldquo;VS Silent Death&amp;rdquo; bug&lt;/a&gt;).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;The Fix.&lt;/h3&gt;
&lt;p&gt;A current workaround for this issue is to apply the following &lt;a href="https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=16827" target="_blank"&gt;Microsoft patch&lt;/a&gt; and reboot your computer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=391" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/.Net/default.aspx">.Net</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category></item><item><title>How to register a keyboard shortcut (hot key) in a .NET Windows Forms Application.</title><link>http://windowscoding.com/blogs/blake/archive/2009/05/19/how-to-register-a-keyboard-shortcut-hot-key-in-a-net-windows-forms-application.aspx</link><pubDate>Tue, 19 May 2009 15:00:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:390</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;There may come a time when you want to implement some extra features or maybe an Easter egg into your application using keyboard shortcuts. I was recently tasked with creating an Easter egg so we could test some functionality in CodeSmith. After countless searches looking for an elegant solution (I found a few ugly solutions and some nicer ones) I came across Method #3. I’ll First touch on the one I didn’t choose to go with.&lt;/p&gt;  &lt;h3&gt;Method #1&lt;/h3&gt;  &lt;p&gt;The following code block will make an unmanaged call to the user32.dll to register the hotkey. I would never go this approach, but if you were like me and couldn’t find anything in the time frame allotted then you might end up implementing this.&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;First you will need to update your using block.&lt;/p&gt;  &lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;using&lt;/span&gt; System.Runtime.InteropServices;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Then add the following code to your form.&lt;/p&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;/// &amp;lt;summary&amp;gt; The RegisterHotKey function defines a system-wide hot key &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;/// &amp;lt;param name=&amp;quot;hWnd&amp;quot;&amp;gt;Handle to the window that will receive WM_HOTKEY messages&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;/// generated by the hot key.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;/// &amp;lt;param name=&amp;quot;id&amp;quot;&amp;gt;Specifies the identifier of the hot key.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;/// &amp;lt;param name=&amp;quot;fsModifiers&amp;quot;&amp;gt;Specifies keys that must be pressed in combination with the key&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;/// specified by the &amp;#39;virtualKey&amp;#39; parameter in order to generate the WM_HOTKEY message.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;/// &amp;lt;param name=&amp;quot;virtualKey&amp;quot;&amp;gt;Specifies the virtual-key code of the hot key&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if the function succeeds, otherwise &amp;lt;c&amp;gt;false&amp;lt;/c&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#008000;"&gt;/// &amp;lt;seealso cref=&amp;quot;http://msdn.microsoft.com/en-us/library/ms646309(VS.85).aspx&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;[DllImport(&lt;span style="color:#006080;"&gt;&amp;quot;user32.dll&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;[&lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;: MarshalAs(UnmanagedType.Bool)]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;extern&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; RegisterHotKey(IntPtr hWnd, &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; id, &lt;span style="color:#0000ff;"&gt;uint&lt;/span&gt; fsModifiers, &lt;span style="color:#0000ff;"&gt;uint&lt;/span&gt; virtualKey);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;[DllImport(&lt;span style="color:#006080;"&gt;&amp;quot;user32.dll&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;extern&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; UnregisterHotKey(IntPtr hWnd, &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; id);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; MOD_CONTROL = 0x2;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; MOD_SHIFT = 0x4;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; WM_HOTKEY = 0x312;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; keyId;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; RegisterHotKey(Form f, Keys key)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; modifiers = 0;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; ((key &amp;amp; Keys.Control) == Keys.Control)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;       modifiers = modifiers | MOD_CONTROL;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; ((key &amp;amp; Keys.Shift) == Keys.Shift)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;       modifiers = modifiers | MOD_SHIFT;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   Keys k = key &amp;amp; ~Keys.Control &amp;amp; ~Keys.Shift;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   Func&amp;lt;&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;&amp;gt; ff = () =&amp;gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;                       {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;                           keyId = f.GetHashCode();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;                           RegisterHotKey(f.Handle, keyId, (&lt;span style="color:#0000ff;"&gt;uint&lt;/span&gt;) modifiers, (&lt;span style="color:#0000ff;"&gt;uint&lt;/span&gt;) k);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;                           &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;                       };&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (f.InvokeRequired)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;       f.Invoke(ff);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;       ff();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; UnregisterHotKey(Form f)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;try&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;       Func&amp;lt;&lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt;&amp;gt; ff = () =&amp;gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;                           {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;                               UnregisterHotKey(f.Handle, keyId);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;                               &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;                           };&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;       &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (f.InvokeRequired)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;           f.Invoke(ff);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;       &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;           ff();&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;catch&lt;/span&gt; (Exception ex)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;       Debug.WriteLine(ex.ToString());&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; WndProc(&lt;span style="color:#0000ff;"&gt;ref&lt;/span&gt; Message m)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;base&lt;/span&gt;.WndProc(&lt;span style="color:#0000ff;"&gt;ref&lt;/span&gt; m);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (m.Msg == WM_HOTKEY)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;       &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Exception(&lt;span style="color:#006080;"&gt;&amp;quot;You found an Easter Egg.&amp;quot;&lt;/span&gt;);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Then in your Form Load event add the following code.&lt;/p&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;Keys k = Keys.F2 | Keys.Control;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;RegisterHotKey(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;, k);&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;I found this example &lt;a href="http://www.pinvoke.net/default.aspx/user32/RegisterHotKey.html" target="_blank"&gt;here&lt;/a&gt;, Please note that I did some refactoring to it.&lt;/p&gt;

&lt;h3&gt;Method #2&lt;/h3&gt;

&lt;p&gt;I also found this &lt;a href="http://stackoverflow.com/questions/48935/c-using-wpf-and-net-35-how-can-i-register-a-global-hot-key-to-say-ctrlshiftlett" target="_blank"&gt;WPF solution&lt;/a&gt; that I haven’t tried but should work. This looks like the best approach for implementing this functionality in WPF as I have seen people use the first method.&lt;/p&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; WindowMain()&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;{  &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   InitializeComponent();     &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.InputBindings.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; InputBinding(MyAppCommands.SaveAll, &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; KeyGesture(Key.F2, ModifierKeys.Control)););&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   CommandBinding cb = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; CommandBinding(MyAppCommands.SaveAll);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   cb.Executed += SaveAllDocuments;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;   &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.CommandBindings.Add(cb );&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; SaveAllDocuments(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; obSender, ExecutedRoutedEventArgs e)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;h3&gt;Method #3&lt;/h3&gt;

&lt;p&gt;The approach I went I thought was the best way as it is small and elegant piece of code. It is completely safe to implement as it doesn’t have any hooks into native windows dlls. The initial idea came from &lt;a href="http://www.codeguru.com/csharp/.net/net_general/keyboard/article.php/c4639" target="_blank"&gt;here&lt;/a&gt;, to implement this code just place it anywhere in your Form.&lt;/p&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; ProcessCmdKey(&lt;span style="color:#0000ff;"&gt;ref&lt;/span&gt; Message message, Keys keys)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#0000ff;"&gt;switch&lt;/span&gt; (keys)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; Keys.F2 | Keys.Control:&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;            &lt;span style="color:#008000;"&gt;//Process action here.&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;            &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;h3&gt;Method #4&lt;/h3&gt;

&lt;p&gt;A &lt;a href="http://erikej.blogspot.com/" target="_blank"&gt;friend&lt;/a&gt; recently sent me &lt;a href="http://www.syncfusion.com/FAQ/windowsforms/faq_c46c.aspx" target="_blank"&gt;this example&lt;/a&gt; right before publishing this. I have never seen this approach but never the less it is an example of how to implement this functionality.&lt;/p&gt;

&lt;h5&gt;C#&lt;/h5&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; MyMainForm : System.Windows.Forms.Form, IMessageFilter&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;{&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;span style="color:#0000ff;"&gt;const&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; WM_KEYDOWN = 0x100;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;span style="color:#0000ff;"&gt;const&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; WM_KEYUP = 0x101;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; PreFilterMessage(&lt;span style="color:#0000ff;"&gt;ref&lt;/span&gt; Message m)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;          Keys keyCode = (Keys)(&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;)m.WParam &amp;amp; Keys.KeyCode;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;          &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt;(m.Msg == WM_KEYDOWN &amp;amp;&amp;amp; keyCode == Keys.Escape)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;          {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;               Console.WriteLine(&lt;span style="color:#006080;"&gt;&amp;quot;Ignoring Escape...&amp;quot;&lt;/span&gt;);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;               &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;          }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;          &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; MyMainForm_Load(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, System.EventArgs e)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     {&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;          Application.AddMessageFilter(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;);&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     }&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;h5&gt;VB.NET&lt;/h5&gt;

&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;Public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Class&lt;/span&gt; MyMainForm&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;span style="color:#0000ff;"&gt;Inherits&lt;/span&gt; System.Windows.Forms.Form&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;span style="color:#0000ff;"&gt;Implements&lt;/span&gt; IMessageFilter&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;span style="color:#0000ff;"&gt;Private&lt;/span&gt; WM_KEYDOWN &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Integer&lt;/span&gt; = &amp;amp;H100&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;span style="color:#0000ff;"&gt;Private&lt;/span&gt; WM_KEYUP &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Integer&lt;/span&gt; = &amp;amp;H101&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;span style="color:#0000ff;"&gt;Public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Function&lt;/span&gt; PreFilterMessage(&lt;span style="color:#0000ff;"&gt;ByRef&lt;/span&gt; m &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; Message) &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;          &lt;span style="color:#0000ff;"&gt;Dim&lt;/span&gt; keyCode &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; Keys = &lt;span style="color:#0000ff;"&gt;CType&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;CInt&lt;/span&gt;(m.WParam), Keys) &lt;span style="color:#0000ff;"&gt;And&lt;/span&gt; Keys.KeyCode&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;          &lt;span style="color:#0000ff;"&gt;If&lt;/span&gt; m.Msg = WM_KEYDOWN &lt;span style="color:#0000ff;"&gt;And&lt;/span&gt; keyCode = Keys.Escape &lt;span style="color:#0000ff;"&gt;Then&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;               Console.WriteLine(&lt;span style="color:#006080;"&gt;&amp;quot;Ignoring Escape...&amp;quot;&lt;/span&gt;)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;               &lt;span style="color:#0000ff;"&gt;Return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;True&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;          &lt;span style="color:#0000ff;"&gt;End&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;If&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;          &lt;span style="color:#0000ff;"&gt;Return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;False&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;span style="color:#0000ff;"&gt;End&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Function&lt;/span&gt; &lt;span style="color:#008000;"&gt;&amp;#39;PreFilterMessage&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;span style="color:#0000ff;"&gt;Private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Sub&lt;/span&gt; MyMainForm_Load(sender &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Object&lt;/span&gt;, e &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; System.EventArgs)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;          Application.AddMessageFilter(&lt;span style="color:#0000ff;"&gt;Me&lt;/span&gt;)&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;span style="color:#0000ff;"&gt;End&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Sub&lt;/span&gt; &lt;span style="color:#008000;"&gt;&amp;#39;MyMainForm_Load&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;End&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Class&lt;/span&gt; &amp;#39;MyMainForm&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Please let me know if you find any issues in the sample code above.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=390" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/.Net/default.aspx">.Net</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/VB.Net/default.aspx">VB.Net</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/WPF/default.aspx">WPF</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/how-to/default.aspx">how-to</category></item><item><title>How to clear cached contacts from Microsoft Outlook.</title><link>http://windowscoding.com/blogs/blake/archive/2009/05/18/how-to-clear-cached-contacts-from-microsoft-outlook.aspx</link><pubDate>Mon, 18 May 2009 17:00:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:389</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;A long time ago we needed a script to remove the cached contacts in Microsoft Outlook. After some research we found that these were stored in a NK2 file in the user profile directory. To run the script please close Outlook and create a new batch file (text file with the extension of .bat), or download the file below. &lt;b&gt;Please not this will create a backup of the NK2 file so everything can be reverted.&lt;/b&gt;&lt;/p&gt;
&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
&lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;@ECHO off&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;nbsp;&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;TITLE Clear the nickname automatic completion caches &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Outlook&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;CLS&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;nbsp;&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;ECHO Clearing the nickname automatic completion caches &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; OutLook...&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;ECHO Created by Blake Niemyjski (http://windowscoding.com)&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;ECHO.&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;nbsp;&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;CD %userprofile%\Application Data\Microsoft\Outlook&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;nbsp;&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;RENAME *.NK2 *.NK2.BAK&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;nbsp;&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;ECHO.&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;ECHO The operation has now completed.&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;ECHO.&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;nbsp;&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;PAUSE&lt;/pre&gt;

&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;EXIT&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Download is attached to this post.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=389" width="1" height="1"&gt;</description><enclosure url="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Components.PostAttachments/00.00.00.03.89/ResetCache.zip" length="360" type="application/zip" /><category domain="http://windowscoding.com/blogs/blake/archive/tags/Office+2007/default.aspx">Office 2007</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/Batch/default.aspx">Batch</category></item><item><title>Microsoft Visual Studio 2010 Beta 1 is coming to MSDN on May 18th.</title><link>http://windowscoding.com/blogs/blake/archive/2009/05/15/microsoft-visual-studio-2010-beta-1-is-coming-to-msdn-on-may-18th.aspx</link><pubDate>Fri, 15 May 2009 12:24:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:388</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;So far I have been very impressed with the CTP builds of &lt;a href="http://www.microsoft.com/australia/visualstudio/products/2010/default.mspx" target="_blank"&gt;Visual studio 2010&lt;/a&gt;. There are some really welcoming changes that are apart of Visual Studio 2010 like UI Unit tests and a completely new IDE written in WPF. The only area where I thought was lacking was the responsiveness of the application. Last night a few &lt;a href="http://blogs.msdn.com/jasonz/" target="_blank"&gt;members&lt;/a&gt; of the Visual Studio team announced that one of there main goals for Beta 1 and RTM is on Performance. I am very excited to hear this. &lt;/p&gt;
&lt;p&gt;&amp;quot;During these last weeks we&amp;rsquo;ve made a lot of progress, I&amp;rsquo;m sure you&amp;rsquo;re going to feel the product is a lot snappier than the builds we provided at the PDC. But of course I&amp;rsquo;m never satisfied &amp;ndash; there are even more wins coming later. I worked with many different teams to help us with our startup, with UI transitions, with memory usage, with threading issues &amp;ndash; especially with how WPF and our main thread synchronize&amp;rdquo; &lt;a href="http://blogs.msdn.com/ricom/archive/2009/05/14/visual-studio-working-on-performance.aspx" target="_blank"&gt;Rico Mariani&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/dannawi/archive/2009/05/15/visual-studio-2010-beta-1-available-for-the-msdn-subscribers-on-monday-may-18th.aspx" target="_blank"&gt;Jihad Dannawi&lt;/a&gt; from Microsoft Australia reports that MSDN will have the latest bits of Visual Studio 2010 on May 18th, So keep an eye open.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;MSDN download &lt;a href="http://msdn.microsoft.com/subscriptions/downloads/default.aspx?pv=18:370"&gt;Link&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=388" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category></item><item><title>How to protect your Community Server site from spammers</title><link>http://windowscoding.com/blogs/blake/archive/2009/05/14/how-to-protect-your-community-server-site-from-spammers.aspx</link><pubDate>Thu, 14 May 2009 15:00:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:383</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>4</slash:comments><description>&lt;p&gt;One should always be aware that your site could be attacked by spam bots if you don’t take the proper precautions. The easiest and quickest way to help prevent 500+ spam users from joining your site is to configure the default options to make it harder for spam bots to create accounts. Please note that this can also reduce the number of registrations on your site due to the extra steps it takes to register.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Navigate to the &lt;b&gt;Account Settings&lt;/b&gt; tab in the control panel (/controlpanel/membership/AccountSettings.aspx). &lt;/li&gt;    &lt;li&gt;In the &lt;b&gt;Registration Settings&lt;/b&gt; tab Set &lt;b&gt;Account Activation&lt;/b&gt; to &lt;b&gt;Email&lt;/b&gt;.&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/EmailSettings_5F00_2D6AABFB.png"&gt;&lt;img style="border-right-width:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto;" title="Email Settings" border="0" alt="Email Settings" src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/EmailSettings_5F00_thumb_5F00_53CC8F46.png" width="292" height="101" /&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;If you have a full time moderator then you can also set &lt;b&gt;New user Moderation Level&lt;/b&gt; to &lt;b&gt;&lt;i&gt;User is Moderated.&lt;/i&gt;&lt;/b&gt; &lt;/li&gt;    &lt;li&gt;Navigate to the &lt;b&gt;Post Settings&lt;/b&gt; in the control panel (/controlpanel/Settings/AdvancedConfiguration.aspx). &lt;/li&gt;    &lt;li&gt;Make sure &lt;b&gt;Enable Anonymous Posting&lt;/b&gt; is set to &lt;b&gt;No&lt;/b&gt;. &lt;/li&gt;    &lt;li&gt;Navigate to the &lt;b&gt;Username Filters&lt;/b&gt; in the control panel (/controlpanel/tools/UsernameFilter.aspx). &lt;/li&gt;    &lt;li&gt;Add any words you think are necessary, like offensive words. I would also add words of medication, payment or buying keywords, and health. &lt;/li&gt;    &lt;li&gt;Navigate to the &lt;b&gt;Manage Spam Blocker&lt;/b&gt; in the control panel (controlpanel/tools/ManageSpamRules.aspx). &lt;/li&gt;    &lt;li&gt;Enable &lt;strong&gt;User Creation IP Frequency&lt;/strong&gt; and configure the minutes to be 1440. This will stop all the spammers from joining from the same IP.&lt;/li&gt;    &lt;li&gt;Enable any rules you think would benefit your community. &lt;/li&gt;    &lt;li&gt;Click Save.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;If you came to this article because you already had your site taken over by spam users created by bots, then continue reading.&lt;i&gt;&lt;b&gt; Please note: before continuing please create a database backup and continue at your own risk. I am not liable for any harm that comes to your database or community after running the following query.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Navigate to &lt;b&gt;Manage Users&lt;/b&gt; in the control panel (controlpanel/membership/membersearch.aspx?SelectedNavItem=BrowseMembers). &lt;/li&gt;    &lt;li&gt;Next if you know the email address of the spam account in question then enter *aspamdomain.com (replacing the domain name with the email domain in question). Now if this returns only the spam accounts in question continue, otherwise you will need to modify the search criteria until you see the list of spam accounts. &lt;/li&gt;    &lt;li&gt;Open &lt;b&gt;SQL Server Management Studio &lt;/b&gt;and connect to your community server database. &lt;/li&gt;    &lt;li&gt;Now backup your community server database. Here is a &lt;a href="http://msdn.microsoft.com/en-us/library/ms187510.aspx" target="_blank"&gt;how to guide&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;Run the following query and make sure it returns the list of user accounts you want to remove.&amp;#160; You may need to update this query and change the domain name from step 2.      &lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;       &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;         &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;SELECT&lt;/span&gt; * &lt;span style="color:#0000ff;"&gt;FROM&lt;/span&gt; cs_users &lt;span style="color:#0000ff;"&gt;WHERE&lt;/span&gt; Email &lt;span style="color:#0000ff;"&gt;LIKE&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;#39;%@aspamdomain.com&amp;#39;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;If you notice that you had a bunch of users join your site all from a certain domain then this TSQL script will work for you out of the box. Also if your spam bots have created posts, you may want to create a new user of which you want to assign the spam posts to. All you need to do is to create a new user account and change line 18 from Anonymous to the case sensitive user name you created.&amp;#160; I modified the following &lt;a href="http://weblogs.asp.net/jgalloway/archive/2006/04/12/442618.aspx" target="_blank"&gt;query&lt;/a&gt; quite a bit to fit this scenario. &lt;b&gt;Please note: you will need to update line 10 to match the like query in step 5 and also change the domain name.&lt;/b&gt; 

    &lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
      &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;declare&lt;/span&gt; @&lt;span style="color:#0000ff;"&gt;Proc&lt;/span&gt; nvarchar(50)&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;declare&lt;/span&gt; @RowCnt &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;declare&lt;/span&gt; @MaxRows &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;declare&lt;/span&gt; @ExecSql nvarchar(255)&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;declare&lt;/span&gt; @user_id &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;select&lt;/span&gt; @RowCnt = 1&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   9:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;declare&lt;/span&gt; @Import &lt;span style="color:#0000ff;"&gt;table&lt;/span&gt; (rownum &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;IDENTITY&lt;/span&gt; (1, 1) &lt;span style="color:#0000ff;"&gt;Primary&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;key&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;NOT&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;NULL&lt;/span&gt; , UserID &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;NOT&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;NULL&lt;/span&gt;)&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  10:&lt;/span&gt; insert &lt;span style="color:#0000ff;"&gt;into&lt;/span&gt; @Import (UserID) &lt;span style="color:#0000ff;"&gt;select&lt;/span&gt; UserID &lt;span style="color:#0000ff;"&gt;from&lt;/span&gt; cs_users &lt;span style="color:#0000ff;"&gt;where&lt;/span&gt; Email &lt;span style="color:#0000ff;"&gt;like&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;#39;%@aspamdomain.com&amp;#39;&lt;/span&gt;&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  11:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  12:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;select&lt;/span&gt; @MaxRows = &lt;span style="color:#0000ff;"&gt;count&lt;/span&gt;(*) &lt;span style="color:#0000ff;"&gt;from&lt;/span&gt; @Import&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  13:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  14:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;while&lt;/span&gt; @RowCnt &amp;lt;= @MaxRows&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  15:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;begin&lt;/span&gt;&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  16:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;select&lt;/span&gt; @user_id = UserID &lt;span style="color:#0000ff;"&gt;from&lt;/span&gt; @Import &lt;span style="color:#0000ff;"&gt;where&lt;/span&gt; rownum = @RowCnt&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  17:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  18:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;execute&lt;/span&gt; [dbo].[cs_User_Delete] @user_id, &lt;span style="color:#006080;"&gt;&amp;#39;Anonymous&amp;#39;&lt;/span&gt;&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  19:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  20:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;Set&lt;/span&gt; @RowCnt = @RowCnt + 1&lt;/pre&gt;


        &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  21:&lt;/span&gt; end&lt;/pre&gt;
&lt;/div&gt;
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;Go back and run the query from step 5, If it returns no results then all the spam accounts have been removed. &lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=383" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/SQL+Server+2005/default.aspx">SQL Server 2005</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/how-to/default.aspx">how-to</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/Community+Server/default.aspx">Community Server</category></item><item><title>How to protect your Community Server site from rouge spiders with a robots text file.</title><link>http://windowscoding.com/blogs/blake/archive/2009/05/13/How-to-protect-your-Community-Server-site-from-rouge-spiders-with-a-robots-text-file.aspx</link><pubDate>Wed, 13 May 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:382</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Over the course of the past two years, I have worked on a number of Community Server sites. The goal of these tips are to share useful information about Telligent&amp;#39;s Community Server platform. There are a few ways you can protect yourself from rouge search bots from stealing your content and bringing down your site.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;The easiest way is to setup a robots text file, which will tell search engines to ignore certain files or directories. I found this &lt;a href="http://www.thesitewizard.com/archive/robotstxt.shtml" target="_blank"&gt;guide&lt;/a&gt; which was very helpful on setting up a robots.txt file in the root directory of your website. There are a few disadvantages to this approach.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It isn&amp;rsquo;t guaranteed to work. There are companies out there who don&amp;rsquo;t care what safe guards you have setup. They are just concerned with indexing or stealing your content. &lt;/li&gt;
&lt;li&gt;People do list there private directories in the robots file thus opening themselves for making public any documents they think are hidden. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If this doesn&amp;rsquo;t work, and trust me sometimes it doesn&amp;rsquo;t always work as I learned a few months ago, then you need to go to the extra step. If you take a look at your exception log in community server by navigating to (/controlpanel/Tools/Reports/ExceptionsReport.aspx) or by running the following SQL Query:&lt;/p&gt;
&lt;div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;padding-bottom:4px;line-height:12pt;background-color:#f4f4f4;margin:20px 0px 10px;padding-left:4px;width:97.5%;padding-right:4px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;padding-top:4px;" id="codeSnippetWrapper"&gt;
&lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
&lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;SELECT&lt;/span&gt; [Frequency], [IPAddress], [UserAgent], [HttpReferrer], [HttpVerb], [PathAndQuery], [&lt;span style="color:#0000ff;"&gt;Exception&lt;/span&gt;], [ExceptionMessage], [DateLastOccurred] &lt;span style="color:#0000ff;"&gt;FROM&lt;/span&gt; [dbo].[cs_Exceptions] &lt;span style="color:#0000ff;"&gt;ORDER&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;BY&lt;/span&gt; DateLastOccurred &lt;span style="color:#0000ff;"&gt;DESC&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You will see the IP Address and the name of the spider that&amp;#39;s bringing down your site. From here you need to open up Internet Information Services (IIS) Manager. Once open you need to navigate to the site you want to block the IP or IP Range from accessing and then click on &lt;b&gt;IP Address and Domain Restrictions&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/InternetInformationServicesIISManager2_5F00_324438AF.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Internet Information Services (IIS) Manager (2)" alt="Internet Information Services (IIS) Manager (2)" src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/InternetInformationServicesIISManager2_5F00_thumb_5F00_0CAA9581.png" width="612" border="0" height="480" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Next right click and click &lt;b&gt;Add Allow Entry&lt;/b&gt; or &lt;b&gt;Add Deny Entry&lt;/b&gt; and fill in the information.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/AddAllowRestrictionRule_5F00_072BFF10.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Add Allow Restriction Rule" alt="Add Allow Restriction Rule" src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/AddAllowRestrictionRule_5F00_thumb_5F00_05E76631.png" width="480" border="0" height="439" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The spider has now been blocked. I&amp;rsquo;d suggest keeping an eye on this and blocking the IP Range of the spider. The last step is to contact the owner of the spider and ask them to stop. You can get this information by looking up the IP Address through &lt;a href="http://www.networksolutions.com/whois/" target="_blank"&gt;Network Solutions&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=382" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/how-to/default.aspx">how-to</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/Community+Server/default.aspx">Community Server</category></item><item><title>CodeSmith 5.1 Released</title><link>http://windowscoding.com/blogs/blake/archive/2009/05/12/codesmith-5-1-released.aspx</link><pubDate>Wed, 13 May 2009 02:20:48 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:380</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;On May 6th we released CodeSmith 5.1. This update brings in many welcoming changes, to name a few: .netTiers 2.3, PLINQO 3.0. Also CodeSmith and now requires that the .NET 3.5 Framework is installed before CodeSmith installs.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Final&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Updated installer to launch CodeSmith after install. &lt;/li&gt;    &lt;li&gt;Loading a CSP on a new machine with an new connection string will cause TableSchema&amp;#39;s UI to be blank. &lt;/li&gt;    &lt;li&gt;Fixed a bug where removing a data source from Database Explorer wouldn&amp;#39;t permanently remove the data source. &lt;/li&gt;    &lt;li&gt;Fixed a threading error when removing a data source from Database Explorer. &lt;/li&gt;    &lt;li&gt;Fixed a bug where CodeSmith would throw an exception when it couldn&amp;#39;t access the systems registry. &lt;/li&gt;    &lt;li&gt;Fixed a bug where Copy Properties would throw an exception when called on a unsaved template. &lt;/li&gt;    &lt;li&gt;Fixed a bug where the SqlCompactSchemaProvider connection string builder class could corrupted additional connection string options. &lt;/li&gt;    &lt;li&gt;Fixed a bug where the SqlCompactSchemaProvider timestamp/rowversion columns were returning a &amp;quot;rowversion&amp;quot; native type name, should be &amp;quot;timestamp&amp;quot;. &lt;/li&gt;    &lt;li&gt;Added CodeSmith Customer Improvement Program. &lt;/li&gt;    &lt;li&gt;Various other minor changes. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Beta&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Fixed a bug where Generate Outputs would throw an error if a Visual Studio Solution contained a Setup and Deployment project. &lt;/li&gt;    &lt;li&gt;Various minor updates to Visual Studio&amp;#39;s Integration. &lt;/li&gt;    &lt;li&gt;Updated Visual Studio Integration to unlock assemblies after generation. &lt;/li&gt;    &lt;li&gt;Fixed a bug where a CSP in Solution folder causes ERROR: Object reference not set to an instance of an object. &lt;/li&gt;    &lt;li&gt;CodeSmith Studio now requires that .NET 3.5 SP1 to be installed.&amp;#160; &lt;/li&gt;    &lt;li&gt;Fixed a bug where CodeSmith Studio would attempt to save a csp for a unsaved template.&amp;#160; &lt;/li&gt;    &lt;li&gt;Fixed a bug where a NullReferenceException would be thrown when toggling the properties window when no template properties existed. &lt;/li&gt;    &lt;li&gt;Fixed a bug where extracting mapping files could cause an exception. &lt;/li&gt;    &lt;li&gt;Added Widening, Narrowing, Like, Let, CUInt, CULng, CUShort, and Operator to the VB.NET keyword list. &lt;/li&gt;    &lt;li&gt;Added var to the C# keyword list. &lt;/li&gt;    &lt;li&gt;Fixed a bug when using Intellisense and Math. or some variable names would throw an ArgumentOutOfRangeException. &lt;/li&gt;    &lt;li&gt;Updated CodeSmith Options dialog&amp;#39;s. &lt;/li&gt;    &lt;li&gt;Added support to give feedback and send detailed error information from within CodeSmith. &lt;/li&gt;    &lt;li&gt;Updated Menu in CodeSmith Explorer, Users can now view the mapping editor, submit feedback, help, or configure options. &lt;/li&gt;    &lt;li&gt;Updated Manage Outputs and child dialogs to save the window dimensions. &lt;/li&gt;    &lt;li&gt;Added IndexedEnumerable, this is used to smartly enumerate collections and get a IsEven, IsLast, IsFirst property. &lt;/li&gt;    &lt;li&gt;Added Linq Querying support to all SchemaExplorer Collections. &lt;/li&gt;    &lt;li&gt;Added MergeProperty functionality for parsing properties from a CodeTemplate that inherits from an assembly. &lt;/li&gt;    &lt;li&gt;Added Insert Class Merge Strategy. &lt;/li&gt;    &lt;li&gt;Added CodeParser. &lt;/li&gt;    &lt;li&gt;Added support to detect an embedded SDK License. &lt;/li&gt;    &lt;li&gt;CodeSmith Configuration no longer uses xml files. &lt;/li&gt;    &lt;li&gt;Updated the documentation for IDbSchemaProvider and DataObjectBase. &lt;/li&gt;    &lt;li&gt;Fixed a bug in OracleSchemaProvider where AllowDBNull would always be set to true for view columns. &lt;/li&gt;    &lt;li&gt;Fixed a bug in OracleSchemaProvider where the TableSchema.PrimaryKeys collection wasn&amp;#39;t being populated correctly. &lt;/li&gt;    &lt;li&gt;Updated OracleSchemaProvider&amp;#39;s configuration to be configurable via the options dialog. &lt;/li&gt;    &lt;li&gt;Added SQL CLR Support to the SqlSchemaProvider. To see if a command is a CLR procedure check the &amp;quot;CS_IsCLR&amp;quot; extended property. &lt;/li&gt;    &lt;li&gt;Fixed a bug in SQLSchemaProvider where an xml index would be set to null after upgrading a SQL Server 2005 database to SQL Server 2008. &lt;/li&gt;    &lt;li&gt;Fixed a bug in SQLSchemaProvider where the ExtendedData query was missing the PropertyBaseType and Minor columns when querying SQL Server 2000 ExtendedData. &lt;/li&gt;    &lt;li&gt;Added PostgreSQLSchemaProvider, SqlCompactSchemaProvider, SQLiteSchemaProvider, VistaDBSchemaProvider. &lt;/li&gt;    &lt;li&gt;Updated .netTiers to version 2.3 RTM. &lt;/li&gt;    &lt;li&gt;Updated PLINQO to version 3.0. &lt;/li&gt;    &lt;li&gt;Added CSLA Beta templates. &lt;/li&gt;    &lt;li&gt;Various other minor changes. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Please click &lt;a href="http://community.codesmithtools.com/blogs/announcements/archive/2009/05/06/codesmith-5-1-now-available.aspx" target="_blank"&gt;here&lt;/a&gt; for more information.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=380" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category></item><item><title>How to open a mini dump file (mdmp) with WinDbg</title><link>http://windowscoding.com/blogs/blake/archive/2009/05/12/opening-a-mini-dump-file-mdmp-file-with-WinDbg.aspx</link><pubDate>Tue, 12 May 2009 18:41:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:381</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Today I was debugging an issue where Microsoft Visual Studio was closing at random in a Microsoft Visual Studio Package. We narrowed down the issue to a previous Microsoft bug report: &lt;a href="https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=16827" target="_blank"&gt;Fatal Execution Error&lt;/a&gt;. I came to a point where Microsoft Visual Studio was creating a mini dump file. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/MicrosoftVisualStudio2008_5F00_32CB08FC.png"&gt;&lt;img style="border-right-width:0px;display:block;float:none;border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto;" title="Microsoft Visual Studio 2008" alt="Microsoft Visual Studio 2008" src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/MicrosoftVisualStudio2008_5F00_thumb_5F00_1F3DA95B.png" width="461" border="0" height="393" /&gt;&lt;/a&gt; After some quick thinking, I downloaded and installed &lt;a href="http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx" target="_blank"&gt;Debugging Tools for Windows&lt;/a&gt;. I then opened WinDbg and clicked on &amp;ldquo;Open Crash Dump&amp;rdquo; and navigated to the location above.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/WinDbg6.11.0001.404AMD64_5F00_2FD5A449.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="WinDbg6.11.0001.404 AMD64 " alt="WinDbg6.11.0001.404 AMD64 " src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/WinDbg6.11.0001.404AMD64_5F00_thumb_5F00_66EF0C75.png" width="771" border="0" height="573" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Your final result will look something like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/DumpCUsersBlakeAppDataLocalTempWER73C8.tmp.mdmpWinDbg6.11.0001.404AMD64_5F00_3D2B9182.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="Dump CUsersBlakeAppDataLocalTempWER73C8.tmp.mdmp - WinDbg6.11.0001.404 AMD64 " alt="Dump CUsersBlakeAppDataLocalTempWER73C8.tmp.mdmp - WinDbg6.11.0001.404 AMD64 " src="http://windowscoding.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blake/DumpCUsersBlakeAppDataLocalTempWER73C8.tmp.mdmpWinDbg6.11.0001.404AMD64_5F00_thumb_5F00_6B55676F.png" width="887" border="0" height="508" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you are looking for more information on how to analyze a mini dump file or how to tell WinDbg to use a symbol server then continue reading &lt;a href="http://www.microsoft.com/whdc/winlogo/maintain/WER/DebugOCA.mspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=381" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/.Net/default.aspx">.Net</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/how-to/default.aspx">how-to</category></item><item><title>CodeSmith CSLA templates - Part 1: Introduction</title><link>http://windowscoding.com/blogs/blake/archive/2009/04/24/codesmith-csla-templates-part-1.aspx</link><pubDate>Fri, 24 Apr 2009 13:46:00 GMT</pubDate><guid isPermaLink="false">6b5532e6-57ca-4170-9999-8460b2d28065:377</guid><dc:creator>Blake Niemyjski</dc:creator><slash:comments>4</slash:comments><description>&lt;p&gt;I&amp;#39;ve been working on CSLA templates periodically over the past few months at CodeSmith Tools . We have designed the templates from the ground up around the CSLA.NET Framework version 3.6.2. You might be thinking what&amp;#39;s the big deal it&amp;#39;s just another set of CSLA templates. You are mistaken, we have done a lot of research and gathered a lot of feedback. The end result is a streamlined CSLA experience that is highly customizable.&lt;br /&gt;&lt;br /&gt;To start using the CSLA templates just navigate in the Template explorer to CodeSmith.CSLA and open the Quick start template.&amp;nbsp; This will change once the templates have reached Release To Web. From here all you need to do is configure the namespaces and select your data source and click generate. CodeSmith will crunch statistics on your schema and generate a working CSLA solution based on your relationships. We know that this won&amp;#39;t be the default case for many of you but it does give you a great starting point to play with CSLA.&lt;br /&gt;&lt;br /&gt;We have thought a lot about plug ability and generation customization. Each of the 14 template types (Criteria, EditableRoot, EditableRootList...) have been split up into three partial classes. For the simplicity of this walk through I&amp;#39;ll pick a database table called Account, it will have two generated partial classes Generated and DataAccess and another non generated partial class. &lt;br /&gt;&lt;br /&gt;Account will be the name of the class and the name of the file will be Account.cs. The sole purpose of this partial class is to hold any class customizations and custom business rules.&lt;br /&gt;&lt;br /&gt;Account.Generated.cs is the second generated partial class that holds all the properties and factory methods. This has been separated out so there is some separation when it comes to the Data Access portion of the class.&lt;br /&gt;&lt;br /&gt;Account.DataAccess.cs is the third generated partial class and holds the DataAccess implementation for the business object. Currently there are two generation options for the data access: you can generate parameterized SQL or just the method stubs. In the future this will also include Object factory, Linq to SQL, or NHibernate.&lt;br /&gt;&lt;br /&gt;Please stay tuned for more information and documentation on the CSLA templates. Please give us your feedback on what you think of our CSLA templates. We will also be releasing some&amp;nbsp; VB.NET CSLA templates before version 1.0 has been completed.&lt;br /&gt;&lt;br /&gt;Please stay tuned for part two where we go over customizing the templates and template features.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Continue to &lt;a href="http://windowscoding.com/blogs/blake/archive/2009/05/21/codesmith-csla-templates-part-2-the-quick-start.aspx"&gt;Part 2&lt;/a&gt;.&lt;/b&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://windowscoding.com/aggbug.aspx?PostID=377" width="1" height="1"&gt;</description><category domain="http://windowscoding.com/blogs/blake/archive/tags/CodeSmith/default.aspx">CodeSmith</category><category domain="http://windowscoding.com/blogs/blake/archive/tags/CSLA/default.aspx">CSLA</category></item></channel></rss>