Self-Tracking Entities in Silverlight Follow-Up

The following most excellent original post…

http://blogs.msdn.com/b/adonet/archive/2010/05/14/self-tracking-entities-in-silverlight.aspx

…has a really nice example of Self-Tracking Entities in Silverlight.

I am posting a follow-up because I have changed it a bit by extending it, maybe filling-in some blanks, and making it suit my goals.

One really needs to read the original post (linked above) in order to understand the code sample below; so, please read that first.

The code-infront for the Silverlight form is here…

<UserControl x:Class="ProductCatalog.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="600" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

    <Grid x:Name="LayoutRoot" Background="White" Height="300" Width="600" DataContext="{Binding}">
        <ComboBox Height="37" HorizontalAlignment="Left" Margin="12,30,0,0" Name="CategoriesComboBox" VerticalAlignment="Top" Width="267" ItemsSource="{Binding}" DisplayMemberPath="CategoryName" SelectedValuePath="CategoryID" SelectionChanged="CategoriesComboBox_SelectionChanged" />
        <sdk:Label Height="28" HorizontalAlignment="Left" Margin="12,12,0,0" Name="CategorySelectedLabel" VerticalAlignment="Top" Width="267" Content="[NoCategorySelected]" />
        <sdk:Label Height="27" HorizontalAlignment="Left" Margin="13,82,0,0" Name="label2" VerticalAlignment="Top" Width="266" Content="Products" />
        <sdk:DataGrid AutoGenerateColumns="True"  Height="149" HorizontalAlignment="Left" Margin="13,100,0,0" Name="MainGrid" VerticalAlignment="Top" Width="564" ItemsSource="{Binding}" />
        <Button Content="Save" Height="23" HorizontalAlignment="Left" Margin="502,265,0,0" Name="SaveButton" VerticalAlignment="Top" Width="75" Click="SaveButton_Click" />
    </Grid>
</UserControl>

The code-behind for the Silverlight form is here…

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ProductCatalog.ServiceReference;
using ProductCatalog.Web;

namespace ProductCatalog
{
    public partial class MainPage : UserControl
    {
        private ObservableCollection<Category> _catalog;

        public MainPage()
        {
            InitializeComponent();
            CatalogServiceClient service = new CatalogServiceClient();
            service.GetCatalogCompleted += (object s, GetCatalogCompletedEventArgs args) => { this.SetCatalog(args.Result); };
            service.GetCatalogAsync();
        }

        private void SetCatalog(ObservableCollection<Category> newCatalog)
        {
            int selectedIndex = this.CategoriesComboBox.SelectedIndex;
            this._catalog = newCatalog;
            this.CategoriesComboBox.DataContext = this._catalog;
            this.EnsureCategorySelection();
        }

        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                CatalogServiceClient service = new CatalogServiceClient();

                service.UpdateCatalogCompleted += (object s, UpdateCatalogCompletedEventArgs args) =>
                                         {
                                             this.SetCatalog(args.Result);
                                             MessageBox.Show(DateTime.Now.ToString("o") + " -- " + "The catalog saved successfully.");
                                         };

                service.UpdateCatalogAsync(this._catalog);
            }
            catch (Exception ex)
            {
                MessageBox.Show(DateTime.Now.ToString("o") + " -- Error during SaveButton_Click -- " + Environment.NewLine +  ex.ToString());
            }
        }

        private void EnsureCategorySelection()
        {
            if ((this.CategoriesComboBox != null) &&
                (this.CategoriesComboBox.Items != null) &&
                (this.CategoriesComboBox.Items.Count > 0))
            {
                if (this.CategoriesComboBox.SelectedIndex < 0)
                {
                    this.CategoriesComboBox.SelectedIndex = -1;
                    this.CategoriesComboBox.SelectedIndex = 0;
                }
            }
            else
            {
                this.CategorySelectedLabel.Content = "[NoData]";
            }
        }

        private void CategoriesComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                this.EnsureCategorySelection();
                this.CategorySelectedLabel.Content = "SelectedCategoryID='" + this.CategoriesComboBox.SelectedValue.ToString() + "'";
                var myProductList = (this._catalog.Where(c => c.CategoryID == Convert.ToInt32(this.CategoriesComboBox.SelectedValue))).SelectMany(c => c.Products);
                this.MainGrid.DataContext = myProductList;
            }
            catch (Exception ex)
            {
                MessageBox.Show(DateTime.Now.ToString("o") + " -- Error during CategoriesComboBox_SelectionChanged -- " + Environment.NewLine + ex.ToString());
            }
        }
    }
}

HTH.

— Mark Kamoski

How To Post A Presentation To WordPress With Screenr

testing 123

These are steps on how to use www.OpenOffice.org (or Microsoft PowerPoint) and  www.Screenr.com and www.YouTube.com to create a presentation with audio and post it to a www.WordPress.com site…

  1. Hook up the Speaker-Output jack to the Microphone-Input jack.
  2. Create presentation in OpenOffice or PowerPoint.
  3. Open the presentation locally.
  4. Start Screenr and set it to capture full screen but do not press the red record button (in the floating Screenr toolbar) yet.
  5. Start the presentation then quickly press the red record button in the floating Screenr toolbar and let the presentation run to the end.
  6. Stop Screenr.
  7. Post Screenr to YouTube and also download the MP4 file just in case.
  8. Go to the video on YouTube and grab the link in the URL
  9. Go to WordPress, create a new post, look for “add video” icon, choose “from URL”, paste link from YouTube, click “insert in post”.
  10. Save post.
  11. Publish post.
  12. Done.

(Note that you must have a Twitter account which is used by Screenr, to allow you to use Screenr.)

VisualStudio ReBuild Succeeded And Failed At The Same Time

A rebuild operation is reporting both “Build succeeded… Build succeeded” and, at the same time, “Rebuild All: 1 succeeded, 1 failed”, in Visual Studio 2008 Standard, using .NET Framework 3.5, and there seems to be no reason stated in the build output.

All —

Please help.

The DETAILED_BUILD_OUTPUT below from a Web Deployment Project reports both “Build succeeded… Build succeeded” and “Rebuild All: 1 succeeded, 1 failed”.

Why?

I cannot see the error anywhere in the build processing. The setup is simple, one Solution with 2 projects in it– one project is a Web Application Project (containing one ASPX and one ASCX) and the other project is a Web Deployment Project.

What do you think?

Please advise.

DETAILED_BUILD_OUTPUT_BEGIN

—— Rebuild All started: Project: Test.General.WebAppCs1, Configuration: Debug Any CPU ——
Build started 05/26/2010 07:54:42 AM.
Building with tools version “3.5”.
Target _CheckForInvalidConfigurationAndPlatform:
Task “Error” skipped, due to false condition; ( ‘$(_InvalidConfigurationError)’ == ‘true’ ) was evaluated as ( ” == ‘true’ ).
Task “Warning” skipped, due to false condition; ( ‘$(_InvalidConfigurationWarning)’ == ‘true’ ) was evaluated as ( ” == ‘true’ ).
Task “Message”
Configuration=Debug
Done executing task “Message”.
Task “Message”
Platform=AnyCPU
Done executing task “Message”.
Task “Error” skipped, due to false condition; (‘$(OutDir)’ != ” and !HasTrailingSlash(‘$(OutDir)’)) was evaluated as (‘bin\’ != ” and !HasTrailingSlash(‘bin\’)).
Task “Error” skipped, due to false condition; (‘$(BaseIntermediateOutputPath)’ != ” and !HasTrailingSlash(‘$(BaseIntermediateOutputPath)’)) was evaluated as (‘obj\’ != ” and !HasTrailingSlash(‘obj\’)).
Task “Error” skipped, due to false condition; (‘$(IntermediateOutputPath)’ != ” and !HasTrailingSlash(‘$(IntermediateOutputPath)’)) was evaluated as (‘obj\Debug\’ != ” and !HasTrailingSlash(‘obj\Debug\’)).
Target StyleCopForceFullAnalysis:
Task “CreateProperty”
Done executing task “CreateProperty”.
Target BeforeRebuild:
Target BeforeClean:
Target “SplitProjectReferencesByType” skipped, due to false condition; (‘@(ProjectReference)’!=”) was evaluated as (”!=”).
Target _SplitProjectReferencesByFileExistence:
Task “ResolveNonMSBuildProjectOutput” skipped, due to false condition; (‘$(BuildingInsideVisualStudio)’==’true’ and ‘@(NonVCProjectReference)’!=”) was evaluated as (‘true’==’true’ and ”!=”).
Target CleanReferencedProjects:
Task “MSBuild” skipped, due to false condition; (‘$(BuildingInsideVisualStudio)’ != ‘true’ and ‘$(BuildingSolutionFile)’ != ‘true’ and ‘$(BuildProjectReferences)’ == ‘true’ and ‘@(_MSBuildProjectReferenceExistent)’ != ”) was evaluated as (‘true’ != ‘true’ and ” != ‘true’ and ‘true’ == ‘true’ and ” != ”).
Target “UnmanagedUnregistration” skipped, due to false condition; (((‘$(_AssemblyTimestampBeforeCompile)’ != ‘$(_AssemblyTimestampAfterCompile)’ or ‘$(RegisterForComInterop)’ != ‘true’ or ‘$(OutputType)’ != ‘library’) or
(‘$(_AssemblyTimestampBeforeCompile)’ == ”)) and
Exists(‘@(_UnmanagedRegistrationCache)’)) was evaluated as (((” != ” or ” != ‘true’ or ‘Library’ != ‘library’) or
(” == ”)) and
Exists(‘obj\Test.General.WebAppCs1.csproj.UnmanagedRegistration.cache’)).
Target CoreClean:
Task “ReadLinesFromFile”
Done executing task “ReadLinesFromFile”.
Task “FindUnderPath”
Comparison path is “bin\”.
Done executing task “FindUnderPath”.
Task “FindUnderPath”
Comparison path is “obj\Debug\”.
Done executing task “FindUnderPath”.
Task “Delete”
Done executing task “Delete”.
Task “RemoveDuplicates”
Done executing task “RemoveDuplicates”.
Task “MakeDir”
Done executing task “MakeDir”.
Task “WriteLinesToFile”
Done executing task “WriteLinesToFile”.
Target CleanPublishFolder:
Task “RemoveDir” skipped, due to false condition; (‘$(PublishDir)’==’$(OutputPath)app.publish\’ and Exists(‘$(PublishDir)’)) was evaluated as (‘bin\app.publish\’==’bin\app.publish\’ and Exists(‘bin\app.publish\’)).
Target AfterClean:
Target EntityClean:
Task “EntityClean”
Successfully cleaned the output for 0 EDMX files.
Done executing task “EntityClean”.
Target Clean:
Target EntityDeploy:
Task “EntityDeploy”
Processing 0 EDMX files.
Finished processing 0 EDMX files.
Done executing task “EntityDeploy”.
Target BeforeBuild:
Target BuildOnlySettings:
Target GetFrameworkPaths:
Task “GetFrameworkPath”
Done executing task “GetFrameworkPath”.
Task “GetFrameworkSdkPath”
Done executing task “GetFrameworkSdkPath”.
Target PrepareForBuild:
Task “FindAppConfigFile”
Done executing task “FindAppConfigFile”.
Task “MakeDir”
Done executing task “MakeDir”.
Target “PreBuildEvent” skipped, due to false condition; (‘$(PreBuildEvent)’!=”) was evaluated as (”!=”).
Target BeforeResolveReferences:
Target “SplitProjectReferencesByType” skipped, due to false condition; (‘@(ProjectReference)’!=”) was evaluated as (”!=”).
Target “SplitProjectReferencesByType” skipped, due to false condition; (‘@(ProjectReference)’!=”) was evaluated as (”!=”).
Target “_SplitProjectReferencesByFileExistence” skipped. Previously built successfully.
Target ResolveProjectReferences:
Task “MSBuild” skipped, due to false condition; (‘@(NonVCProjectReference)’!=” and (‘$(BuildingSolutionFile)’ == ‘true’ or ‘$(BuildingInsideVisualStudio)’ == ‘true’ or ‘$(BuildProjectReferences)’ != ‘true’) and ‘@(_MSBuildProjectReferenceExistent)’ != ”) was evaluated as (”!=” and (” == ‘true’ or ‘true’ == ‘true’ or ‘true’ != ‘true’) and ” != ”).
Task “MSBuild” skipped, due to false condition; (‘@(NonVCProjectReference)’!=” and ‘$(BuildingInsideVisualStudio)’ != ‘true’ and ‘$(BuildingSolutionFile)’ != ‘true’ and ‘$(BuildProjectReferences)’ == ‘true’ and ‘@(_MSBuildProjectReferenceExistent)’ != ”) was evaluated as (”!=” and ‘true’ != ‘true’ and ” != ‘true’ and ‘true’ == ‘true’ and ” != ”).
Task “MSBuild” skipped, due to false condition; (‘@(NonVCProjectReference)’!=” and ‘$(BuildingProject)’==’true’ and ‘@(_MSBuildProjectReferenceExistent)’!=”) was evaluated as (”!=” and ‘true’==’true’ and ”!=”).
Task “Warning” skipped, due to false condition; (‘@(NonVCProjectReference)’!=” and ‘@(_MSBuildProjectReferenceNonexistent)’!=”) was evaluated as (”!=” and ”!=”).
Target “SplitProjectReferencesByType” skipped, due to false condition; (‘@(ProjectReference)’!=”) was evaluated as (”!=”).
Target ResolveVCProjectReferences:
Task “ResolveNonMSBuildProjectOutput” skipped, due to false condition; (‘$(BuildingInsideVisualStudio)’==’true’ and ‘@(VCProjectReference)’!=”) was evaluated as (‘true’==’true’ and ”!=”).
Task “ResolveVCProjectOutput” skipped, due to false condition; (‘$(BuildingSolutionFile)’==’true’ and ‘@(VCProjectReference)’!=”) was evaluated as (”==’true’ and ”!=”).
Task “Error” skipped, due to false condition; (‘$(BuildingSolutionFile)’!=’true’ and ‘$(BuildingInsideVisualStudio)’!=’true’ and ‘@(VCProjectReference)’!=”) was evaluated as (”!=’true’ and ‘true’!=’true’ and ”!=”).
Target “ResolveNativeReferences” skipped, due to false condition; (‘@(NativeReference)’!=”) was evaluated as (”!=”).
Target “GetFrameworkPaths” skipped. Previously built successfully.
Target GetWinFXPath:
Task “GetWinFXPath”

Microsoft (R) Build Task ‘GetWinFXPath’ Version ‘3.0.6920.1427 built by: SP’.
Copyright (C) Microsoft Corporation 2005. All rights reserved.

Done executing task “GetWinFXPath”.
Target GetReferenceAssemblyPaths:
Target “PrepareForBuild” skipped. Previously built successfully.
Target ResolveAssemblyReferences:
Task “ResolveAssemblyReference”
Assemblies:
System
System.Data
System.Core
System.Data.DataSetExtensions
System.Web.Extensions
System.Xml.Linq
System.Drawing
System.Web
System.Xml
System.Configuration
System.Web.Services
System.EnterpriseServices
System.Web.Mobile
AssemblyFiles:
CandidateAssemblyFiles:
TargetFrameworkDirectories:
C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\,C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0,C:\WINDOWS\Microsoft.NET\Framework\v3.5,C:\WINDOWS\Microsoft.NET\Framework\v3.0,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
InstalledAssemblyTables:
IgnoreInstalledAssemblyTable:
False
SearchPaths:
{CandidateAssemblyFiles}
{HintPathFromItem}
{TargetFrameworkDirectory}
{Registry:Software\Microsoft\.NetFramework,v3.5,AssemblyFoldersEx}
{AssemblyFolders}
{GAC}
{RawFileName}
bin\
AllowedAssemblyExtensions:
.exe
.dll
AllowedRelatedFileExtensions:
.pdb
.xml
AppConfigFile:

