Download presentation
Presentation is loading. Please wait.
Published byWinifred Sherman Modified over 8 years ago
1
DEV362.NET Reference Building Blocks Ron Jacobs Product Manager Microsoft Patterns & Practices
2
Agenda What Are Application Blocks? Walkthrough of 4 Application Blocks Community Results Call to Action
3
Sound familiar? Writing a component to make it simpler to call stored procedures Building a framework component that allows you to log errors to different sources Building framework / infrastructure components to generally simplify app development …wishing Microsoft had done some of this for you?
4
Application Blocks for.NET Beyond ‘sample code’ Reusable Code – C# and VB.NET Documentation Quick Start samples patterns & practices … showcasing best practices Tested & reviewed: Security, Performance, etc. Considering future direction in design …better solutions, faster!
5
Architecture Guidance Microsoft patterns & practices Proven Based on field and partner experience Authoritative Best advice available Accurate Technically validated and tested Actionable Provide the steps to success Relevant Address real world scenarios Available online http://www.microsoft.com/practices Books available from http://shop.microsoft.com/practices
6
EULA and Support Model What about licensing & support? Source Code only – VB.NET and C# No binaries - ‘As is’ EULA Customizations OK Redistribution & repackaging OK GotDotNet Community Support PSS sign-off PSS Training Consistency in recommendations Escalation procedures, bug reporting
7
Walkthrough of 4 Blocks: Operational Management UI Components SecurityCommunication UI Process Components Business Workflows Service Interfaces Business Components Business Entities Users Data SourcesServices Data Access Logic Components Service Agents Data Access Exception Mgmt UI Process Configuration Mgmt Updater
8
Data Access Application Block Simplifies calling ADO.NET SqlClient Simplifies returning many formats Get DataSets, DataReaders, Scalars, XmlReaders – all in one line of code Simplifies calling with many sources Connections, Conn. Strings, SQL Transactions Plays well with COM+ dr = SqlHelper.ExecuteReader( CONN_STRING,“SaveCustomer", “John”, “Doe” );
9
Data Access Application Block SqlHelper static methods ExecuteNonQuery – do not return rows ExecuteDataset – get a dataset from TSQL or sproc ExecuteReader – get a DataReader ExecuteScalar - retrieve a single value resultset from a Transact-SQL statement or stored procedure ExecuteXMLReader - retrieve XML data
10
SqlHelperSqlHelper.ExecuteDataset(SqlHelper.ExecuteDataset(“connectionstring” First, choose the response format Int DataSet SqlDataReader Object XmlReader Then choose target data source Connection String SqlConnection SqlTransaction …and finally, what type of parameters you want to send Value Array SqlParameter Arrays No Parameters Choosing a DAAB Method SqlHelper.ExecuteDataset(“connectionstring”, CommandType.StoredProcedure, ”CustomersGetByPlanet”, “Earth”);
11
Data Access Block demo demo
12
Data Access Application Block Parameter Caching Caches Stored Procedure Parameters Avoids 2 roundtrips Cache can be loaded manually (enforcing type manually) or automatically ‘on the fly’ Important Links.NET Data Access Architecture Guide http://msdn.microsoft.com/library/en-us/dnbda/html/daag.asp http://msdn.microsoft.com/library/en-us/dnbda/html/daag.asp GotDotNet Workspace http://www.gotdotnet.com/Community/Workspaces/Workspace.aspx?i d=c20d12b0-af52-402b-9b7c-aaeb21d1f431
13
Tips ‘Privatize’ functions you don’t need Things you can add Connection String Mgmt Batch Updates* Typed Datasets* * Next rev Instrumentation, DDR, etc.
14
Exception Management Pluggable Exception Publishing One-Line in the application Event log by default You should use EIF as a plug-in Base Application Exception
15
ExceptionManager Simplifies reporting Exceptions Pluggable ‘Publishers’ of exception info Event Log as default. Filters for routing / verbosity Adds troubleshooting information Persists Exception Chain try {…} catch( Exception ex ) { ExceptionManager.Publish (ex ) }
16
Exception Mgmt App Block Runtime flexibility, pluggable stuff <section name="exceptionManagement" type=" Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManagerSectionHandler, Microsoft.ApplicationBlocks.ExceptionManagement" /> <publisher mode="on/off" assembly="AssemblyName" type="TypeName" exclude=“[*]Type,Type" include=“[+]Type,Type" exceptionFormat="xml" customattr = "value" /> <section name="exceptionManagement" type=" Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManagerSectionHandler, Microsoft.ApplicationBlocks.ExceptionManagement" /> <publisher mode="on/off" assembly="AssemblyName" type="TypeName" exclude=“[*]Type,Type" include=“[+]Type,Type" exceptionFormat="xml" customattr = "value" />
17
Exception Management Block demo demo
18
Tips Register custom event sources by running installutil on your DLL Understand exception management best practices Build a ‘dump to text file’ publisher for development
19
Exception Management Important Links Exception Management in.NET http://msdn.microsoft.com/library/en- us/dnbda/html/exceptdotnet.asp Adding WMI and Instrumentation to.NET Apps http://msdn.microsoft.com/library/en- us/dnbda/html/monitordotnet.asp
20
User Interface Process Block Facilitates development of complex UI layers Helps you implement the MVC pattern Describe your UI ‘flow’ as XML Reuse controller logic for win & web Take care of state management Start, pause and resume user tasks without having your code notice
21
A User Interface Process cart browsecatalog error checkout congrats addItem fail resume passCheckout failCheckout checkout fail <navigationGraph iViewManager="WinFormViewManager" name="Shopping" state="State" statePersist="SqlServerPersistState" startView="cart"> <navigationGraph iViewManager="WinFormViewManager" name="Shopping" state="State" statePersist="SqlServerPersistState" startView="cart"> A User Interface Process represents a ‘use case’ You can draw it as a flow between views The UIP Block uses XML config to manage flow
22
UIP In Your Application ControllerBase Your Controller Class DALC WinFormView Your Windows Forms WinFormView Your Windows Forms WebFormView Your ASP.NET Pages or Windows Form,s WebFormView Your ASP.NET Pages or Windows Form,s Biz Component s Data Access State Persistence Provider MyFunc() { //do cool code //more good stuff } MyFunc() { //do cool code //more good stuff } Persistence Providers: - SQL Server - Encrypted SQL Server - Memory - ASP.NET Session - Custom ASP.NET Pages or Windows Forms belonging to a use case State Persistence Provider UIP Manager Application XML Configuration File UIP Configuration View Managers: - Windows Forms - Web Pages View Manager WebFormView Your ASP.NET Pages WinFormView Your Windows Forms State Your State Type (Optional) Your State Type (Optional)
23
UIP Code Writing Controllers: Inherit your class from ControllerBase Use the State object to hold your process data Use the NavigateValue property to set your output Interact with your business layers Writing Views: Inherit your page from WebFormView Inherit your Form from WinFormView Use the MyController property to access the controller UIP sets the reference for you
24
User Interface Process demo demo
25
Configuration Management AB Secure configuration in multiple sources Helps maintain application configuration Pluggable Storage Pluggable Signing & Encryption Caching of config data for performance
26
Using the Config Mgmgt AB Write your application as usual Specify ‘config for the config’ Where a configuration section is stored, whether it’s encrypted or not, caching policy Includes utilities & QuickStarts for encryption <configProvider assembly="Microsoft.ApplicationBlocks.ConfigurationManagement.Storage.XML, Version=1.0.0.4,Culture=neutral, PublicKeyToken=3325ee11de9ffa0a" type="Microsoft.ApplicationBlocks.ConfigurationManagement.Storage.XmlFileStorage" signed="false" refreshOnChange="true" encrypted="false" /> <configCache enabled="true" locationPath="" locationType="Memory" refresh="1 * * * *" signed="true" encrypted=“false" />
27
Configuration Mgmt Design Your Application Your Application Application XML Configuration File (holds config for config) Configuration Storage Providers: - XML File - SQL Server - Registry - Custom Configuration Manager Configuration Storage Provider Data Protection Provider Data Protection Provider Data Protection Providers: - DPAPI - BCL - Custom Caching Service Configuration Section Handlers Data Protection Provider Data Protection Provider Data Protection Provider Data Protection Provider Configuration Storage Provider
28
Updater Application Block Adding self-deployment capabilities for applications ‘V Next’ of the popular GotDotNet Application Updater Securely pull assemblies and files Pluggable download mechanism Includes BITS - Background Intelligent Transfer System Run ‘custom actions’ post deployment Downloads validated using RSA or custom validation
29
Using the Updater Update Controller (Application or separate EXE) Update Controller (Application or separate EXE) Updater Application Block Application Update Manifest 1 1 Server Client Downloader 2 2 Application Poll & Download Controller XML Configuration File File Copy Administrator uses Manifest Utility Validator Post Processor (optional) 5 5 Downloader Validator 4 4 3 3
30
Upcoming Blocks Other Blocks Just Released: Caching, Asynch Invocation, Aggregation Available Now www.microsoft.com/practices Get the code Get samples Get extra plug-ins Use GotDotNetWorkspace for discussion
31
Sharing Code through Community GotDotNet Workspaces Community Blocks Workspaces for blocks Community Blocks Share ideas / extensions File bugs, fix them too! GotDotNet Microsoft Blocks Internet
32
Next Steps Use patterns & practices Download & Use Application Blocks Participate in Workspaces Provide us with your feedback: Are we focused on the topics you need? What other suggestions or requests do you have? rojacobs@microsoft.com http://msdn.microsoft.com/practices
33
Community Resources http://www.microsoft.com/communities/default.mspx Most Valuable Professional (MVP) http://www.mvp.support.microsoft.com/ Newsgroups Converse online with Microsoft Newsgroups, including Worldwide http://www.microsoft.com/communities/newsgroups/default.mspx User Groups Meet and learn with your peers http://www.microsoft.com/communities/usergroups/default.mspx
34
evaluations evaluations
35
© 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.