DEV334 Creating Application Starting Points & Sharing Best Practices with Enterprise Templates Marc Gusmano Director of Emerging Technologies The Information Management Group
A Microsoft Solution Provider and Authorized Technical Education Center Consulting, knowledge transfer and online learning solutions based on Microsoft technologies Founded 1987, based in Chicago, IL USA Corporate information:
Agenda Enterprise Templates Overview Enterprise Template Features What’s new today Futures Q & A
IT Development Problems IT development projects are getting more complex, larger, and more critical A poor application architecture can make any platform perform poorly A good architecture only works if people follow the rules when implementing it Good help is hard to find (and expensive!) “Best Practices” are useless if no one reads them
Enterprise Templates Implementation - Package reusable code in easy to use ways Policy - Define active design time rules to help avoid common problems Guidance - Provide “Just-In-Time” help Help architects capture and share best practices as Application Construction Toolkits
Reusable Implementation Common, standard code everyone should use Active – Interactive Wizards Static – Standard ETP prototypes When components are not enough Custom code or optimization required Too many variations for “one size fits all” Default Implementation – Created on File | New | Project Optional Implementation – Added only when needed
An Enterprise Template Example demo demo
Steps to building an Enterprise Template with VS.NET 1. Create a VS.NET Class Library project 2. Add a reference to envDTE 3. Define a new Template Class a) Create a class that implements the EnvDTE.IDTWizard Interface b) Add the ‘Guid’ and ‘ProgID’ Attributes to the class 4. Implement the ‘Execute’ method 5. Register the assembly to COM 6. Create the.vsdir and.vsz files 7. Register the Template with Visual Studio.NET
Step 1: Create a VS.NET Class Library project
Step 2: Add a reference to envDTE
Step 3: Define a new Template Class Imports System.Runtime.InteropServices <Guid(" A9F3-BB589069D914"), _ ProgId("AppArchWiz.Wizard2003")> _ Public Class MyCustomWizard Implements EnvDTE.IDTWizard End Class
Step 4: Implement the ‘Execute’ method Public Sub Execute(ByVal Application As Object, _ ByVal hwndOwner As Integer, _ ByRef ContextParams() As Object, _ ByRef CustomParams() As Object, _ ByRef retval As EnvDTE.wizardResult) _ Implements EnvDTE.IDTWizard.Execute Try SetWizardState(Application, contextParams, customParams) Dim frmAppArch As frmAppArch frmAppArch = New frmAppArch frmAppArch.clsWizard = Me frmAppArch.Text = "Application Architecture for.NET - " + ProjectName If frmAppArch.ShowDialog() <> Windows.Forms.DialogResult.OK Then Return End If Dim soln As EnvDTE.Solution soln = CreateVSSolution(AppObject, LocalDirectory, InstallationDirectory, _ SolutionName, ProjectName, ExclusiveSolution) Catch e As Exception MsgBox("An error occured while creating the solution. The wizard is unable to continue." _ + vbCrLf + vbCrLf + e.Message + " (" + e.Source + ")", _ MsgBoxStyle.Critical, "Error") End Try End Sub
Step 5: Register the Assembly to COM Create a Strong Name Key Use sn.exe /k AppArchWiz.snk Set Assembly Version Attribute [assembly: AssemblyVersion(" ")] Assign strong name file to Assembly-level attribute [assembly: Register Assembly with COM Use ‘regasm.exe AppArchWiz.dll /codebase’
Step 6: Create the.vsz and.vsdir files.vsz VSWIZARD 7.0 Wizard=AppArchWiz.Wizard2003 (Modify Wizard to match ProgID attribute in code).vsdir AppArchfor.NET.vsz| |Application Architecture for.NET Wizard|1|This wizard generates an Application Architecture for.NET Solution.| |6777| |AppArch (Modify to match name of this template).ico – icon for VS.NET dialog
Step 7: Register the Template with Visual Studio.NET [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.1\NewProje Architecture for.NET Wizard" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.1\NewProje ctTemplates\TemplateDirs\{ a5e-A CAF8085FE}\/1] "TemplatesDir"="C:\\Program Files\\Microsoft Visual Studio.NET 2003\\EnterpriseFrameworks\\ProxyProjects\\Application Architecture for.NET\\" Architecture for.NET Wizard" Need to modify GUID (2 locations) – match GUID attribute in code Description – (2 locations) TemplatesDir – to location of.vsz and.vsdir files
Policy Design-time rules Defined in Template Description Language (TDL) XML schema “Active” guidance, not strict enforcement Benefits Help avoid common problems Provide context specific component property settings Simplify & filter inappropriate choices
Policy Examples demo demo
Policy Defining Development Policy For each design time framework component, define: Component identification Containment restrictions Reference restrictions Default property values and ranges Context and help topics
“Just-In-Time” Guidance User defined help topics Plain HTML or Compiled Help Local or centrally managed Custom context keywords & attributes Links appear in Dynamic Help Window Benefits IDE integrated, Framework specific help Subtle but timely reminders More up-to-date (Centralized management)
“Just-In-Time” Guidance Example demo demo
“Just-In-Time” Guidance Beyond HTML pages VS Help Integration Kit (VSHIK) Access to MS Help 2.1 SDK Integrate custom help into index and TOC Free download MSDN Download center (Search for VSHIK)
Client example of an Enterprise Template Web Services – based Application Architecture Several steps needed once a developer created a Win Form VS.NET project Enterprise Template generated needed code and component references WinForm ServiceAgentFactory ServiceAgent ServiceInterfaceAuthor.dllXMLWebServiceCall
Client example of an Enterprise Template demo demo
What’s New in VS.NET 2003 Policy Editor Simplifies policy definition process Free download Full source available “Unsupported” tool Still requires “policy dance” Download at:
Policy Editor demo demo
Futures More powerful policy Policy on solution & any projects Improved identify (uniqueness & web) Separate policy from definitions Minimum & maximum allowed ElementSet PolicyMode support Author defined reminder text and severity Migration support Updated Policy Editor
Resources VS Enterprise Tools Community Microsoft.public.vsnet.enterprise.tools Microsoft.public.vsnet.enterprise.tools Architect Community e/Patterns/templates.aspx e/Patterns/templates.aspx
Summary Enterprise Templates Overview Enterprise Template Features What’s new today Futures
Community Resources Most Valuable Professional (MVP) Newsgroups Converse online with Microsoft Newsgroups, including Worldwide User Groups Meet and learn with your peers
evaluations evaluations
© 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.