AutoUnify:
True
TargetProcessorArchitecture:
x86
StateFile:
obj\Debug\ResolveAssemblyReference.cache
InstalledAssemblySubsetTables:
IgnoreInstalledAssemblySubsetTable:
False
TargetFrameworkSubsets:
FullTargetFrameworkSubsetNames:
Full
No TargetFramework subset exclusion list will be generated. No TargetFrameworkSubsets were provided and no additional subset files were passed in to InstalledAssemblySubsetTables.
Primary reference “System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”.
Resolved file path is “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll”.
Reference found at search path location “{TargetFrameworkDirectory}”.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.exe”, but it didn’t exist.
This reference is not “CopyLocal” because it’s a prerequisite file.
Primary reference “System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”.
Resolved file path is “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll”.
Reference found at search path location “{TargetFrameworkDirectory}”.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Configuration.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Configuration.dll”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Configuration.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Configuration.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Configuration.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Configuration.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Configuration.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Configuration.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Configuration.exe”, but it didn’t exist.
This reference is not “CopyLocal” because it’s a prerequisite file.
Primary reference “System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”.
Resolved file path is “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.Mobile.dll”.
Reference found at search path location “{TargetFrameworkDirectory}”.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Mobile.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Mobile.dll”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Web.Mobile.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Web.Mobile.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Web.Mobile.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Web.Mobile.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Web.Mobile.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Web.Mobile.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.Mobile.exe”, but it didn’t exist.
This reference is not “CopyLocal” because it’s a prerequisite file.
Primary reference “System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”.
Resolved file path is “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll”.
Reference found at search path location “{TargetFrameworkDirectory}”.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.dll”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Data.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Data.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Data.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Data.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Data.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Data.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.exe”, but it didn’t exist.
This reference is not “CopyLocal” because it’s a prerequisite file.
Primary reference “System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”.
Resolved file path is “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll”.
Reference found at search path location “{TargetFrameworkDirectory}”.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.dll”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Web.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Web.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Web.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Web.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Web.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Web.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.exe”, but it didn’t exist.
This reference is not “CopyLocal” because it’s a prerequisite file.
Primary reference “System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”.
Resolved file path is “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll”.
Reference found at search path location “{TargetFrameworkDirectory}”.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.dll”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Xml.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Xml.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Xml.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Xml.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Xml.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Xml.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.exe”, but it didn’t exist.
This reference is not “CopyLocal” because it’s a prerequisite file.
Primary reference “System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”.
Resolved file path is “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll”.
Reference found at search path location “{TargetFrameworkDirectory}”.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.exe”, but it didn’t exist.
This reference is not “CopyLocal” because it’s a prerequisite file.
Primary reference “System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”.
Resolved file path is “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Extensions.dll”.
Reference found at search path location “{TargetFrameworkDirectory}”.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Extensions.exe”, but it didn’t exist.
This reference is not “CopyLocal” because it’s a prerequisite file.
Primary reference “System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”.
Resolved file path is “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.EnterpriseServices.dll”.
Reference found at search path location “{TargetFrameworkDirectory}”.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.EnterpriseServices.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.EnterpriseServices.dll”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.EnterpriseServices.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.EnterpriseServices.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.EnterpriseServices.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.EnterpriseServices.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.EnterpriseServices.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.EnterpriseServices.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.EnterpriseServices.exe”, but it didn’t exist.
This reference is not “CopyLocal” because it’s a prerequisite file.
Primary reference “System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”.
Resolved file path is “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll”.
Reference found at search path location “{TargetFrameworkDirectory}”.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.dll”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.exe”, but it didn’t exist.
This reference is not “CopyLocal” because it’s a prerequisite file.
Primary reference “System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”.
Resolved file path is “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll”.
Reference found at search path location “{TargetFrameworkDirectory}”.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Services.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Services.dll”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Web.Services.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Web.Services.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Web.Services.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Web.Services.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Web.Services.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Web.Services.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.exe”, but it didn’t exist.
This reference is not “CopyLocal” because it’s a prerequisite file.
Primary reference “System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”.
Resolved file path is “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll”.
Reference found at search path location “{TargetFrameworkDirectory}”.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.exe”, but it didn’t exist.
This reference is not “CopyLocal” because it’s in a Frameworks directory.
Primary reference “System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”.
Resolved file path is “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll”.
Reference found at search path location “{TargetFrameworkDirectory}”.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Drawing.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Drawing.dll”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Drawing.exe”, but it didn’t exist.
Considered “C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Drawing.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Drawing.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.5\System.Drawing.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Drawing.exe”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v3.0\System.Drawing.dll”, but it didn’t exist.
Considered “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.exe”, but it didn’t exist.
This reference is not “CopyLocal” because it’s a prerequisite file.
Done executing task “ResolveAssemblyReference”.
Target “ResolveComReferences” skipped, due to false condition; (‘@(COMReference)’!=” or ‘@(COMFileReference)’!=”) was evaluated as (”!=” or ”!=”).
Target AfterResolveReferences:
Target ResolveReferences:
Target “MarkupCompilePass1″ skipped, due to false condition; (‘@(Page)@(ApplicationDefinition)’ != ” ) was evaluated as (” != ” ).
Target AfterMarkupCompilePass1:
Target “MarkupCompilePass2ForMainAssembly” skipped, due to false condition; (‘$(_RequireMCPass2ForMainAssembly)’ == ‘true’ ) was evaluated as (‘false’ == ‘true’ ).
Target FileClassification:
Task “FileClassifier” skipped, due to false condition; (‘@(GeneratedBaml)@(Resource)@(Font)’ != ”) was evaluated as (” != ”).
Task “Message” skipped, due to false condition; (‘$(MSBuildTargetsVerbose)’==’true’) was evaluated as (”==’true’).
Task “Message” skipped, due to false condition; (‘$(MSBuildTargetsVerbose)’==’true’) was evaluated as (”==’true’).
Target “MainResourcesGeneration” skipped, due to false condition; (‘@(MainEmbeddedFiles)’!=”) was evaluated as (”!=”).
Target “AssignWinFXEmbeddedResource” skipped, due to false condition; (‘@(WinFXEmbeddedResource)’ != ”) was evaluated as (” != ”).
Target AssignTargetPaths:
Task “AssignTargetPath”
Done executing task “AssignTargetPath”.
Task “AssignTargetPath”
Done executing task “AssignTargetPath”.
Task “AssignTargetPath”
Done executing task “AssignTargetPath”.
Task “AssignTargetPath”
Done executing task “AssignTargetPath”.
Task “AssignTargetPath” skipped, due to false condition; (‘@(_DeploymentBaseManifestWithTargetPath)’==” and ‘%(None.Extension)’==’.manifest’) was evaluated as (”==” and ‘.assemblyPreLoad’==’.manifest’).
Task “AssignTargetPath” skipped, due to false condition; (‘@(_DeploymentBaseManifestWithTargetPath)’==” and ‘%(None.Extension)’==’.manifest’) was evaluated as (”==” and ‘.snk’==’.manifest’).
Target “AssignTargetPaths” skipped. Previously built successfully.
Target SplitResourcesByCulture:
Task “Warning” skipped, due to false condition; (‘@(ResxWithNoCulture)’!=”) was evaluated as (”!=”).
Task “Warning” skipped, due to false condition; (‘@(ResxWithCulture)’!=”) was evaluated as (”!=”).
Task “Warning” skipped, due to false condition; (‘@(NonResxWithCulture)’!=”) was evaluated as (”!=”).
Task “Warning” skipped, due to false condition; (‘@(NonResxWithNoCulture)’!=”) was evaluated as (”!=”).
Task “AssignCulture”
Done executing task “AssignCulture”.
Target “CreateManifestResourceNames” skipped, due to false condition; (‘@(EmbeddedResource)’ != ”) was evaluated as (” != ”).
Target CreateCustomManifestResourceNames:
Target PrepareResourceNames:
Target “ResolveAssemblyReferences” skipped. Previously built successfully.
Target “SplitResourcesByCulture” skipped. Previously built successfully.
Target BeforeResGen:
Target CoreResGen:
Task “GenerateResource” skipped, due to false condition; ( ‘%(EmbeddedResource.Type)’ == ‘Resx’ and ‘%(EmbeddedResource.GenerateResource)’ != ‘false’) was evaluated as ( ” == ‘Resx’ and ” != ‘false’).
Target AfterResGen:
Target ResGen:
Target “CompileLicxFiles” skipped, due to false condition; (‘@(_LicxFile)’!=”) was evaluated as (”!=”).
Target PrepareRdlFiles:
Task “CreateItem” skipped, due to false condition; (‘%(Extension)’==’.rdlc’) was evaluated as (‘.aspx’==’.rdlc’).
Task “CreateItem” skipped, due to false condition; (‘%(Extension)’==’.rdlc’) was evaluated as (‘.config’==’.rdlc’).
Task “CreateItem” skipped, due to false condition; (‘%(Extension)’==’.rdlc’) was evaluated as (‘.txt’==’.rdlc’).
Task “CreateItem” skipped, due to false condition; (‘%(Extension)’==’.rdlc’) was evaluated as (‘.asax’==’.rdlc’).
Task “CreateItem” skipped, due to false condition; (‘%(Extension)’==’.rdlc’) was evaluated as (‘.PNG’==’.rdlc’).
Target “RunRdlCompiler” skipped, due to false condition; (‘@(RdlFile)’!=”) was evaluated as (”!=”).
Target CompileRdlFiles:
Target PrepareResources:
Target ResolveKeySource:
Task “ResolveKeySource”
Done executing task “ResolveKeySource”.
Target “ResolveReferences” skipped. Previously built successfully.
Target “ResolveKeySource” skipped. Previously built successfully.
Target “ResolveComReferences” skipped, due to false condition; (‘@(COMReference)’!=” or ‘@(COMFileReference)’!=”) was evaluated as (”!=” or ”!=”).
Target “ResolveNativeReferences” skipped, due to false condition; (‘@(NativeReference)’!=”) was evaluated as (”!=”).
Target “_SetExternalWin32ManifestProperties” skipped, due to false condition; (‘$(GenerateClickOnceManifests)’==’true’ or ‘@(NativeReference)’!=” or ‘@(ResolvedIsolatedComModules)’!=”) was evaluated as (”==’true’ or ”!=” or ”!=”).
Target _SetEmbeddedWin32ManifestProperties:
Task “GetFrameworkPath”
Done executing task “GetFrameworkPath”.
Target SetWin32ManifestProperties:
Target _GenerateCompileInputs:
Task “Warning” skipped, due to false condition; (‘@(ManifestResourceWithNoCulture)’!=” and ‘%(ManifestResourceWithNoCulture.EmittedForCompatibilityOnly)’==”) was evaluated as (”!=” and ”==”).
Task “Warning” skipped, due to false condition; (‘@(ManifestNonResxWithNoCultureOnDisk)’!=” and ‘%(ManifestNonResxWithNoCultureOnDisk.EmittedForCompatibilityOnly)’==”) was evaluated as (”!=” and ”==”).
Target BeforeCompile:
Target “_TimeStampBeforeCompile” skipped, due to false condition; (‘$(RunPostBuildEvent)’==’OnOutputUpdated’ or (‘$(RegisterForComInterop)’==’true’ and ‘$(OutputType)’==’library’)) was evaluated as (”==’OnOutputUpdated’ or (”==’true’ and ‘Library’==’library’)).
Target DesignTimeMarkupCompilation:
Task “CallTarget” skipped, due to false condition; (‘$(BuildingProject)’ != ‘true’) was evaluated as (‘true’ != ‘true’).
Target _ComputeNonExistentFileProperty:
Target CoreCompile:
Building target “CoreCompile” completely.
Output file “bin\Test.General.WebAppCs1.xml” does not exist.
Task “Csc”
Command:
C:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /doc:bin\Test.General.WebAppCs1.xml /define:DEBUG;TRACE /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll /reference:”C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll” /reference:”C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll” /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.EnterpriseServices.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll /reference:”C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Extensions.dll” /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.Mobile.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:”C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll” /debug+ /debug:full /keyfile:TestKey.snk /optimize+ /out:obj\Debug\Test.General.WebAppCs1.dll /target:library BuildData.cs Default.aspx.cs Default.aspx.designer.cs ErrorForm.aspx.cs ErrorForm.aspx.designer.cs Global.asax.cs Properties\AssemblyInfo.cs

Compile complete — 0 errors, 0 warnings
Done executing task “Csc”.
Target “_TimeStampAfterCompile” skipped, due to false condition; (‘$(RunPostBuildEvent)’==’OnOutputUpdated’ or (‘$(RegisterForComInterop)’==’true’ and ‘$(OutputType)’==’library’)) was evaluated as (”==’OnOutputUpdated’ or (”==’true’ and ‘Library’==’library’)).
Target AfterCompile:
Target “PrepareResourcesForSatelliteAssemblies” skipped, due to false condition; (‘$(UICulture)’ != ”) was evaluated as (” != ”).
Target “MergeLocalizationDirectives” skipped, due to false condition; (‘@(GeneratedLocalizationFiles)’ !=”) was evaluated as (” !=”).
Target AfterCompileWinFX:
Target _AfterCompileWinFXInternal:
Target Compile:
Target “UnmanagedUnregistration” skipped, due to false condition; (((‘$(_AssemblyTimestampBeforeCompile)’ != ‘$(_AssemblyTimestampAfterCompile)’ or ‘$(RegisterForComInterop)’ != ‘true’ or ‘$(OutputType)’ != ‘library’) or
(‘$(_AssemblyTimestampBeforeCompile)’ == ”)) and
Exists(‘@(_UnmanagedRegistrationCache)’)) was evaluated as (((” != ” or ” != ‘true’ or ‘Library’ != ‘library’) or
(” == ”)) and
Exists(‘obj\Test.General.WebAppCs1.csproj.UnmanagedRegistration.cache’)).
Target “GenerateSerializationAssemblies” skipped, due to false condition; (‘$(_SGenGenerateSerializationAssembliesConfig)’ == ‘On’ or (‘@(WebReferenceUrl)’!=” and ‘$(_SGenGenerateSerializationAssembliesConfig)’ == ‘Auto’)) was evaluated as (‘Off’ == ‘On’ or (”!=” and ‘Off’ == ‘Auto’)).
Target _GenerateSatelliteAssemblyInputs:
Task “Warning” skipped, due to false condition; (‘@(ManifestResourceWithCulture)’!=” and ‘%(ManifestResourceWithCulture.EmittedForCompatibilityOnly)’==”) was evaluated as (”!=” and ”==”).
Task “Warning” skipped, due to false condition; (‘@(ManifestNonResxWithCultureOnDisk)’!=” and ‘%(ManifestNonResxWithCultureOnDisk.EmittedForCompatibilityOnly)’==”) was evaluated as (”!=” and ”==”).
Target “ComputeIntermediateSatelliteAssemblies” skipped, due to false condition; (@(EmbeddedResource->’%(WithCulture)’) != ”) was evaluated as ( != ”).
Target “GenerateSatelliteAssemblies” skipped, due to false condition; (‘@(_SatelliteAssemblyResourceInputs)’ != ”) was evaluated as (” != ”).
Target CreateSatelliteAssemblies:
Target “GenerateManifests” skipped, due to false condition; (‘$(GenerateClickOnceManifests)’==’true’ or ‘@(NativeReference)’!=” or ‘@(ResolvedIsolatedComModules)’!=”) was evaluated as (”==’true’ or ”!=” or ”!=”).
Target GetTargetPath:
Building target “GetTargetPath” completely.
No input files were specified.
Target “ComputeIntermediateSatelliteAssemblies” skipped, due to false condition; (@(EmbeddedResource->’%(WithCulture)’) != ”) was evaluated as ( != ”).
Target _CopyFilesMarkedCopyLocal:
Task “Copy”
Done executing task “Copy”.
Target “AssignTargetPaths” skipped. Previously built successfully.
Target “_SplitProjectReferencesByFileExistence” skipped. Previously built successfully.
Target GetCopyToOutputDirectoryItems:
Task “MSBuild” skipped, due to false condition; (‘@(_MSBuildProjectReferenceExistent)’ != ” and ‘$(_GetChildProjectCopyToOutputDirectoryItems)’ == ‘true’ and ‘%(_MSBuildProjectReferenceExistent.Private)’ != ‘false’) was evaluated as (” != ” and ‘true’ == ‘true’ and ” != ‘false’).
Task “AssignTargetPath”
Done executing task “AssignTargetPath”.
Target “_CopyOutOfDateSourceItemsToOutputDirectory” skipped, due to false condition; ( ‘@(_SourceItemsToCopyToOutputDirectory)’ != ” ) was evaluated as ( ” != ” ).
Target “_CopyOutOfDateSourceItemsToOutputDirectoryAlways” skipped, due to false condition; ( ‘@(_SourceItemsToCopyToOutputDirectoryAlways)’ != ” ) was evaluated as ( ” != ” ).
Target _CopySourceItemsToOutputDirectory:
Target “_CopyAppConfigFile” skipped, due to false condition; ( ‘@(AppConfigWithTargetPath)’ != ” ) was evaluated as ( ” != ” ).
Target “_CopyManifestFiles” skipped, due to false condition; ( ‘$(_DeploymentCopyApplicationManifest)’==’true’ or ‘$(GenerateClickOnceManifests)’==’true’ ) was evaluated as ( ”==’true’ or ”==’true’ ).
Target _CheckForCompileOutputs:
Target “_SGenCheckForOutputs” skipped, due to false condition; (‘$(_SGenGenerateSerializationAssembliesConfig)’ == ‘On’ or (‘@(WebReferenceUrl)’!=” and ‘$(_SGenGenerateSerializationAssembliesConfig)’ == ‘Auto’)) was evaluated as (‘Off’ == ‘On’ or (”!=” and ‘Off’ == ‘Auto’)).
Target CopyFilesToOutputDirectory:
Task “Copy”
Copying file from “obj\Debug\Test.General.WebAppCs1.dll” to “bin\Test.General.WebAppCs1.dll”.
Command:
copy /y “obj\Debug\Test.General.WebAppCs1.dll” “bin\Test.General.WebAppCs1.dll”
Done executing task “Copy”.
Task “Message”
Test.General.WebAppCs1 -> C:\Code\Test\General\Test.General.WebAppCs1\bin\Test.General.WebAppCs1.dll
Done executing task “Message”.
Task “Copy”
Done executing task “Copy”.
Task “Copy” skipped, due to false condition; (‘$(_SGenDllCreated)’==’true’) was evaluated as (‘false’==’true’).
Task “Copy”
Copying file from “obj\Debug\Test.General.WebAppCs1.pdb” to “bin\Test.General.WebAppCs1.pdb”.
Command:
copy /y “obj\Debug\Test.General.WebAppCs1.pdb” “bin\Test.General.WebAppCs1.pdb”
Done executing task “Copy”.
Task “Copy”
Did not copy from file “bin\Test.General.WebAppCs1.xml” to file “bin\Test.General.WebAppCs1.xml” because the “SkipUnchangedFiles” parameter was set to “true” in the project and the files’ sizes and timestamps match.
Done executing task “Copy”.
Task “Copy”
Done executing task “Copy”.
Task “Copy”
Done executing task “Copy”.
Target “_CopyWebApplication” skipped, due to false condition; (‘$(OutDir)’ != ‘$(OutputPath)’) was evaluated as (‘bin\’ != ‘bin\’).
Target _BuiltWebOutputGroupOutput:
Task “CreateItem”
Done executing task “CreateItem”.
Task “CreateItem” skipped, due to false condition; (‘$(OutDir)’ != ‘$(OutputPath)’) was evaluated as (‘bin\’ != ‘bin\’).
Target PrepareForRun:
Target “UnmanagedRegistration” skipped, due to false condition; (‘$(RegisterForComInterop)’==’true’ and ‘$(OutputType)’==’library’) was evaluated as (”==’true’ and ‘Library’==’library’).
Target “_CheckForCompileOutputs” skipped. Previously built successfully.
Target “_SGenCheckForOutputs” skipped, due to false condition; (‘$(_SGenGenerateSerializationAssembliesConfig)’ == ‘On’ or (‘@(WebReferenceUrl)’!=” and ‘$(_SGenGenerateSerializationAssembliesConfig)’ == ‘Auto’)) was evaluated as (‘Off’ == ‘On’ or (”!=” and ‘Off’ == ‘Auto’)).
Target _CleanGetCurrentAndPriorFileWrites:
Task “ReadLinesFromFile”
Done executing task “ReadLinesFromFile”.
Task “ConvertToAbsolutePath”
Done executing task “ConvertToAbsolutePath”.
Task “FindUnderPath”
Comparison path is “C:\Code\Test\General\Test.General.WebAppCs1”.
Done executing task “FindUnderPath”.
Task “FindUnderPath”
Comparison path is “bin\”.
Path “C:\Code\Test\General\Test.General.WebAppCs1\obj\Debug\ResolveAssemblyReference.cache” is outside the comparison path.
Path “C:\Code\Test\General\Test.General.WebAppCs1\obj\Debug\Test.General.WebAppCs1.dll” is outside the comparison path.
Path “C:\Code\Test\General\Test.General.WebAppCs1\bin\Test.General.WebAppCs1.xml” is inside the comparison path.
Path “C:\Code\Test\General\Test.General.WebAppCs1\obj\Debug\Test.General.WebAppCs1.pdb” is outside the comparison path.
Path “C:\Code\Test\General\Test.General.WebAppCs1\bin\Test.General.WebAppCs1.dll” is inside the comparison path.
Path “C:\Code\Test\General\Test.General.WebAppCs1\bin\Test.General.WebAppCs1.pdb” is inside the comparison path.
Path “C:\Code\Test\General\Test.General.WebAppCs1\bin\Test.General.WebAppCs1.xml” is inside the comparison path.
Done executing task “FindUnderPath”.
Task “FindUnderPath”
Comparison path is “obj\Debug\”.
Path “C:\Code\Test\General\Test.General.WebAppCs1\obj\Debug\ResolveAssemblyReference.cache” is inside the comparison path.
Path “C:\Code\Test\General\Test.General.WebAppCs1\obj\Debug\Test.General.WebAppCs1.dll” is inside the comparison path.
Path “C:\Code\Test\General\Test.General.WebAppCs1\bin\Test.General.WebAppCs1.xml” is outside the comparison path.
Path “C:\Code\Test\General\Test.General.WebAppCs1\obj\Debug\Test.General.WebAppCs1.pdb” is inside the comparison path.
Path “C:\Code\Test\General\Test.General.WebAppCs1\bin\Test.General.WebAppCs1.dll” is outside the comparison path.
Path “C:\Code\Test\General\Test.General.WebAppCs1\bin\Test.General.WebAppCs1.pdb” is outside the comparison path.
Path “C:\Code\Test\General\Test.General.WebAppCs1\bin\Test.General.WebAppCs1.xml” is outside the comparison path.
Done executing task “FindUnderPath”.
Task “RemoveDuplicates”
Done executing task “RemoveDuplicates”.
Target IncrementalClean:
Task “FindUnderPath”
Comparison path is “bin\”.
Done executing task “FindUnderPath”.
Task “FindUnderPath”
Comparison path is “obj\Debug\”.
Done executing task “FindUnderPath”.
Task “Delete”
Done executing task “Delete”.
Task “RemoveDuplicates”
Done executing task “RemoveDuplicates”.
Task “WriteLinesToFile”
Done executing task “WriteLinesToFile”.
Target “PostBuildEvent” skipped, due to false condition; (
‘$(PostBuildEvent)’!=”
and
(
‘$(RunPostBuildEvent)’!=’OnOutputUpdated’
or
‘$(_AssemblyTimestampBeforeCompile)’!=’$(_AssemblyTimestampAfterCompile)’
)
) was evaluated as (
”!=”
and
(
”!=’OnOutputUpdated’
or
”!=”
)
).
Target CoreBuild:
Task “CallTarget” skipped, due to false condition; (‘$(UnloadProjectsOnCompletion)’==’true’) was evaluated as (‘false’==’true’).
Task “CallTarget” skipped, due to false condition; (‘$(UnloadProjectsOnCompletion)’==’true’) was evaluated as (‘false’==’true’).
Task “CallTarget” skipped, due to false condition; (‘$(UnloadProjectsOnCompletion)’==’true’) was evaluated as (‘false’==’true’).
Target AfterBuild:
Target StyleCop:
Task “Message”
Forcing full StyleCop reanalysis.
Done executing task “Message”.
Task “CreateItem”
Done executing task “CreateItem”.
Task “Message”
Analyzing BuildData.cs;Default.aspx.cs;Default.aspx.designer.cs;ErrorForm.aspx.cs;ErrorForm.aspx.designer.cs;Global.asax.cs;Properties\AssemblyInfo.cs
Done executing task “Message”.
Task “CreateItem” skipped, due to false condition; ((‘%(Compile.ExcludeFromStyleCop)’ == ‘true’) or (‘%(Compile.ExcludeFromSourceAnalysis)’ == ‘true’)) was evaluated as ((” == ‘true’) or (” == ‘true’)).
Task “Message”
Excluding
Done executing task “Message”.
Task “StyleCopTask”
Pass 1: BuildData.cs…
Pass 1: Default.aspx.cs…
Loaded Analyzer: Documentation Rules…
Loaded Analyzer: Layout Rules…
Loaded Analyzer: Maintainability Rules…
Loaded Analyzer: Naming Rules…
Loaded Analyzer: Ordering Rules…
Loaded Analyzer: Readability Rules…
Loaded Analyzer: Spacing Rules…
Pass 1: Default.aspx.designer.cs…
Pass 1: ErrorForm.aspx.cs…
Pass 1: ErrorForm.aspx.designer.cs…
Pass 1: Global.asax.cs…
Pass 1: AssemblyInfo.cs…
Pass 2: Default.aspx.cs…
Pass 2: Default.aspx.designer.cs…
Skipping Default.aspx.designer.cs…
Pass 2: ErrorForm.aspx.cs…
Pass 2: ErrorForm.aspx.designer.cs…
Skipping ErrorForm.aspx.designer.cs…
No violations encountered
Done executing task “StyleCopTask”.
Task “CreateItem”
Done executing task “CreateItem”.
Task “CreateItem”
Done executing task “CreateItem”.
Target Build:
Building target “Build” completely.
No input files were specified.
Target AfterRebuild:
Target Rebuild:
Building target “Rebuild” completely.
No input files were specified.

Done building project “Test.General.WebAppCs1.csproj”.

Build succeeded.

Time Elapsed 00:00:00.35
—— Rebuild All started: Project: Test.General.WebAppCs1.Deploy, Configuration: Debug Any CPU ——
Build started 05/26/2010 07:54:42 AM.
Building with tools version “3.5”.
Target Clean:
Task “CreateProperty”
Done executing task “CreateProperty”.
Target _PrepareForBuild:
Task “CreateProperty”
Done executing task “CreateProperty”.
Task “CreateProperty”
Done executing task “CreateProperty”.
Task “CreateProperty”
Done executing task “CreateProperty”.
Task “Exec”
Command:
if exist “.\TempBuildDir\” rd /s /q “.\TempBuildDir\”
Done executing task “Exec”.
Target “_SplitProjectReferencesByType” skipped, due to false condition; (‘@(ProjectReference)’!=”) was evaluated as (”!=”).
Target “_PrepareForBuild” skipped. Previously built successfully.
Target GetFrameworkPathAndRedistList:
Task “GetFrameworkPath”
Done executing task “GetFrameworkPath”.
Task “CreateItem”
Done executing task “CreateItem”.
Target _ResolveReferences:
Task “CreateItem”
Done executing task “CreateItem”.
Task “ReadLinesFromFile” skipped, due to false condition; ( ‘%(References_RefreshFile.Identity)’ != ” ) was evaluated as ( ” != ” ).
Task “CombinePath”
Done executing task “CombinePath”.
Task “Copy”
Done executing task “Copy”.
Task “ResolveAssemblyReference” skipped, due to false condition; (Exists(‘%(References.Identity)’)) was evaluated as (Exists(”)).
Task “Copy”
Done executing task “Copy”.
Target “_ResolveProjectReferences” skipped, due to false condition; (‘@(NonVCProjectReference)’!=”) was evaluated as (”!=”).
Target “ResolveAssemblyReferences” skipped, due to false condition; (‘@(Reference)’!=” or ‘@(_ResolvedProjectReferencePaths)’!=”) was evaluated as (”!=” or ”!=”).
Target “_CopyBeforeBuild” skipped, due to false condition; ( ‘$(EnableCopyBeforeBuild)’ == ‘true’ or ‘@(ExcludeFromBuild)’ != ” ) was evaluated as ( ” == ‘true’ or ” != ” ).
Target BeforeBuild:
Target “_PrepareForBuild” skipped. Previously built successfully.
Target AspNetCompiler:
Task “AspNetCompiler”

Command:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v /Test.General.WebAppCs1.csproj -p C:\Code\Test\General\Test.General.WebAppCs1 -f -c -fixednames .\TempBuildDir\ -aptca -keyfile C:\Code\SharedReferencesEx\TeamKey.snk
The “AspNetCompiler” task is using “aspnet_compiler.exe” from “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe”.
Utility to precompile an ASP.NET application
Copyright (C) Microsoft Corporation. All rights reserved.

Done executing task “AspNetCompiler”.
Task “RemoveDir” skipped, due to false condition; (‘$(DeleteAppDataFolder)’ == ‘true’) was evaluated as (” == ‘true’).
Task “CreateItem”
Done executing task “CreateItem”.
Target BeforeMerge:
Target “AspNetMerge” skipped, due to false condition; (‘$(UseMerge)’ == ‘true’) was evaluated as (‘false’ == ‘true’).
Target AfterMerge:
Target CopyToOutputDir:
Task “CreateItem”
Done executing task “CreateItem”.
Task “Exec”
Command:
if exist “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\” rd /s /q “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\”
Done executing task “Exec”.
Task “Exec”
Command:
if not exist “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\” md “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\”
Done executing task “Exec”.
Task “Copy”
Copying file from “.\TempBuildDir\\app_offline.htm.config” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\app_offline.htm.config”.
Command:
copy /y “.\TempBuildDir\\app_offline.htm.config” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\app_offline.htm.config”
Copying file from “.\TempBuildDir\\BuildData.config” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\BuildData.config”.
Command:
copy /y “.\TempBuildDir\\BuildData.config” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\BuildData.config”
Copying file from “.\TempBuildDir\\Default.aspx” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Default.aspx”.
Command:
copy /y “.\TempBuildDir\\Default.aspx” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Default.aspx”
Copying file from “.\TempBuildDir\\ErrorForm.aspx” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\ErrorForm.aspx”.
Command:
copy /y “.\TempBuildDir\\ErrorForm.aspx” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\ErrorForm.aspx”
Copying file from “.\TempBuildDir\\MSSCCPRJ.SCC” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\MSSCCPRJ.SCC”.
Command:
copy /y “.\TempBuildDir\\MSSCCPRJ.SCC” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\MSSCCPRJ.SCC”
Copying file from “.\TempBuildDir\\PrecompiledApp.config” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\PrecompiledApp.config”.
Command:
copy /y “.\TempBuildDir\\PrecompiledApp.config” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\PrecompiledApp.config”
Copying file from “.\TempBuildDir\\ReadMe.config” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\ReadMe.config”.
Command:
copy /y “.\TempBuildDir\\ReadMe.config” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\ReadMe.config”
Copying file from “.\TempBuildDir\\Test.General.WebAppCs1.csproj” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Test.General.WebAppCs1.csproj”.
Command:
copy /y “.\TempBuildDir\\Test.General.WebAppCs1.csproj” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Test.General.WebAppCs1.csproj”
Copying file from “.\TempBuildDir\\Test.General.WebAppCs1.csproj.assemblyPreLoad” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Test.General.WebAppCs1.csproj.assemblyPreLoad”.
Command:
copy /y “.\TempBuildDir\\Test.General.WebAppCs1.csproj.assemblyPreLoad” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Test.General.WebAppCs1.csproj.assemblyPreLoad”
Copying file from “.\TempBuildDir\\Test.General.WebAppCs1.csproj.user” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Test.General.WebAppCs1.csproj.user”.
Command:
copy /y “.\TempBuildDir\\Test.General.WebAppCs1.csproj.user” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Test.General.WebAppCs1.csproj.user”
Copying file from “.\TempBuildDir\\Test.General.WebAppCs1.csproj.vspscc” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Test.General.WebAppCs1.csproj.vspscc”.
Command:
copy /y “.\TempBuildDir\\Test.General.WebAppCs1.csproj.vspscc” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Test.General.WebAppCs1.csproj.vspscc”
Copying file from “.\TempBuildDir\\Test.General.WebAppCs1.Publish.xml” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Test.General.WebAppCs1.Publish.xml”.
Command:
copy /y “.\TempBuildDir\\Test.General.WebAppCs1.Publish.xml” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Test.General.WebAppCs1.Publish.xml”
Copying file from “.\TempBuildDir\\TestKey.snk” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\TestKey.snk”.
Command:
copy /y “.\TempBuildDir\\TestKey.snk” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\TestKey.snk”
Copying file from “.\TempBuildDir\\Web.config” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Web.config”.
Command:
copy /y “.\TempBuildDir\\Web.config” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Web.config”
Done executing task “Copy”.
Task “Copy”
Creating directory “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\App_Data”.
Copying file from “.\TempBuildDir\\App_Data\Test.txt” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\App_Data\Test.txt”.
Command:
copy /y “.\TempBuildDir\\App_Data\Test.txt” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\App_Data\Test.txt”
Done executing task “Copy”.
Task “Copy”
Creating directory “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\bin”.
Copying file from “.\TempBuildDir\\bin\App_global.asax.compiled” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\App_global.asax.compiled”.
Command:
copy /y “.\TempBuildDir\\bin\App_global.asax.compiled” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\App_global.asax.compiled”
Copying file from “.\TempBuildDir\\bin\App_global.asax.dll” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\App_global.asax.dll”.
Command:
copy /y “.\TempBuildDir\\bin\App_global.asax.dll” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\App_global.asax.dll”
Copying file from “.\TempBuildDir\\bin\App_Web_default.aspx.cdcab7d2.dll” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\App_Web_default.aspx.cdcab7d2.dll”.
Command:
copy /y “.\TempBuildDir\\bin\App_Web_default.aspx.cdcab7d2.dll” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\App_Web_default.aspx.cdcab7d2.dll”
Copying file from “.\TempBuildDir\\bin\App_Web_errorform.aspx.cdcab7d2.dll” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\App_Web_errorform.aspx.cdcab7d2.dll”.
Command:
copy /y “.\TempBuildDir\\bin\App_Web_errorform.aspx.cdcab7d2.dll” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\App_Web_errorform.aspx.cdcab7d2.dll”
Copying file from “.\TempBuildDir\\bin\default.aspx.cdcab7d2.compiled” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\default.aspx.cdcab7d2.compiled”.
Command:
copy /y “.\TempBuildDir\\bin\default.aspx.cdcab7d2.compiled” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\default.aspx.cdcab7d2.compiled”
Copying file from “.\TempBuildDir\\bin\errorform.aspx.cdcab7d2.compiled” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\errorform.aspx.cdcab7d2.compiled”.
Command:
copy /y “.\TempBuildDir\\bin\errorform.aspx.cdcab7d2.compiled” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\errorform.aspx.cdcab7d2.compiled”
Copying file from “.\TempBuildDir\\bin\Test.General.WebAppCs1.dll” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\Test.General.WebAppCs1.dll”.
Command:
copy /y “.\TempBuildDir\\bin\Test.General.WebAppCs1.dll” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\Test.General.WebAppCs1.dll”
Copying file from “.\TempBuildDir\\bin\Test.General.WebAppCs1.pdb” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\Test.General.WebAppCs1.pdb”.
Command:
copy /y “.\TempBuildDir\\bin\Test.General.WebAppCs1.pdb” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\Test.General.WebAppCs1.pdb”
Copying file from “.\TempBuildDir\\bin\Test.General.WebAppCs1.xml” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\Test.General.WebAppCs1.xml”.
Command:
copy /y “.\TempBuildDir\\bin\Test.General.WebAppCs1.xml” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\bin\Test.General.WebAppCs1.xml”
Done executing task “Copy”.
Task “Copy”
Creating directory “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\Images”.
Copying file from “.\TempBuildDir\\Images\PublishDialog01.PNG” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Images\PublishDialog01.PNG”.
Command:
copy /y “.\TempBuildDir\\Images\PublishDialog01.PNG” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\Images\PublishDialog01.PNG”
Done executing task “Copy”.
Task “Copy”
Creating directory “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\obj\Debug”.
Copying file from “.\TempBuildDir\\obj\Debug\StyleCopViolations.xml” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\obj\Debug\StyleCopViolations.xml”.
Command:
copy /y “.\TempBuildDir\\obj\Debug\StyleCopViolations.xml” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\obj\Debug\StyleCopViolations.xml”
Copying file from “.\TempBuildDir\\obj\Debug\Test.General.WebAppCs1.csproj.FileListAbsolute.txt” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\obj\Debug\Test.General.WebAppCs1.csproj.FileListAbsolute.txt”.
Command:
copy /y “.\TempBuildDir\\obj\Debug\Test.General.WebAppCs1.csproj.FileListAbsolute.txt” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\obj\Debug\Test.General.WebAppCs1.csproj.FileListAbsolute.txt”
Copying file from “.\TempBuildDir\\obj\Debug\Test.General.WebAppCs1.dll” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\obj\Debug\Test.General.WebAppCs1.dll”.
Command:
copy /y “.\TempBuildDir\\obj\Debug\Test.General.WebAppCs1.dll” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\obj\Debug\Test.General.WebAppCs1.dll”
Copying file from “.\TempBuildDir\\obj\Debug\Test.General.WebAppCs1.pdb” to “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\obj\Debug\Test.General.WebAppCs1.pdb”.
Command:
copy /y “.\TempBuildDir\\obj\Debug\Test.General.WebAppCs1.pdb” “C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\\obj\Debug\Test.General.WebAppCs1.pdb”
Done executing task “Copy”.
Task “Exec”
Command:
if exist “.\TempBuildDir\” rd /s /q “.\TempBuildDir\”
Done executing task “Exec”.
Task “ToggleDebugCompilation”
Updating Web.config element debug attribute to ‘False’.
Successfully updated Web.config element debug attribute to ‘False’.
Done executing task “ToggleDebugCompilation”.
Target “ReplaceWebConfigSections” skipped, due to false condition; (‘$(UseWebConfigReplacement)’ == ‘true’) was evaluated as (‘false’ == ‘true’).
Target CreateVirtualDirectory:
Task “CreateVirtualDirectory”
Initializing IIS Web Server…
Successfully created virtual directory ‘Test.General.WebAppCs1.Publish’.
Done executing task “CreateVirtualDirectory”.
Task “GrantServerAccess”
Granting IIS read access to the folder ‘C:\Code\Deploy\General\Test.General.WebAppCs1.Publish’.
Grant folder access successful.
Done executing task “GrantServerAccess”.
Task “GrantServerAccess”
Granting IIS read/write access to the folder ‘C:\Code\Deploy\General\Test.General.WebAppCs1.Publish\App_Data’.
Grant folder access successful.
Done executing task “GrantServerAccess”.
Target AfterBuild:
Target Rebuild:

Done building project “Test.General.WebAppCs1.Deploy.wdproj”.

Build succeeded.

Time Elapsed 00:00:04.53
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========

DETAILED_BUILD_OUTPUT_END

This matter is also discussed by me at the following link…

http://forums.asp.net/t/1548089.aspx

This matter is also discussed elsewhere on the web, such as at the following link…

http://channel9.msdn.com/forums/TechOff/259614-VS2008-Web-Setup-Project-Build-Fails/

As such, it seems like this may be a bug in VisualStudio 2008 and or MsBuild and or a related environment subsystem.

If you have any way to fix this, then please let me know.

Thank you.

— Mark Kamoski

Find A LinkButton Recursively By Text

If one needs to find a dynamically-generated LinkButton, for example, and if one does not know the ID of the LinkButton, then one may use something like the following…

/// <summary>
/// This will return the 1st LinkButton found that has the given text, searching deep into all contained controls.
/// </summary>
/// <param name="targetRoot">This is the starting control.</param>
/// <param name="targetTextToFind">This is the text to find, not-case-sensitive.</param>
/// <returns>This is the control found or null if the control is not found.</returns>
public static LinkButton FindLinkButtonRecursiveByText(Control targetRoot, string targetTextToFind)
{
	targetTextToFind = (targetTextToFind + "").Trim().ToLower();

	if (targetRoot == null)
	{
		//Hardjump.
		return null;
	}

	if ((targetRoot.GetType() == typeof(System.Web.UI.WebControls.LinkButton)) ||
		(targetRoot.GetType().ToString().Trim().ToLower() == PageHelper.DefaultTypeNameForDataControlLinkButton.Trim().ToLower()))
	{
		LinkButton myLinkButton = (LinkButton)targetRoot;
		string myLinkButtonText = myLinkButton.Text.Trim().ToLower();
		Debug.WriteLine("myLinkButtonText='" + myLinkButtonText + "'");

		if (myLinkButtonText == targetTextToFind)
		{
			return (LinkButton)targetRoot;
		}
	}

	if (targetRoot.Controls != null)
	{
		foreach (Control myControlTemp in targetRoot.Controls)
		{
			//Recursion.
			Control myControlFound = PageHelper.FindLinkButtonRecursiveByText(myControlTemp, targetTextToFind);

			if (myControlFound != null)
			{
				//Hardjump.
				return (LinkButton)myControlFound;
			}
		}
	}

	return null;
}

HTH.

Thank you.

— Mark Kamoski

Find A Control Recursively

This is a helper that can find a control recursively based on an ID.

/// <summary>
/// This will find a control with the given ID if it exists.
/// </summary>
/// <param name="targetRoot">This is the place to start searching.</param>
/// <param name="targetId">This is the ID to find.</param>
/// <returns>This is the control if the ID is found, otherwise it is null.</returns>
/// <remarks>
/// Thanks for this code goes to the following...
/// http://west-wind.com/Weblog/posts/5127.aspx 
/// </remarks>
public static Control FindControlRecursive(Control targetRoot, string targetId)
{
	targetId = (targetId + "").Trim();

	if (targetRoot == null)
	{
		//Hardjump.
		return null;
	}

	if (targetRoot.ID == targetId)
	{
		//Hardjump.
		return targetRoot;
	}

	if (targetRoot.Controls != null)
	{
		foreach (Control myControlTemp in targetRoot.Controls)
		{
			//Recursion.
			Control myControlFound = PageHelper.FindControlRecursive(myControlTemp, targetId);

			if (myControlFound != null)
			{
				//Hardjump.
				return myControlFound;
			}
		}
	}

	return null;
}

HTH.

Thank you.

— Mark Kamoski

XML Serialization Code Sample

Problem
One is writing code an one needs to serialize an object.

Solution
One can use XML-based serialization, (as long as the object is xml-serializable), as shown below.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Xml.XPath;
using System.Xml.Xsl;

namespace Test.Framework.Common.Core
{
	/// <summary>
	/// This is a basic serialization helper.
	/// </summary>
	/// <remarks>
	/// Reference...
	/// http://www.dotnetfunda.com/articles/show/articleShow.aspx?aid=98
	/// </remarks>
	public class SerializationHelper
	{
		#region ConstructorMethods

		public SerializationHelper()
		{

		}

		#endregion //ConstructorMethods

		#region HelperMethods

		/// <summary>
		/// This will deserialize any object that can use xml-based serialization.
		/// </summary>
		/// <param name="targetObject">This is the XML to deserialize.</param>
		/// <param name="targetType">This is type to use for the output.</param>
		/// <returns>This is the object deserialized.</returns>
		/// <remarks>
		/// Note the following RTE message that happens when trying to serialize a DataView...
		/// "To be XML serializable, types which inherit from ICollection must have an implementation of 
		/// Add(System.Data.DataRowView) at all levels of their inheritance hierarchy. 
		/// System.Data.DataView does not implement Add(System.Data.DataRowView)".
		/// </remarks>
		public object DeSerializeAnObject(string xmlOfAnObject, System.Type targetType)
		{
			object myObject = null;

			System.Xml.XmlReader myXmlReader = null;
			System.IO.StringReader myStringReader = null;

			try
			{
				myStringReader = new StringReader(xmlOfAnObject);

				System.Xml.Serialization.XmlSerializer myXmlSerializer =
					new System.Xml.Serialization.XmlSerializer(targetType);

				myXmlReader = new XmlTextReader(myStringReader);
				myObject = new object();
				myObject = (object)myXmlSerializer.Deserialize(myXmlReader);
			}
			catch (Exception ex)
			{
				throw new System.ApplicationException(
					"Exception caught and thrown. ex.ToString()='" + ex.ToString() + "'.");
			}
			finally
			{
				if (myXmlReader != null)
				{
					myXmlReader.Close();
				}

				if (myStringReader != null)
				{
					myStringReader.Close();
					myStringReader.Dispose();
				}
			}

			return myObject;
		}

		/// <summary>
		/// This will serialize any object that can use xml-based serialization.
		/// </summary>
		/// <param name="targetObject">This is the object to serialize.</param>
		/// <returns>This is the object serialized as XML.</returns>
		/// <remarks>
		/// Note the following RTE message that happens when trying to serialize a DataView...
		/// "To be XML serializable, types which inherit from ICollection must have an implementation of 
		/// Add(System.Data.DataRowView) at all levels of their inheritance hierarchy. 
		/// System.Data.DataView does not implement Add(System.Data.DataRowView)".
		/// </remarks>
		public string SerializeObject(object targetObject)
		{
			string myXml = "";

			if (targetObject == null)
			{
				throw new System.ApplicationException("The given object, targetObject, is null.");
			}

			System.IO.MemoryStream myMemoryStream = null;

			try
			{
				myMemoryStream = new System.IO.MemoryStream();

				System.Xml.Serialization.XmlSerializer mySerializer =
					new System.Xml.Serialization.XmlSerializer(targetObject.GetType());

				mySerializer.Serialize(myMemoryStream, targetObject);
				myMemoryStream.Position = 0;
				System.Xml.XmlDocument myXmlDoc = new XmlDocument();
				myXmlDoc.Load(myMemoryStream);
				myXml = myXmlDoc.InnerXml;
			}
			catch (Exception ex)
			{
				throw new System.ApplicationException(
					"Exception caught and thrown. ex.ToString()='" + ex.ToString() + "'.");
			}
			finally
			{
				if (myMemoryStream != null)
				{
					myMemoryStream.Close();
					myMemoryStream.Dispose();
				}
			}

			return myXml;
		}

		#endregion //HelperMethods
	}
}

HTH.

Thank you.

— Mark Kamoski

interface for web service without a web reference

Purpose…

Sometimes one has a project where one must dynamically determine which web service to call.

In a typical VS.NET web site project, a web reference is needed to call such a service– but that web reference, when added in the standard fashion, points to a specific URL (web service) and it the URL for that service is not assigned dynamically.

Well, if one needs to determine the URL for the service to call at run-time, and if a typcial web reference cannot do that, then one must call the web service without a web reference.

It is possible to dynamically get a reference to a service, but how do you know the API for that service?

Simple, make sure the service implements a generic interface.

Voila.

One good answer to this is below.

(Make sure you get the latest version available.)

Version 1…

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Data;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;

namespace Test.Framework.Interfaces.BusinessLayer.BusinessEntities
{
	/// <summary>
	/// This is a shared interface for web services that must conform to a standard API and be called without a web reference.
	/// </summary>
	/// <remarks>
	/// Note that the targetIdList parameters are XML, not delimited lists, so data type can be specified if necessary.
	/// Note that this interface is designed for Fire-And-Forget operations, except where a return is absolutely required.
	/// Note that each method has a unique name to simplify attribute creation in the implementing code.
	/// Note that details concerning how and why one might call a web service in this way are found at the following link...
	/// http://www.codeproject.com/KB/cpp/CallWebServicesDynamic.aspx
	/// </remarks>
	public interface IGenericWebServiceStub
	{
		#region InterfaceMethods

		/// <summary>
		/// This saves the given objects.
		/// </summary>
		/// <param name="targetObjectList">This is a list of zero-to-many objects, such as a DataSet serialized as XML.</param>
		void Create(string targetObjectList);

		/// <summary>
		/// This deletes each object that has an ID in the given list.
		/// </summary>
		/// <param name="targetIdList">This is a list of IDs, such as a DataSet serialized as XML.</param>
		void Delete(string targetIdList);

		/// <summary>
		/// This initializes a new object and returns it, without having saved the object.
		/// </summary>
		/// <returns>This is a list containing exactly-one object, such as a DataSet serialized as XML.</returns>
		string Initialize();

		/// <summary>
		/// This retrieves each object that has an ID in the given list.
		/// </summary>
		/// <param name="targetIdList">This is a list of IDs, such as a DataSet serialized as XML.</param>
		/// <returns>This is a list of zero-to-many objects, such as a DataSet serialized as XML.</returns>
		string Retrieve(string targetIdList);

		/// <summary>
		/// This retrieves all objects.
		/// </summary>
		/// <returns>This is a list of zero-to-many objects, such as a DataSet serialized as XML.</returns>
		string RetrieveAll();

		/// <summary>
		/// This retrieves the count of existing objects.
		/// </summary>
		/// <returns>This is the count of objects in the data store.</returns>
		long RetrieveCount();

		/// <summary>
		/// This executes a run-operation.
		/// </summary>
		void Run();

		/// <summary>
		/// This updates the given objects.
		/// </summary>
		/// <param name="targetObjectList">This is a list of zero-to-many objects, such as a DataSet serialized as XML.</param>
		void Update(string targetObjectList);

		#endregion //InterfaceMethods
	}
}

Version 2…

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Data;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;

namespace Test.Framework.Interfaces.BusinessLayer.BusinessEntities
{
	/// <summary>
	/// This is a generic interface for services called without a web reference.
	/// </summary>
	/// <remarks>
	/// Note that this interface is designed for mainly Fire-And-Forget operations.
	/// Note that each method has a single parameter, to ensure uniform call sites.
	/// Note one implementation takes the same a DataSet serialized as XML as a DTO.
	/// Note one implementation uses BusinessLayer-generated, single-column, Guid, PkIds.
	/// Note details concerning how and why one might call a web service as such here...
	/// http://www.codeproject.com/KB/cpp/CallWebServicesDynamic.aspx
	/// </remarks>
	public interface IGenericService
	{
		/// <summary>
		/// This saves the given objects.
		/// </summary>
		/// <param name="targetData">This is a list of zero-to-many objects.</param>
		void Create(string targetData);

		/// <summary>
		/// This deletes each object that has an ID in the given list.
		/// </summary>
		/// <param name="targetData">This is a list of zero-to-many objects, perhaps with just IDs.</param>
		void Delete(string targetData);

		/// <summary>
		/// This initializes a new object, gives it a PkId, but does not save it.
		/// </summary>
		/// <param name="targetData">This is the data to use, typically not necessary.</param>
		/// <returns>This is a list containing exactly-one object.</returns>
		string Initialize(string targetData);

		/// <summary>
		/// This retrieves zero-to-many objects based on the given data.
		/// </summary>
		/// <param name="targetData">This is a list of zero-to-many objects, perhaps with just IDs.</param>
		/// <returns>This is a list of zero-to-many objects.</returns>
		string Retrieve(string targetData);

		/// <summary>
		/// This updates the given objects.
		/// </summary>
		/// <param name="targetData">This is a list of zero-to-many objects.</param>
		void Update(string targetData);
	}
}

HTH.

Thank you.

— Mark Kamoski

Convert From DataSet To Csv

Purpose

The purpose of this post is to show one way to convert a simple DataSet into CSV format.

Problem

Sometimes, one needs to get a DataSet into CSV, such as for exporting to Excel.

Design

Make something that can take a DataSet (or a DataTable) and return a CSV.

Solution

I created some simple helper methods, with Brute-Force looping, and best-effort CSV conformance.

/// <summary>
/// This will convert the given DataTable to a Csv.
/// </summary>
/// <param name="targetData">This is the data to convert.</param>
/// <returns>This is a Csv list.</returns>
public static string ConvertToCsv(DataTable targetData)
{
	string myCsv = "";

	if (targetData == null)
	{
		throw new System.ApplicationException("The given object, targetData, is null.");
	}

	DataTable myDataTable = targetData.Copy();
	DataSet myDataSet = new DataSet();
	myDataSet.Tables.Add(myDataTable);

	//Call a helper.
	myCsv = Team.Framework.Common.Core.Utility.ConvertToCsv(myDataSet);

	return myCsv;
}

/// <summary>
/// This will convert the given DataSet to a Csv.
/// </summary>
/// <param name="targetData">This is the DataSet to convert, at most 1 DataTable.</param>
/// <returns>This is a Csv list.</returns>
public static string ConvertToCsv(DataSet targetData)
{
	string myCsv = "";

	if (targetData == null)
	{
		throw new System.ApplicationException("The given object, targetData, is null.");
	}

	if (targetData.Tables == null)
	{
		throw new System.ApplicationException("The given object, targetData.Tables, is null.");
	}

	const int DefaultRequiredTableCount = 1;

	if (targetData.Tables.Count != DefaultRequiredTableCount)
	{
		throw new System.ApplicationException("ActualTableCount='" + targetData.Tables.Count.ToString() + 
			"' must equal RequiredTableCount='" + DefaultRequiredTableCount.ToString() + "'.");
	}

	if (targetData.Tables[0] == null)
	{
		throw new System.ApplicationException("The given object, targetData.Tables[0], is null.");
	}

	if (targetData.Tables[0].Columns == null)
	{
		throw new System.ApplicationException("The given object, targetData.Tables[0].Columns, is null.");
	}

	if (targetData.Tables[0].Rows == null)
	{
		throw new System.ApplicationException("The given object, targetData.Tables[0].Rows, is null.");
	}

	//Get a helper.
	StringBuilder myBuilder = new StringBuilder();

	//Add a row in the Csv that contains the columns-names from the DataTable.

	bool isFirst1 = true;

	foreach (DataColumn myColumnTemp1 in targetData.Tables[0].Columns)
	{
		string myValueTemp1 = "";

		if (isFirst1)
		{
			isFirst1 = false;
		}
		else
		{
			myBuilder.Append(",");
		}

		myBuilder.Append("\"");
		myValueTemp1 = myColumnTemp1.ColumnName;
		myValueTemp1 = myValueTemp1.Replace("\"", "\"\"");
		myBuilder.Append(myColumnTemp1.ColumnName);
		myBuilder.Append("\"");
	}

	//Add a row in the Csv for each row in the DataTable.

	foreach (DataRow myRowTemp in targetData.Tables[0].Rows)
	{
		myBuilder.Append(Environment.NewLine);
		bool isFirst2 = true;

		foreach (DataColumn myColumnTemp2 in targetData.Tables[0].Columns)
		{
			string myValueTemp2 = "";

			if (isFirst2)
			{
				isFirst2 = false;
			}
			else
			{
				myBuilder.Append(",");
			}

			myBuilder.Append("\"");

			if ((myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(bool)) ||
				(myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(byte)) ||
				(myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(char)) ||
				(myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(decimal)) ||
				(myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(double)) ||
				(myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(float)) ||
				(myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(int)) ||
				(myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(long)) ||
				(myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(sbyte)) ||
				(myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(short)) ||
				(myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(string)) ||
				(myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(uint)) ||
				(myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(ulong)) ||
				(myRowTemp[myColumnTemp2.ColumnName].GetType() == typeof(ushort)))
			{
				myValueTemp2 = myRowTemp[myColumnTemp2.ColumnName].ToString();
				myValueTemp2 = myValueTemp2.Replace("\"", "\"\"");
			}
			else
			{
				myValueTemp2 = "";
			}

			myBuilder.Append(myValueTemp2);
			myBuilder.Append("\"");
		}
	}

	myCsv = myBuilder.ToString();

	return myCsv;
}

HTH.

Thank you.

— Mark Kamoski

DotNet Export To Word Or Html Code Sample

This is the helper class…


using System;
using System.Text;
using System.Web;

namespace Test.Framework.Common.Core
{
	/// 
	/// This is global utility class that helps with some common Word-based functionality.
	/// 
	public sealed class WordHelper
	{
		#region MemberConsts

		public const int InnerHtmlLengthMin = 0;
		public static readonly int InnerHtmlLengthMax = int.MaxValue;
		public const double DefaultDouble = double.MinValue;
		public const Test.Framework.Common.Core.WordHelper.FileExtension DefaultFileExtension = Test.Framework.Common.Core.WordHelper.FileExtension.DOC;
		public const Test.Framework.Common.Core.WordHelper.PageOrientation DefaultPageOrientation = Test.Framework.Common.Core.WordHelper.PageOrientation.Portrait;
		public const Test.Framework.Common.Core.WordHelper.PageMarginInInches DefaultPageMarginInInches = Test.Framework.Common.Core.WordHelper.PageMarginInInches._0_POINT_5_;

		#endregion //MemberConsts

		#region MemberEnums

		public enum FileExtension
		{
			HTM,
			DOC
		}

		public enum PageOrientation
		{
			Landscape,
			Portrait
		}

		public enum PageMarginInInches
		{
			_0_POINT_5_,
			_1_POINT_0_,
			_1_POINT_5_,
			_2_POINT_0_
		}

		#endregion //MemberEnums

		#region ConversionHelpers

		public static Test.Framework.Common.Core.WordHelper.PageOrientation ConvertToPageOrientationByForce(string targetOrientation)
		{
			Test.Framework.Common.Core.WordHelper.PageOrientation myOrientation = Test.Framework.Common.Core.WordHelper.DefaultPageOrientation;

			try
			{
				targetOrientation = (targetOrientation + "").Trim().ToLower();

				if (targetOrientation == Test.Framework.Common.Core.WordHelper.PageOrientation.Landscape.ToString().ToLower())
				{
					myOrientation = Test.Framework.Common.Core.WordHelper.PageOrientation.Landscape;
				}
				else if (targetOrientation == Test.Framework.Common.Core.WordHelper.PageOrientation.Portrait.ToString().ToLower())
				{
					myOrientation = Test.Framework.Common.Core.WordHelper.PageOrientation.Portrait;
				}
				else
				{
					myOrientation = Test.Framework.Common.Core.WordHelper.DefaultPageOrientation;
				}
			}
			catch 
			{
				myOrientation = Test.Framework.Common.Core.WordHelper.DefaultPageOrientation;
			}

			return myOrientation;
		}

		public static Test.Framework.Common.Core.WordHelper.PageMarginInInches ConvertToPageMarginInInchesByForce(string targetPageMarginInInches)
		{
			Test.Framework.Common.Core.WordHelper.PageMarginInInches myPageMarginInInches = Test.Framework.Common.Core.WordHelper.DefaultPageMarginInInches;

			try
			{
				targetPageMarginInInches = (targetPageMarginInInches + "").Trim().ToLower();
				double myPageMarginInInchesAsDouble = Test.Framework.Common.Core.WordHelper.ConvertToDoubleByForce(targetPageMarginInInches);

				if (myPageMarginInInchesAsDouble == 
					Test.Framework.Common.Core.WordHelper.ConvertToDoubleByForce(Test.Framework.Common.Core.WordHelper.PageMarginInInches._0_POINT_5_))
				{
					myPageMarginInInches = Test.Framework.Common.Core.WordHelper.PageMarginInInches._0_POINT_5_;
				}
				else if (myPageMarginInInchesAsDouble == 
					Test.Framework.Common.Core.WordHelper.ConvertToDoubleByForce(Test.Framework.Common.Core.WordHelper.PageMarginInInches._1_POINT_0_))
				{
					myPageMarginInInches = Test.Framework.Common.Core.WordHelper.PageMarginInInches._1_POINT_0_;
				}
				else if (myPageMarginInInchesAsDouble == 
					Test.Framework.Common.Core.WordHelper.ConvertToDoubleByForce(Test.Framework.Common.Core.WordHelper.PageMarginInInches._1_POINT_5_))
				{
					myPageMarginInInches = Test.Framework.Common.Core.WordHelper.PageMarginInInches._1_POINT_5_;
				}
				else if (myPageMarginInInchesAsDouble == 
					Test.Framework.Common.Core.WordHelper.ConvertToDoubleByForce(Test.Framework.Common.Core.WordHelper.PageMarginInInches._2_POINT_0_))
				{
					myPageMarginInInches = Test.Framework.Common.Core.WordHelper.PageMarginInInches._2_POINT_0_;
				}
				else
				{
					myPageMarginInInches = Test.Framework.Common.Core.WordHelper.DefaultPageMarginInInches;
				}
			}
			catch
			{
				myPageMarginInInches = Test.Framework.Common.Core.WordHelper.DefaultPageMarginInInches;
			}

			return myPageMarginInInches;
		}

		public static double ConvertToDoubleByForce(Test.Framework.Common.Core.WordHelper.PageMarginInInches targetValue)
		{
			double myDouble = Test.Framework.Common.Core.WordHelper.DefaultDouble;

			try
			{
				string myInputAsString = targetValue.ToString().ToLower();
				myInputAsString = myInputAsString.Replace("point", ".");
				myInputAsString = myInputAsString.Replace("_", "");

				//Call a helper.
				myDouble = Test.Framework.Common.Core.WordHelper.ConvertToDoubleByForce(myInputAsString);
			}
			catch
			{
				myDouble = Test.Framework.Common.Core.WordHelper.DefaultDouble;
			}

			return myDouble;
		}

		public static double ConvertToDoubleByForce(string targetValue)
		{
			double myDouble = Test.Framework.Common.Core.WordHelper.DefaultDouble;

			try
			{
				targetValue = (targetValue + "").Trim().ToLower();
				myDouble = Convert.ToDouble(targetValue);
			}
			catch
			{
				myDouble = Test.Framework.Common.Core.WordHelper.DefaultDouble;
			}

			return myDouble;
		}

		#endregion //ConversionHelpers

		#region Helpers

		public static bool IsDouble(string targetText)
		{
			bool isDoubleFlag = false;

			try
			{
				targetText = (targetText + "").Trim().ToLower();
				double myTemp = Convert.ToDouble(targetText);
				isDoubleFlag = true;
			}
			catch
			{
				isDoubleFlag = false;
			}

			return isDoubleFlag;
		}

		private static string GetHtmlPrefix(WordHelper.PageOrientation targetOrientation, WordHelper.PageMarginInInches pageMargins)
		{
			string myPrefix = "";

			StringBuilder myBuilder = new StringBuilder();

			myBuilder.AppendLine(" ");

			myBuilder.AppendLine(" ");
			myBuilder.AppendLine("EXPORT ");
			myBuilder.AppendLine(@" ");
			myBuilder.AppendLine(@" ");
			myBuilder.AppendLine(" ");
			myBuilder.AppendLine(" ");

			myBuilder.AppendLine(" ");
			myBuilder.AppendLine("@page Section1 ");
			myBuilder.AppendLine("{");

			if (targetOrientation == PageOrientation.Portrait)
			{
				myBuilder.AppendLine("    size:8.5in 11.0in;");
			}
			else
			{
				myBuilder.AppendLine("    size:11.0in 8.5in;");
			}

			myBuilder.AppendLine("    mso-page-orientation:" + targetOrientation.ToString() + ";");

			switch (pageMargins)
			{
				case Test.Framework.Common.Core.WordHelper.PageMarginInInches._0_POINT_5_:
					myBuilder.AppendLine("    margin:0.5in 0.5in 0.5in 0.5in;");
					break;
				case Test.Framework.Common.Core.WordHelper.PageMarginInInches._1_POINT_0_:
					myBuilder.AppendLine("    margin:1.0in 1.0in 1.0in 1.0in;");
					break;
				case Test.Framework.Common.Core.WordHelper.PageMarginInInches._1_POINT_5_:
					myBuilder.AppendLine("    margin:1.5in 1.5in 1.5in 1.5in;");
					break;
				case Test.Framework.Common.Core.WordHelper.PageMarginInInches._2_POINT_0_:
					myBuilder.AppendLine("    margin:2.0in 2.0in 2.0in 2.0in;");
					break;
				default:
					myBuilder.AppendLine("    margin:1.0in 1.0in 1.0in 1.0in;");
					break;
			}

			myBuilder.AppendLine("} ");

			myBuilder.AppendLine("div.Section1 ");
			myBuilder.AppendLine("{ ");
			myBuilder.AppendLine("    page: Section1; ");
			myBuilder.AppendLine("} ");

			myBuilder.AppendLine(" ");
			myBuilder.AppendLine(" " );
			myBuilder.AppendLine(" " );
			myBuilder.AppendLine("<div class='Section1'> " );

			myPrefix = myBuilder.ToString();

			return myPrefix;
		}

		public static string GetHtmlBodyCleaned(string targetBody)
		{
			string myBodyCleaned = "";

			myBodyCleaned = (targetBody + "").Trim();

			myBodyCleaned.Replace(@"<br />", @"<br />");
			myBodyCleaned.Replace(@"<br />", @"<br />");
			myBodyCleaned.Replace(@"<p>", @"</p><p>");
			myBodyCleaned.Replace(@"</p>", @"");

			return myBodyCleaned;
		}

		public static string GetHtmlSuffix()
		{
			string mySuffix = "";

			StringBuilder myBuilder = new StringBuilder();
			myBuilder.AppendLine("</div> ");
			myBuilder.AppendLine(" " );
			myBuilder.AppendLine(" ");
			mySuffix = myBuilder.ToString();

			return mySuffix;
		}

		/// 
		/// This will set the client-script-block on the target page.
		/// 
		/// This is the page that contains the data to be exported.
		/// This is the name to use for the client script function.
		/// This is any string that idenfies this script block uniquely on the page.
		/// This is the ClientID of the DIV tag that holds the data that is being exported.
		/// This is the ID of the INPUT tag that holds the InnerHtml that is being exported.
		public static void SetClientScriptBlock(System.Web.UI.Page targetPage, string targetScriptFunctionName, string targetScriptKey, string targetDivTagClientId, string targetInputTagClientId)
		{
			//Validate the given Page.

			if (targetPage == null)
			{
				throw new System.ApplicationException("The given object, targetPage, is null.");
			}

			//Validate the given key for the script-block.

			targetScriptKey = (targetScriptKey + "").Trim();

			if (targetScriptKey.Length <= 0)
			{
				throw new System.ApplicationException("The value targetScriptKey.Length.ToString()='" + targetScriptKey.Length.ToString() + "' is not valid.");
			}

			//Validate the given function name.

			targetScriptFunctionName = (targetScriptFunctionName + "").Trim();

			if (targetScriptFunctionName.Length <= 0)
			{
				throw new System.ApplicationException("The value targetScriptFunctionName.Length.ToString()='" + targetScriptFunctionName.Length.ToString() + "' is not valid.");
			}

			//Validate the given ID for the DivTag.

			targetDivTagClientId = (targetDivTagClientId + "").Trim();

			if (targetDivTagClientId.Length <= 0)
			{
				throw new System.ApplicationException("The value targetDivTagClientId.Length.ToString()='" + targetDivTagClientId.Length.ToString() + "' is not valid.");
			}

			//Validate the given ID for the InputTag.

			targetInputTagClientId = (targetInputTagClientId + "").Trim();

			if (targetInputTagClientId.Length <= 0)
			{
				throw new System.ApplicationException("The value targetInputTagClientId.Length.ToString()='" + targetInputTagClientId.Length.ToString() + "' is not valid.");
			}

			Type myTypeToUse = targetPage.GetType();

			if (!targetPage.ClientScript.IsClientScriptBlockRegistered(myTypeToUse, targetScriptKey))
			{
				string myScriptCode = Test.Framework.Common.Core.WordHelper.GetClientScript(targetScriptFunctionName, targetDivTagClientId, targetInputTagClientId);
				const bool addScriptTagsFlag = false;
				targetPage.ClientScript.RegisterClientScriptBlock(myTypeToUse, targetScriptKey, myScriptCode, addScriptTagsFlag);
			}
		}

		/// 
		/// This will get the client-script-block that is required for the call.
		/// 
		/// This is the name to use for the client script function.
		/// This is the ID of the DIV tag that holds the data that is being exported.
		/// This is the ID of the INPUT tag that holds the InnerHtml that is being exported.
		/// This is the client script.
		public static string GetClientScript(string targetScriptFunctionName, string targetDivTagClientId, string targetInputTagClientId)
		{
			string myScript = "";

			//Validate the given function name.

			targetScriptFunctionName = (targetScriptFunctionName + "").Trim();

			if (targetScriptFunctionName.Length <= 0)
			{
				throw new System.ApplicationException("The value targetScriptFunctionName.Length.ToString()='" + targetScriptFunctionName.Length.ToString() + "' is not valid.");
			}

			//Validate the ID for the DivTag.

			targetDivTagClientId = (targetDivTagClientId + "").Trim();

			if (targetDivTagClientId.Length <= 0)
			{
				throw new System.ApplicationException("The value targetDivTagClientId.Length.ToString()='" + targetDivTagClientId.Length.ToString() + "' is not valid.");
			}

			//Validate the ID for the InputTag.

			targetInputTagClientId = (targetInputTagClientId + "").Trim();

			if (targetInputTagClientId.Length <= 0)
			{
				throw new System.ApplicationException("The value targetInputTagClientId.Length.ToString()='" + targetInputTagClientId.Length.ToString() + "' is not valid.");
			}

			//Get a worker object.
			StringBuilder myBuilder = new StringBuilder();

			//Build the text.

			myBuilder.AppendLine(" ");
			myBuilder.AppendLine("  ");
			myBuilder.AppendLine(" function " + targetScriptFunctionName + "() ");
			myBuilder.AppendLine(" { ");
			myBuilder.AppendLine("     //Get the element DIV that contains the GridView that contains the data. ");
			myBuilder.AppendLine("     var myElementSource = document.getElementById('" + targetDivTagClientId + "'); ");
			myBuilder.AppendLine("     //Get a handle to the element that is the hidden field that will hold the data for export. ");
			myBuilder.AppendLine("     var myElementDestination = document.getElementById('" + targetInputTagClientId + "'); ");
			myBuilder.AppendLine("     //Copy from the the source to the destination. ");
			myBuilder.AppendLine("     myElementDestination.value = myElementSource.innerHTML; ");
			myBuilder.AppendLine(" } ");
			myBuilder.AppendLine("  ");
			myBuilder.AppendLine(" ");

			//Get the text.
			myScript = myBuilder.ToString();

			return myScript;
		}

		public static void ExportToWord(
			System.Web.UI.Page targetPage, 
			string innerHtmlFromDiv, 
			string targetOrientation, 
			string targetMarginInInches, 
			Test.Framework.Common.Core.WordHelper.FileExtension targetExtension)
		{
			Test.Framework.Common.Core.WordHelper.PageOrientation myOrientation = Test.Framework.Common.Core.WordHelper.ConvertToPageOrientationByForce(targetOrientation);
			Test.Framework.Common.Core.WordHelper.PageMarginInInches myMarginInInches = Test.Framework.Common.Core.WordHelper.ConvertToPageMarginInInchesByForce(targetMarginInInches);

			//Call a helper.
			Test.Framework.Common.Core.WordHelper.ExportToWord(targetPage, innerHtmlFromDiv, myOrientation, myMarginInInches, targetExtension);
		}

		/// 
		/// This will export the given innerHtml to a single-worksheet, Word-friendly, HTML file.
		/// 
		/// This is the current page.
		/// This is the InnerHtml from a DIV that holds the data to be exported.
		/// This is the orientation for the output.
		/// This is the margin-size for the output.
		/// This is the extension for the output.
		public static void ExportToWord(
			System.Web.UI.Page targetPage, 
			string innerHtmlFromDiv, 
			Test.Framework.Common.Core.WordHelper.PageOrientation targetOrientation, 
			Test.Framework.Common.Core.WordHelper.PageMarginInInches targetMarginInInches, 
			Test.Framework.Common.Core.WordHelper.FileExtension targetExtension)
		{
			//NOTE: 20080925. This may work with other HTML passed to it (not just InnerHtml from a DIV) but so far it has only been tested with InnerHtml from a DIV.

			//Validate the given Page.
			if (targetPage == null)
			{
				throw new System.ApplicationException("The given object, targetPage, is null.");
			}

			//Validate the given Response.
			if (targetPage.Response == null)
			{
				throw new System.ApplicationException("The given object, targetPage.Response, is null.");
			}

			HttpResponse myTargetResponse = targetPage.Response;

			//Validate the given InnnerHtml.
			innerHtmlFromDiv = (innerHtmlFromDiv + "").Trim();

			if (innerHtmlFromDiv.Length  Test.Framework.Common.Core.WordHelper.InnerHtmlLengthMax)
			{
				throw new System.ApplicationException(
					"The given value innerHtmlFromDiv.Length.ToString()='" + innerHtmlFromDiv.Length.ToString() + 
					"' is not valid because it must be less-than-or-equal-to InnerHtmlLengthMax='" + Test.Framework.Common.Core.WordHelper.InnerHtmlLengthMax.ToString() + "'.");
			}

			//Get a working builder.
			StringBuilder myBuilder = new StringBuilder();

			//Call a helper to get the standard prefix that is written when Word 2003 saves from ".XLS" to ".HTM".

			string myHtmlPrefix = "";
			myHtmlPrefix = Test.Framework.Common.Core.WordHelper.GetHtmlPrefix(targetOrientation, targetMarginInInches);

			//Add the prefix.
			myBuilder.Append(myHtmlPrefix);

			//Get the basline HTML to be exported.
			string myHtmlBody = innerHtmlFromDiv;

			myHtmlBody = Test.Framework.Common.Core.WordHelper.GetHtmlBodyCleaned(myHtmlBody);

			//Add the body.
			myBuilder.Append(myHtmlBody);

			//Call a helper to get the standard suffix that is written when Word 2003 saves from ".XLS" to ".HTM".
			string myHtmlSuffix = Test.Framework.Common.Core.WordHelper.GetHtmlSuffix();

			//Add the suffix.
			myBuilder.Append(myHtmlSuffix);

			//Get a unique suffix for the output file.
			string DateTimeStringSuffix = DateTime.Now.ToString("yyyyMMddHHMMssfffffff");

			//Prepare the response.
			myTargetResponse.Clear();
			myTargetResponse.ClearHeaders();
			myTargetResponse.AddHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0");
			myTargetResponse.AddHeader("Content-transfer-encoding", "binary");
			myTargetResponse.AddHeader("Pragma", "anytextexeptno-cache, true");
			myTargetResponse.AddHeader("content-disposition", "attachment;filename=EXPORT_" + DateTimeStringSuffix + "." + targetExtension.ToString());
			string myHtmlComplete = myBuilder.ToString();

			//Prepare the page.
			targetPage.EnableViewState = false;

			//Write.
			myTargetResponse.Write(myHtmlComplete);

			//End the process, which must be done outside of all try-catch blocks.
			myTargetResponse.End();
		}

		#endregion //Helpers
	}
}

This is a sample usage code-infront…

<%@ page autoeventwireup="true" codefile="ViewerFormVersion02.aspx.cs" enableeventvalidation="false" inherits="Test.ExportForWord.Web.Components.Forms.Private.Administrator.ViewerFormVersion02" language="C#" maintainscrollpositiononpostback="true" validaterequest="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
	<title>ViewerForWord</title>
</head>
<body>
	<form id="form1" runat="server">
	<p>
		<asp:literal id="TopStatusLiteral" runat="server"></asp:literal>&nbsp;
	</p>
	<p>
		<asp:hyperlink id="MainHyperlink" runat="server" navigateurl="~/Default.aspx">Back</asp:hyperlink>
		<asp:label id="Label1" runat="server" font-bold="true">&nbsp;|&nbsp;</asp:label>
		<asp:linkbutton id="TopExportButton" runat="server" onclick="ExportButton_Click" text="Export"></asp:linkbutton>
	</p>
	<table border="1" cellpadding="5" cellspacing="0">
		<tr align="left" valign="top">
			<td align="left" valign="top">
				<asp:label id="Label5" runat="server">Export Settings</asp:label>
			</td>
		</tr>
		<tr align="left" valign="top">
			<td align="left" valign="top">
				<asp:label id="Label6" runat="server">Page Orientation</asp:label>
				<asp:radiobuttonlist id="OrientationRadioButtonList" runat="server" repeatcolumns="9" repeatdirection="horizontal" repeatlayout="table">
					<asp:listitem enabled="true" selected="true" text="Portrait" value="Portrait"></asp:listitem>
					<asp:listitem enabled="true" selected="false" text="Landscape" value="Landscape"></asp:listitem>
				</asp:radiobuttonlist>
			</td>
		</tr>
		<tr align="left" valign="top">
			<td align="left" valign="top">
				<asp:label id="Label7" runat="server">Page Margins</asp:label>
				<asp:radiobuttonlist id="MarginRadioButtonList" runat="server" repeatcolumns="9" repeatdirection="horizontal" repeatlayout="Table">
					<asp:listitem enabled="true" selected="true" text="0.5''" value="0.5"></asp:listitem>
					<asp:listitem enabled="true" selected="false" text="1.0''" value="1.0"></asp:listitem>
					<asp:listitem enabled="true" selected="false" text="1.5''" value="1.5"></asp:listitem>
					<asp:listitem enabled="true" selected="false" text="2.0''" value="2.0"></asp:listitem>
				</asp:radiobuttonlist>
			</td>
		</tr>
	</table>
	<p>
		<asp:label id="Label3" runat="server">Row&nbsp;Count:&nbsp;</asp:label><asp:label id="TotalRowCountLabel" runat="server">0</asp:label>
	</p>
	<div id="ExportDiv" runat="server">
		<asp:gridview id="WordGridView" runat="server" allowpaging="false" allowsorting="false" autogeneratecolumns="true" autogeneratedeletebutton="false" autogenerateeditbutton="false" autogenerateselectbutton="false" bordercolor="Silver" borderstyle="Solid" borderwidth="1px" emptydatatext="NULL" enablesortingandpagingcallbacks="false" enabletheming="false" enableviewstate="true" gridlines="both" showfooter="false" showheader="true">
			<headerstyle horizontalalign="left" verticalalign="Top" font-bold="true" />
			<rowstyle horizontalalign="left" verticalalign="Top" />
		</asp:gridview>
	</div>
	<input id="ExportInput" runat="server" type="hidden" value="" />
	<p>
		<asp:hyperlink id="Hyperlink1" runat="server" navigateurl="~/Default.aspx">Back</asp:hyperlink>
		<asp:label id="Label4" runat="server" font-bold="true">&nbsp;|&nbsp;</asp:label>
		<asp:linkbutton id="BottomExportButton" runat="server" onclick="ExportButton_Click" text="Export"></asp:linkbutton>
	</p>
	<p>
		<asp:literal id="BottomStatusLiteral" runat="server"></asp:literal><asp:label id="Label2" runat="server">&nbsp;</asp:label>
	</p>
	</form>
</body>
</html>

This is sample usage code-behind…

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Test.ExportForWord.Web.Components.Forms.Private.Administrator
{
	/// 
	/// This will display data for Word export.
	/// 
	/// 
	/// Note that this page cannot be a cross-page-post-target because the source page will not display errors properly.
	/// 
	public partial class ViewerFormVersion02 : System.Web.UI.Page
	{
		#region MemberEnums

		/// 
		/// This is mock-data helper.
		/// 
		private enum ColumnName
		{
			Count,
			First,
			Middle,
			Last,
			Email,
		}

		#endregion //MemberEnums

		#region ValidationMethods

		/// 
		/// This is a mock custom validator.
		/// 
		private void ValidateExport()
		{
			//Continue.
		}

		#endregion //ValidationMethods

		#region HelperMethods

		/// 
		/// This is a mock-data helper.
		/// 
		/// This is mock data.
		private DataTable GetData()
		{
			DataTable myDataTable = new DataTable();
			myDataTable.Columns.Add(ColumnName.Count.ToString(), typeof(string));
			myDataTable.Columns.Add(ColumnName.First.ToString(), typeof(string));
			myDataTable.Columns.Add(ColumnName.Last.ToString(), typeof(string));
			myDataTable.Columns.Add(ColumnName.Email.ToString(), typeof(string));
			DataRow myDataRowTemp = null;

			for (int myCount = 1; myCount <= 9; ++myCount)
			{
				myDataRowTemp = myDataTable.NewRow();
				myDataRowTemp[ColumnName.Count.ToString()] = myCount.ToString();
				myDataRowTemp[ColumnName.First.ToString()] = Guid.NewGuid().ToString().Trim().ToUpper();
				myDataRowTemp[ColumnName.Last.ToString()] = Guid.NewGuid().ToString().Trim().ToUpper();
				myDataRowTemp[ColumnName.Email.ToString()] = Guid.NewGuid().ToString().Trim().ToUpper() + "@" + Guid.NewGuid().ToString().Trim().ToUpper() + ".COM";
				myDataTable.Rows.Add(myDataRowTemp);
			}

			myDataTable.AcceptChanges();

			return myDataTable;
		}

		#endregion //HelperMethods

		#region HandlerMethods

		protected void Page_Load(object sender, EventArgs e)
		{
			try
			{
				//Set values for export.
				const string ScriptPrefix = "_d26109b1_f78b_4c79_96a6_c87a892e4761_";
				const string ScriptSuffix = "GetHtmlForWord";
				Test.Framework.Common.Core.WordHelper.SetClientScriptBlock(this.Page, ScriptPrefix + ScriptSuffix, ScriptPrefix, this.ExportDiv.ClientID, this.ExportInput.ClientID);
				this.TopExportButton.OnClientClick = ScriptPrefix + ScriptSuffix + "();";
				this.BottomExportButton.OnClientClick = this.TopExportButton.OnClientClick;

				if (this.IsPostBack)
				{
					//Continue.
				}
				else
				{
					//To get data from Session, do something like this...
					//string myTestSessionData = this.Session[Test.ExportForWord.Common.Core.Enums.SessionKey.TestKeyName.ToString()].ToString();

					//To get data from this page, do something like this...
					DataTable myTableForWord = this.GetData();

					this.TotalRowCountLabel.Text = myTableForWord.Rows.Count.ToString();
					this.WordGridView.DataSource = myTableForWord;
					this.WordGridView.DataBind();
				}
			}
			catch (Exception ex)
			{

#if (DEBUG)
				this.TopStatusLiteral.Text = ex.ToString();
#else
				this.TopStatusLiteral.Text = ex.Message;
#endif

				this.BottomStatusLiteral.Text = this.TopStatusLiteral.Text;
			}
		}

		protected void ExportButton_Click(object sender, EventArgs e)
		{
			try
			{
				//This is optional code, shown in this code sample for demonstration purposed only.
				this.TopStatusLiteral.Text = "";
				this.BottomStatusLiteral.Text = this.TopStatusLiteral.Text;

				//This is optional code, shown in this code sample for demonstration purposed only.
				this.ValidateExport();
			}
			catch (Exception ex)
			{

#if (DEBUG)
				this.TopStatusLiteral.Text = ex.ToString();
#else
				this.TopStatusLiteral.Text = ex.Message;
#endif

				this.BottomStatusLiteral.Text = this.TopStatusLiteral.Text;
			}

			//Call a helper to do the work and do not wrap this call in a try-catch.
			Test.Framework.Common.Core.WordHelper.ExportToWord(
				this.Page,
				this.ExportInput.Value,
				this.OrientationRadioButtonList.SelectedValue,
				this.MarginRadioButtonList.SelectedValue,
				Test.Framework.Common.Core.WordHelper.FileExtension.DOC
				);
		}

		#endregion //HandlerMethods
	}
}

LinqHelper Refactor Idea

Purpose

The purpose of this post is to provide a simple refactoring of Mike Hunter’s most excellent LinqHelper.

Please see the code below.

Please see the orginal post by Mike, linked below.

Code

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime;
using System.Runtime.Serialization;
using System.Text;
using System.Xml;
using Team;
using Team.Framework;
using Team.Framework.Common;
using Team.Framework.Common.Linq;

namespace Team.Framework.Common.Linq
{
	/// <summary>
	/// This is a utility for using L2s-based objects.
	/// </summary>
	/// <remarks>
	/// This code was borrowed '2009-Aug-11-Tue 08:38:14.1223174 AM -04:00' and it should not be modified manually.
	/// For details, see...
	/// http://complexitykills.blogspot.com/2008/03/disconnected-linq-to-sql-tips-part-1.html 
	/// </remarks>
	public static class LINQHelper
	{
		/// <summary> 
		/// Makes a copy of an existing LINQ to SQL entity and it's children. 
		/// </summary> 
		/// <typeparam name="T"></typeparam> 
		/// <param name="entitySource">The LINQ to SQL entity to copy</param> 
		/// <returns></returns> 
		public static T CopyEntityDeep<T>(T entitySource)
		{
			if (entitySource == null)
				return default(T);
			return (T)DeserializeEntity(SerializeEntity(entitySource), entitySource.GetType());
		}

		/// <summary> 
		/// Makes a copy of a list of existing LINQ to SQL entities and their children. 
		/// </summary> 
		/// <typeparam name="T"></typeparam> 
		/// <param name="source">The LIST of SQL entities to copy 
		/// </param> 
		/// <returns></returns> 
		public static List<T> CopyEntityListDeep<T>(List<T> entitySourceList)
		{
			List<T> result = new List<T>();
			if (entitySourceList == null) return null;
			foreach (T entitySource in entitySourceList)
			{
				T entityTarget = CopyEntityDeep(entitySource);
				result.Add(entityTarget);
			}
			return result;
		}

		public static string SerializeEntity<T>(T entitySource)
		{
			DataContractSerializer dcs = new DataContractSerializer(entitySource.GetType());
			if (entitySource == null) return null; StringBuilder sb = new StringBuilder(); XmlWriter xmlw = XmlWriter.Create(sb); dcs.WriteObject(xmlw, entitySource); xmlw.Close();
			return sb.ToString();
		}

		/// <summary>
		/// This will serialize and optionally convert to "utf-8" format.
		/// </summary>
		/// <typeparam name="T">This is the type.</typeparam>
		/// <param name="entitySource">This is the object to use.</param>
		/// <param name="convertToUtf8">This is the flag for utf conversion.</param>
		/// <returns>This is XML.</returns>
		/// <remarks>
		/// NOTE. 20091202. This was added because the standard call returns "utf-16", which sometimes does not load into VS.NET and IE8.
		/// </remarks>
		public static string SerializeEntity<T>(T entitySource, bool convertToUtf8)
		{
			string myString = "";

			myString = (LINQHelper.SerializeEntity(entitySource) + "").Trim();

			if (convertToUtf8)
			{
				myString = myString.Replace("utf-16", "utf-8");
			}

			return myString;
		}

		public static object DeserializeEntity(string entitySource, Type entityType)
		{
			object entityTarget;
			if (entityType == null) return null;
			DataContractSerializer dcs = new DataContractSerializer(entityType);
			StringReader sr = new StringReader(entitySource); XmlTextReader xmltr = new XmlTextReader(sr); entityTarget = (object)dcs.ReadObject(xmltr); xmltr.Close();
			return entityTarget;
		}
	}
}

HTH.

Thank you.

— Mark Kamoski

T4, T4 ToolBox, Linq To Sql Entity Base, Code Description

 

Download Link —

The code can be downloaded at the following link.

https://mkamoski1.wordpress.com/2009/12/01/t4-t4-toolbox-linq-to-sql-entity-base-code-sample/

Credits —

I want to give special thanks to the following people, without whom this sample would not exist.

This is in no particular order, and certainly not a complete list, please note the following superstars…

Oleg Sych
http://www.olegsych.com/
http://www.codeplex.com/t4toolbox

Matthew Hunter
http://complexitykills.blogspot.com/
http://www.codeplex.com/LINQ2SQLEB/

Kristofer Andersson
http://www.huagati.com/

Frans Bouma
http://weblogs.asp.net/fbouma/
http://www.llblgen.com/

(BTW, one would probably learn more from studying their work rather than mine.)

Purpose —

The purpose of this article is to show one way to use T4 templates and T4ToolBox and LinqToSqlEntityBase and Repository and other nice things to help one code a bit faster.

Warning —

I trt to follow, a bit, ideas from GEFN and RAD and YAGNI and a few other quick-mode development ideas. I try to Agile, especially bold, and I refactor heavily. See this List Of Software Development Philosophies for some general details on all this. However, even in doing so, I only do it loosely. Etc. As such, my style is a bit loose and it may not be for everyone. Also, please note that this is a work in progress. APIs may change. Interfaces may change. I have the luxury of working on my own projects from start-to-finish, so I have no compunction in making big changes if necessary. I do, however, have had this code in production as of 2009-Oct-01 and it will probably remain in production until about 2010-Apr-01, when VS.NET 2010 is released and I get it and I implement Self-Tracking-Entities and etc.

Problem —

Linq To Sql was bothering me. I wanted to use Linq-To-Sql in a disconnected way. I did not like the way that the DataContext was getting littered about my layers. I did not like the way that Linq entities had to have reference to an active DataContext object in some scenarios. I did not like the way the baseline CRUD functionality required using some methods of the DataContext and some Entity static methods. Etc. I wanted a Repository pattern, or a quasi-one. I wanted a “Manager” that could “do all the work” and an Entity that could “hold all the data”. I wanted to hand an Entity to my Manager and say “Create” or “Update”. Etc.

Writing the same code was bothering me. I had CRUD methods that I wanted to be generated rather than write by hand. I wanted to use code generation. It did not look like I would be able to get a license to CodeSmith at my current gig. The MyGeneration project, an old favorite, seemed a bit stale. The available code generators were WAY too much for me. I wanted something simple. The generator that I wrote myself was pretty ugly and it was not powerful enough. I did not want a black-box generator. I wanted to generate code that could, if necessary,  have the code generation engine unplugged and the code should be human-readable and not too far from what I would write by hand manually. (Of course, my goal is not to have to unplug the code generator, but if something strange happens, such as a fatal flaw in the generator, then the fall-back must be to manage the code by hand.)

Handling built-in system-level code-table values was bothering me. The common example is “Roles”. I needed a generated output class that could help. I wanted no hardcode for such values. See below for more on this topic.

Design —

I decided to build some simple T4 templates to do the work. The T4ToolBox was a nice way to get up and running quickly. Futhermore, there were some nice tutorials to follow, from Oleg Sych. In my design, there would be one, project-specific “settings template”, that would define the varying parameters for a given project, and this settings-template could not be reused across more than one project. The core templates, these must be able to be reused on any number of projects. 

I decided to use the “one Manager per database table or view” approach. Nice and simple. I would handle full-object-load and cascade-delete and etc on an as-needed basis. The generated Manager would have core CRUD operations. The hand-extended Manager partial class would have custom logic.

I decided to use the “one Entity per database table or view” approach. Nice and simple. These would just hold data. For the most part, the generated Linq To Sql entities, that are made by the VS.NET Designer, were fine. I extended using partial classes for some of the extensibility methods, such as for validation logic in OnValidate() and the like.

I decided to use interfaces to make my objects uniform across projects. These interfaces must be able to be reused on any number of projects.

I decided to generate partial classes to avoid an inheritance chain.

I decided to not hand-edit generated code ever.

I decided code generation MUST be idempotent always.

I decided to use a single-column, uniqueidentifier (Guid), business-layer-generated, primary key in every table. It makes sense. It is easy. It is simple. It is strong. Etc. I can use a unique key for other lookup types, multi-column association tables, natural keys, etc.

Solution —

As above, I used T4, T4 ToolBox, Linq To Sql Entity Base, Repository design pattern, and a few other goodies.

For the CodeTable template, note that the output class may be used in many ways. For example, to make a call to the built-in method this.User.IsInRole(string targetRoleName), such as to enforce the business rule that says “hide this button if the user is not in the admin role”, then one must have somewhere hardcoded that targetRoleName. Generally, one either hard-codes the value somewhere or do this one does other odd tricks, each of which is manually maintained. Objection 1: If the code table value gets deleted or changed then you have to recompile. Answer 1: Well, what better way is there to solve the issue of calling IsUserInRole() with a string role name? This is not for everyone or everything. The hand-hardcode would break too and this is easier to maintain. Also, this risk can be mitigated by a controlled admin workflow and other code. Also, this is intended for semi-static, system-level values.

Interface —

This is just a taste of the code and a version as of about 2009-Dec-14 and a more-recent version probably exists at the Download Link. This is the interface. It may change. It seems is more-or-less done right now, I think. Please note that if this interface does change, then I might not update this in-line code sample in this post. However, the code download link above will have the latest version. The following is just to give the reader an idea of the interface.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Text;

namespace Team.Framework.Interfaces.BusinessLayer.BusinessEntities
{
	/// <summary>
	/// This is a shared manager interface for projects using Linq To Sql (AKA L2s).
	/// </summary>
	/// <remarks>
	/// Note that implementation is at discretion of the architect; but, recommendations are noted below.
	/// </remarks>
	public interface IL2sEntityManager
	{
		/// <summary>
		/// This saves a new entity.
		/// </summary>
		/// <param name="targetEntity">This is the entity to be saved.</param>
		/// <remarks>
		/// Note that the implementation must cast to the appropriate type.
		/// </remarks>
		void Create(object targetEntity);

		/// <summary>
		/// This deletes an existing entity if the ID does exist.
		/// </summary>
		/// <param name="targetPkId">This</param>
		/// <remarks>
		/// Note that it is recommended that this method should gracefully do nothing if the ID does not exist.
		/// Note that the ID is of type "object" in order to support all key types, such as Guid and Long.
		/// </remarks>
		void DeleteByPkId(object targetPkId);

		/// <summary>
		/// This deletes an existing entity if the ID does exist, for each in the given list.
		/// </summary>
		/// <param name="targetPkIdList">This is the list of ID values to delete.</param>
		/// <remarks>
		/// Note that it is recommended that this method should gracefully do nothing if the ID does not exist.
		/// Note that the ID is of type "ArrayList" in order to support all key types, such as Guid and Long.
		/// </remarks>
		void DeleteByPkId(ArrayList targetPkIdList);

		/// <summary>
		/// This returns the total count.
		/// </summary>
		/// <returns>This is the count or zero if there are no rows.</returns>
		long GetCount();

		/// <summary>
		/// This will instantiate and return a new, non-null, unsaved, empty object using the object's default constructor.
		/// </summary>
		/// <returns>This is the new object.</returns>
		/// <remarks>
		/// Note that the callsite must cast to the appropriate type.
		/// </remarks>
		object Instantiate();

		/// <summary>
		/// This returns a flag that indicates object existence.
		/// </summary>
		/// <param name="targetPkId">This is the ID to check.</param>
		/// <returns>This is "true" if the ID does exist, otherwise this is "false".</returns>
		bool IsExistingPkId(object targetPkId);

		/// <summary>
		/// This returns all entities or it returns null if none are found.
		/// </summary>
		/// <returns>This is the set of entities.</returns>
		/// <remarks>
		/// Note that the callsite must cast to the appropriate type.
		/// </remarks>
		System.Linq.IQueryable RetrieveAll();

		/// <summary>
		/// This returns an entity if ID does exists otherwise it returns null.
		/// </summary>
		/// <param name="targetPkId">This is the ID to check.</param>
		/// <returns>This is the entity if the ID does exists or null if the ID does not exist.</returns>
		/// <remarks>
		/// Note that the callsite must cast to the appropriate type.
		/// </remarks>
		object RetrieveByPkId(object targetPkId);

		/// <summary>
		/// This saves an existing entity.
		/// </summary>
		/// <param name="targetEntity">This is the entity to save.</param>
		void Update(object targetEntity);
	}
}

Closing —

 
I am going to stop writing there for now. I have no more time at the moment. I admit, it is all far from perfect, but it is a start.

Comments, criticism, etc, are welcome– just no swearing please.

đŸ™‚

HTH.

Thank you.

— Mark Kamoski

T4, T4 ToolBox, Linq To Sql Entity Base, Code Sample

Overview —

The purpose of this page is to provide links to the latest-and-greatest version of my T4 code generation sample.

Code Description —

The detailed description of the code can be found at the following link.

https://mkamoski1.wordpress.com/2009/12/01/t4-t4-toolbox-linq-to-sql-entity-base-code-description/

Download —

The code can be downloaded from the following link(s).

Always get the one with the latest date-time stamp at the end.

http://www.LogicBus.net/Downloads/Northwind01_T4Sample_200911091337.zip

http://www.LogicBus.net/Downloads/Northwind01_T4Sample_200912011643.zip

HTH.

Thank you.

— Mark Kamoski

Reflection For Information On Constants

How can one get the names of all the constants in a given type?

How can one get the values of all the constants in a given type?

See below.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Text;
using System.Web;

namespace Test.Abcd.Common.Core
{
	/// <summary>
	/// This provides generic services for Reflection.
	/// </summary>
	public static class ReflectionHelper
	{
		#region HelperMethods

		/// <summary>
		/// This returns FieldInfo for constants in a given type.
		/// </summary>
		/// <param name="targetType">This is the type to use.</param>
		/// <returns>This is an array of FieldInfo objects.</returns>
		/// <remarks>
		/// Note that this code was refactored from code found on 20091201 at the following link...
		/// http://weblogs.asp.net/whaggard/archive/2003/02/20/2708.aspx
		/// </remarks>
		public static FieldInfo[] GetConstantFieldInfoArray(System.Type targetType)
		{
			//The "BindingFlags.Public" gets all public fields.
			//The "BindingFlags.Static" gets all static fields.
			//The "BindingFlags.FlattenHierarchy" gets fields from all base types.
			FieldInfo[] myFields = targetType.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);

			ArrayList myConstants = new ArrayList();

			//Go through the list and only pick out the constants.
			foreach (FieldInfo myFieldInfoTemp in myFields)
			{
				// IsLiteral determines if its value is written at compile time and not changeable.
				// IsInitOnly determine if the field can be set in the body of the constructor.
				// For C#, a field with the readonly keyword would have IsLiteral=true and IsInitOnly=true. 
				// For C#, a const field would have IsLiteral=true and IsInitOnly=false.
				if ((myFieldInfoTemp.IsLiteral) && (!myFieldInfoTemp.IsInitOnly))
				{
					myConstants.Add(myFieldInfoTemp);
				}
			}

			// Return an array of FieldInfos
			return (FieldInfo[])myConstants.ToArray(typeof(FieldInfo));
		}

		/// <summary>
		/// This will get the values of all the constants in the given type.
		/// </summary>
		/// <param name="targetType">This is the type to use.</param>
		/// <param name="convertToLowercase">This is a flag indicating if the values should be converted to lowercase or not.</param>
		/// <param name="trimWhitespace">This is a flag indicating if the values should be whitespace-trimmed or not.</param>
		/// <returns>This a collection of the values.</returns>
		/// <remarks>
		/// Note this will only work if the underlying type for the constants is "string".
		/// </remarks>
		public static StringCollection GetConstantValueStringCollection(System.Type targetType, bool convertToLowercase, bool trimWhitespace)
		{
			StringCollection myCollection = null;

			FieldInfo[] myFieldInfoArray = Team.Framework.Common.Core.ReflectionHelper.GetConstantFieldInfoArray(targetType);
			string myValueStringTemp = "";
			object myValueObjectTemp = null;
			int myLoopIndex = 0;
			myCollection = new StringCollection();

			foreach (FieldInfo myFieldInfoTemp in myFieldInfoArray)
			{
				myValueObjectTemp = null;
				myValueStringTemp = "";

				if (myFieldInfoTemp == null)
				{
					throw new System.ApplicationException("The current object, myFieldInfoTemp, is null.");
				}

				myValueObjectTemp = myFieldInfoTemp.GetValue(null);
				Debug.WriteLine("myLoopIndex='" + myLoopIndex.ToString() + "'");

				if (myValueObjectTemp == null)
				{
					myValueStringTemp = "";
					Debug.WriteLine("myValueObjectTemp == null");
					Debug.WriteLine("myValueStringTemp='" + myValueStringTemp + "'");
				}
				else
				{
					myValueStringTemp = myValueObjectTemp.ToString();

					if (convertToLowercase)
					{
						myValueStringTemp = myValueStringTemp.ToLower();
					}

					if (trimWhitespace)
					{
						myValueStringTemp = myValueStringTemp.Trim();
					}
					
					Debug.WriteLine("myValueObjectTemp != null");
					Debug.WriteLine("myValueStringTemp='" + myValueStringTemp + "'");
				}

				myCollection.Add(myValueStringTemp);
				myLoopIndex = myLoopIndex + 1;
			}

			return myCollection;
		}

		#endregion //HelperMethods
	}
}

HTH.

Thank you.

— Mark Kamoski

Simple RSS Control

This is a simple RSS control.

(To use this sample, one needs the code below plus a Linq-To-Sql data model with the given table in it.)

This is the User Control code-behind…

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.Linq;

/// <summary>
/// This control displays Rss content.
/// </summary>
/// <remarks>
/// The code in this control was refactored from the orginal found on 20091128 here...
/// http://code.msdn.microsoft.com/CreateRSSFeedVBNet/Release/ProjectReleases.aspx?ReleaseId=969
/// </remarks>
public partial class EasyControls_RssCreatorControl01 : System.Web.UI.UserControl
{
	#region HelperMethods

	public void DoPageLoad()
	{
		this.Response.Clear();
		this.Response.ContentType = "text/xml";
		var myDataContext = new Aggregator01DbDataContext();

		//Add a where clause here if desired.
		var myRssNewsRecords = from r in myDataContext.RssNewsRecord
							   select r;

		var myRssItemList = new List<System.Xml.Linq.XElement>();
		XElement myRssItemTemp = null;

		foreach (RssNewsRecord myRssNewsRecordTemp in myRssNewsRecords)
		{
			myRssItemTemp = new XElement(
				"item",
				new System.Xml.Linq.XElement("title", myRssNewsRecordTemp.Title),
				new System.Xml.Linq.XElement("link", myRssNewsRecordTemp.Link),
				new System.Xml.Linq.XElement("description", myRssNewsRecordTemp.Description),
				new System.Xml.Linq.XElement("pubDate", DateTime.Now.ToString("r"))
				);

			myRssItemList.Add(myRssItemTemp);
		}

		XDocument myRssResult = new XDocument();
		myRssResult.Declaration = new XDeclaration("1.0", "utf-8", "yes");

		XElement myNode1 = new XElement("rss", "");
		XAttribute myAttribute = new XAttribute("version", "2.0");
		myNode1.Add(myAttribute);

		XElement myNode2 = new XElement(
			"channel",
			new System.Xml.Linq.XElement("title", ConfigurationManager.AppSettings["rss_Title"]),
			new System.Xml.Linq.XElement("link", ConfigurationManager.AppSettings["rss_Link"]),
			new System.Xml.Linq.XElement("description", ConfigurationManager.AppSettings["rss_Description"]),
			new System.Xml.Linq.XElement("pubDate", DateTime.Now.ToString("r")),
			myRssItemList
			);

		myNode1.AddFirst(myNode2);
		myRssResult.AddFirst(myNode1);
		this.Response.Write(myRssResult.ToString());
		this.Response.End();
	}

	#endregion //HelperMethods

	#region HandlerMethods

	protected void Page_Load(object sender, EventArgs e)
	{
		this.DoPageLoad();
	}

	#endregion //HandlerMethods
}

This is the User Control code-infront…

<%@ control language="C#" autoeventwireup="true" codefile="RssCreatorControl01.ascx.cs" inherits="EasyControls_RssCreatorControl01" %>

This is the SQL schema…

USE [YOUR_DATABASE_NAME_GOES_HERE]
GO
/****** Object:  Table [dbo].[RssNewsRecord]    Script Date: 11/30/2009 14:32:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RssNewsRecord]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[RssNewsRecord](
[Description] [varchar](1024) NOT NULL CONSTRAINT [DF_RssNewsRecord_Description]  DEFAULT (''),
[Link] [varchar](128) NOT NULL CONSTRAINT [DF_RssNewsRecord_Link]  DEFAULT (''),
[LiveDate] [datetime] NOT NULL CONSTRAINT [DF_RssNewsRecord_LiveDate]  DEFAULT (getdate()),
[ModifiedBy] [nvarchar](128) NOT NULL CONSTRAINT [DF_RssNewsRecord_ModifiedBy]  DEFAULT (''),
[ModifiedDateTime] [datetime] NOT NULL CONSTRAINT [DF_RssNewsRecord_ModifiedDateTime]  DEFAULT (getdate()),
[ModifiedTimestamp] [timestamp] NOT NULL,
[PkId] [uniqueidentifier] NOT NULL CONSTRAINT [DF_RssNewsRecord_Id]  DEFAULT (newid()),
[Title] [varchar](128) NOT NULL CONSTRAINT [DF_RssNewsRecord_Title]  DEFAULT (''),
CONSTRAINT [Pk_RssNewsRecord_PkId] PRIMARY KEY CLUSTERED
(
[PkId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, 
ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
CONSTRAINT [Uk_RssNewsRecord_Title] UNIQUE NONCLUSTERED
(
[Title] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, 
ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF

This is the consuming page code-behind…

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class RssCreatorControl01Test01 : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{

	}
}

This is the consuming page code-infront…

<%@ page language="C#" autoeventwireup="true" codefile="RssCreatorControl01Test01.aspx.cs" inherits="RssCreatorControl01Test01" %>

<%@ register src="EasyControls/RssCreatorControl01.ascx" tagname="RssCreatorControl01" tagprefix="uc1" %>
<uc1:rsscreatorcontrol01 id="RssCreatorControl011" runat="server" />

Screen Scraper Code Sample 01

Screen Scraper Sample 01

Once I had to make a simple, one-page, basic, screen scraper sample.

The code is below.

This is the code-infront…

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
using System.Text;

public partial class ScreenScraperExample4 : System.Web.UI.Page
{
	#region MemberConstants

	public const string DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss.fffffff tt zzz";
	public const int DefaultUrlLengthMin = 16;
	public const int DefaultStartTokenLengthMin = 1;
	public const int DefaultEndTokenLengthMin = 1;
	public const string DefaultUrl = @"http://www.Google.com";
	public const string DefaultStartToken = @"Web";
	public const string DefaultEndToken = @"News";

	#endregion //MemberConstants

	#region HelperMethods

	private string GetDataValue(string targetUrl, string targetTokenStart, string targetTokenEnd)
	{
		string myReturnValue = "";

		//Special thanks to the following link for starting point, etc,...
		//http://www.eggheadcafe.com/community/aspnet/2/10065129/parsing-datas-from-the-ht.aspx

		targetUrl = (targetUrl + "").Trim();

		if (targetUrl.Length < ScreenScraperExample4.DefaultUrlLengthMin)
		{
			throw new System.NotSupportedException(
				"URL must be greater-than-or-equal-to '" +
				ScreenScraperExample4.DefaultUrlLengthMin.ToString() + "'.");
		}

		targetTokenStart = (targetTokenStart + "").Trim();

		if (targetTokenStart.Length < ScreenScraperExample4.DefaultStartTokenLengthMin)
		{
			throw new System.NotSupportedException(
				"Start-token must be greater-than-or-equal-to '" +
				ScreenScraperExample4.DefaultStartTokenLengthMin.ToString() + "'.");
		}

		targetTokenEnd = (targetTokenEnd + "").Trim();

		if (targetTokenEnd.Length < ScreenScraperExample4.DefaultEndTokenLengthMin)
		{
			throw new System.NotSupportedException(
				"End-token must be greater-than-or-equal-to '" +
				ScreenScraperExample4.DefaultEndTokenLengthMin.ToString() + "'.");
		}

		//Get a Reader.
		StreamReader myReader = null;

		//Get the link.
		WebRequest myRequest = WebRequest.Create(targetUrl);

		//Get the HTML.
		WebResponse myResponse = myRequest.GetResponse();

		//Fill the Reader.
		myReader = new StreamReader(myResponse.GetResponseStream());

		//Get the content.
		string myContent = myReader.ReadToEnd();

		//Get the Regex.
		Regex myRegex =
			new Regex(targetTokenStart + "((.|\n)*?)" + targetTokenEnd, RegexOptions.IgnoreCase);

		//Run the Regex.
		Match myMatch = myRegex.Match(myContent);

		//Bam! We return the value from our Match, and we're in business. 
		myReturnValue = myMatch.Value + "";

		return myReturnValue;
	}

	private void ResetFormNow()
	{
		this.UrlTextBox.Text = ScreenScraperExample4.DefaultUrl;
		this.StartTokenTextBox.Text = ScreenScraperExample4.DefaultStartToken;
		this.EndTokenTextBox.Text = ScreenScraperExample4.DefaultEndToken;
		this.OutputTextBox.Text = "";
	}

	private void ClearFormNow()
	{
		this.UrlTextBox.Text = "";
		this.StartTokenTextBox.Text = "";
		this.EndTokenTextBox.Text = "";
		this.OutputTextBox.Text = "";
	}

	#endregion //HelperMethods

	#region HandlerMethods

	private void Page_Load(object sender, System.EventArgs e)
	{
		try
		{
			this.ResetButton.OnClientClick = @"return confirm('Discard data and reset?');";
			this.ClearButton.OnClientClick = @"return confirm('Discard data and clear?');";
			this.CancelButton.OnClientClick = @"return confirm('Discard data and exit?');";

			if (!this.IsPostBack)
			{
				this.ResetFormNow();
				this.StatusLabel.Text =
					DateTime.Now.ToString(ScreenScraperExample4.DefaultDateTimeFormat) + ": Done.";
			}
		}
		catch (Exception ex)
		{
			this.StatusLabel.Text = ex.ToString();
		}
	}

	protected void TestInlineButton_Click(object sender, EventArgs e)
	{
		try
		{
			string myTargetUrl = this.UrlTextBox.Text;
			myTargetUrl = myTargetUrl + "";
			myTargetUrl = myTargetUrl.Trim();

			if (myTargetUrl.Length < ScreenScraperExample4.DefaultUrlLengthMin)
			{
				throw new System.NotSupportedException(
					"URL must be greater-than-or-equal-to '" +
					ScreenScraperExample4.DefaultUrlLengthMin.ToString() + "'.");
			}

			string myReturn =
				this.GetDataValue(myTargetUrl, this.StartTokenTextBox.Text, this.EndTokenTextBox.Text);

			this.OutputTextBox.Text = myReturn;

			this.StatusLabel.Text =
				DateTime.Now.ToString(ScreenScraperExample4.DefaultDateTimeFormat) + ": Done.";
		}
		catch (Exception ex)
		{
			this.StatusLabel.Text = ex.ToString();
		}
	}

	protected void ResetButton_Click(object sender, EventArgs e)
	{
		try
		{
			this.ResetFormNow();

			this.StatusLabel.Text =
				DateTime.Now.ToString(ScreenScraperExample4.DefaultDateTimeFormat) + ": Done.";
		}
		catch (Exception ex)
		{
			this.StatusLabel.Text = ex.ToString();
		}
	}

	protected void ClearButton_Click(object sender, EventArgs e)
	{
		try
		{
			this.ClearFormNow();

			this.StatusLabel.Text =
				DateTime.Now.ToString(ScreenScraperExample4.DefaultDateTimeFormat) + ": Done.";
		}
		catch (Exception ex)
		{
			this.StatusLabel.Text = ex.ToString();
		}
	}

	protected void CancelButton_Click(object sender, EventArgs e)
	{
		try
		{
			this.Response.Redirect("Default.aspx");
		}
		catch (Exception ex)
		{
			this.StatusLabel.Text = ex.ToString();
		}
	}

	#endregion //HandlerMethods
}

This is the code-behind…


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
using System.Text;

public partial class ScreenScraperExample4 : System.Web.UI.Page
{
	#region MemberConstants

	public const string DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss.fffffff tt zzz";
	public const int DefaultUrlLengthMin = 16;
	public const int DefaultStartTokenLengthMin = 1;
	public const int DefaultEndTokenLengthMin = 1;
	public const string DefaultUrl = @"http://www.Google.com";
	public const string DefaultStartToken = @"Web";
	public const string DefaultEndToken = @"News";

	#endregion //MemberConstants

	#region HelperMethods

	private string GetDataValue(string targetUrl, string targetTokenStart, string targetTokenEnd)
	{
		string myReturnValue = "";

		targetUrl = (targetUrl + "").Trim();

		if (targetUrl.Length < ScreenScraperExample4.DefaultUrlLengthMin)
		{
			throw new System.NotSupportedException(
				"URL must be greater-than-or-equal-to '" + 
				ScreenScraperExample4.DefaultUrlLengthMin.ToString() + "'.");
		}

		targetTokenStart = (targetTokenStart + "").Trim();

		if (targetTokenStart.Length < ScreenScraperExample4.DefaultStartTokenLengthMin)
		{
			throw new System.NotSupportedException(
				"Start-token must be greater-than-or-equal-to '" + 
				ScreenScraperExample4.DefaultStartTokenLengthMin.ToString() + "'.");
		}

		targetTokenEnd = (targetTokenEnd + "").Trim();

		if (targetTokenEnd.Length < ScreenScraperExample4.DefaultEndTokenLengthMin)
		{
			throw new System.NotSupportedException(
				"End-token must be greater-than-or-equal-to '" + 
				ScreenScraperExample4.DefaultEndTokenLengthMin.ToString() + "'.");
		}

		//Get a Reader.
		StreamReader myReader = null;

		//Get the link.
		WebRequest myRequest = WebRequest.Create(targetUrl);

		//Get the HTML.
		WebResponse myResponse = myRequest.GetResponse();

		//Put the HTML into the Reader.
		myReader = new StreamReader(myResponse.GetResponseStream());

		//And dump the StreamReader into a string...
		string myContent = myReader.ReadToEnd();

		//Here we set up our Regular expression to snatch what's between the BEGIN and END comments. 
		Regex myRegex =
			new Regex(targetTokenStart + "((.|\n)*?)" + targetTokenEnd, RegexOptions.IgnoreCase);

		//Here we apply our regular expression to our string using the Match object. 
		Match myMatch = myRegex.Match(myContent);

		//Bam! We return the value from our Match, and we're in business. 
		myReturnValue = myMatch.Value + "";

		return myReturnValue;
	}

	private void ResetFormNow()
	{
		this.UrlTextBox.Text = ScreenScraperExample4.DefaultUrl;
		this.StartTokenTextBox.Text = ScreenScraperExample4.DefaultStartToken;
		this.EndTokenTextBox.Text = ScreenScraperExample4.DefaultEndToken;
		this.OutputTextBox.Text = "";
	}

	private void ClearFormNow()
	{
		this.UrlTextBox.Text = "";
		this.StartTokenTextBox.Text = "";
		this.EndTokenTextBox.Text = "";
		this.OutputTextBox.Text = "";
	}

	#endregion //HelperMethods

	#region HandlerMethods

	private void Page_Load(object sender, System.EventArgs e)
	{
		try
		{
			this.ResetButton.OnClientClick = @"return confirm('Discard data and reset?');";
			this.ClearButton.OnClientClick = @"return confirm('Discard data and clear?');";
			this.CancelButton.OnClientClick = @"return confirm('Discard data and exit?');";

			if (!this.IsPostBack)
			{
				this.ResetFormNow();
				this.StatusLabel.Text =
					DateTime.Now.ToString(ScreenScraperExample4.DefaultDateTimeFormat) + ": Done.";
			}
		}
		catch (Exception ex)
		{
			this.StatusLabel.Text = ex.ToString();
		}
	}

	protected void TestInlineButton_Click(object sender, EventArgs e)
	{
		try
		{
			string myTargetUrl = this.UrlTextBox.Text;
			myTargetUrl = myTargetUrl + "";
			myTargetUrl = myTargetUrl.Trim();

			if (myTargetUrl.Length < ScreenScraperExample4.DefaultUrlLengthMin)
			{
				throw new System.NotSupportedException(
					"URL must be greater-than-or-equal-to '" +
					ScreenScraperExample4.DefaultUrlLengthMin.ToString() + "'.");
			}

			string myReturn = 
				this.GetDataValue(myTargetUrl, this.StartTokenTextBox.Text, this.EndTokenTextBox.Text);

			this.OutputTextBox.Text = myReturn;

			this.StatusLabel.Text =
				DateTime.Now.ToString(ScreenScraperExample4.DefaultDateTimeFormat) + ": Done.";
		}
		catch (Exception ex)
		{
			this.StatusLabel.Text = ex.ToString();
		}
	}

	protected void ResetButton_Click(object sender, EventArgs e)
	{
		try
		{
			this.ResetFormNow();

			this.StatusLabel.Text =
				DateTime.Now.ToString(ScreenScraperExample4.DefaultDateTimeFormat) + ": Done.";
		}
		catch (Exception ex)
		{
			this.StatusLabel.Text = ex.ToString();
		}
	}

	protected void ClearButton_Click(object sender, EventArgs e)
	{
		try
		{
			this.ClearFormNow();

			this.StatusLabel.Text =
				DateTime.Now.ToString(ScreenScraperExample4.DefaultDateTimeFormat) + ": Done.";
		}
		catch (Exception ex)
		{
			this.StatusLabel.Text = ex.ToString();
		}
	}

	protected void CancelButton_Click(object sender, EventArgs e)
	{
		try
		{
			this.Response.Redirect("Default.aspx");
		}
		catch (Exception ex)
		{
			this.StatusLabel.Text = ex.ToString();
		}
	}

	#endregion //HandlerMethods
}