Professional C# 4.0 and .Net 4

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

This book starts by reviewing the overall architecture of .NET in order to give you the background you need to be able to write managed code. After that, the book is divided into a number of sections that cover both the C# language and its application in a variety of areas. Part I: The C# Language gives a good grounding in the C# language for experienced programmers. You start by looking at basic syntax and data types. Objects, types, inheritance, generics, arrays, tuples, operators, casts, delegates, lambdas, events, strings, regular expressions, collections, Language Integrated, Query (LINQ), Dynamic Language Extensions, memory management, pointers, reflection, errors, and exceptions are all covered. Part II: Visual Studio looks at Visual Studio 2010 (the best way to use the tool to build applications based on the .NET Framework 4) and deploying your projects. Part III: Foundation looks at .NET assemblies, instrumentation, security, threading, tasks, synchronization, localization, System.Transactions, networking, interop, XAML, Managed Extensibility Framework, Manipulating Files and the Registry, transactions, building Windows services, and generating your own libraries as assemblies. Part IV: Data covers accessing databases with ADO.NET, ADO.NET Entity Framework, data services, support in .NET for XML, and the .NET features of SQL Server 2008. Part V: Presentation shows how to build applications based on the Windows Presentation Foundation and Silverlight, and covers writing components that will run on web sites. It also has coverage on building Windows Forms applications in as well as ASP.NET and ASP.NET MVC. Part VI: Communication covers services for platform-independent communication using the Windows Communication Foundation (WCF). With Message Queuing, asynchronous disconnected communication is shown. This section looks at utilizing the Windows Workflow Foundation 4, peer to peer networking, and creating syndication feeds.

Author(s): Christian Nagel; Bill Evjen; Jay Glynn; Karli Watson; Morgan Skinner
Publisher: Wrox Press
Year: 2010

Language: English
Pages: 1474

WroxBooks
Professional C# 4 and .NET 4
About the Authors
Contents
Introduction
THE SIGNIFICANCE OF .NET AND C#
ADVANTAGES OF .NET
WHAT'S NEW IN THE .NET FRAMEWORK 4
ASP.NET MVC
WHERE C# FITS IN
WHAT YOU NEED TO WRITE AND RUN C# CODE
WHAT THIS BOOK COVERS
CONVENTIONS
SOURCE CODE
ERRATA
P2P.WROX.COM
Part I: The C# Language
Chapter 1: .NET Architecture
THE RELATIONSHIP OF C# TO .NET
THE COMMON LANGUAGE RUNTIME
A CLOSER LOOK AT INTERMEDIATE LANGUAGE
ASSEMBLIES
.NET FRAMEWORK CLASSES
NAMESPACES
CREATING .NET APPLICATIONS USING C#
THE ROLE OF C# IN THE .NET ENTERPRISE ARCHITECTURE
SUMMARY
Chapter 2: Core C#
YOUR FIRST C# PROGRAM
VARIABLES
PREDEFINED DATA TYPES
FLOW CONTROL
ENUMERATIONS
NAMESPACES
THE MAIN() METHOD
MORE ON COMPILING C# FILES
CONSOLE I/O
USING COMMENTS
THE C# PREPROCESSOR DIRECTIVES
C# PROGRAMMING GUIDELINES
SUMMARY
Chapter 3: Objects and Types
CLASSES AND STRUCTS
CLASSES
ANONYMOUS TYPES
STRUCTS
PARTIAL CLASSES
STATIC CLASSES
THE OBJECT CLASS
EXTENSION METHODS
SUMMARY
Chapter 4: Inheritance
TYPES OF INHERITANCE
IMPLEMENTATION INHERITANCE
MODIFIERS
INTERFACES
SUMMARY
Chapter 5: Generics
GENERICS OVERVIEW
CREATING GENERIC CLASSES
GENERICS FEATURES
GENERIC INTERFACES
GENERIC METHODS
SUMMARY
Chapter 6: Arrays and Tuples
SIMPLE ARRAYS
MULTIDIMENSIONAL ARRAYS
JAGGED ARRAYS
ARRAY CLASS
ARRAYS AS PARAMETERS
ENUMERATIONS
TUPLES
STRUCTURAL COMPARISON
SUMMARY
Chapter 7: Operators and Casts
OPERATORS
TYPE SAFETY
COMPARING OBJECTS FOR EQUALITY
OPERATOR OVERLOADING
USER-DEFINED CASTS
SUMMARY
Chapter 8: Delegates, Lambdas, and Events
DELEGATES
LAMBDA EXPRESSIONS
EVENTS
SUMMARY
Chapter 9: Strings and Regular Expressions
EXAMINING SYSTEM.STRING
REGULAR EXPRESSIONS
SUMMARY
Chapter 10: Collections
COLLECTION INTERFACES AND TYPES
LISTS
QUEUE
STACK
LINKED LIST
SORTED LIST
DICTIONARIES
SETS
OBSERVABLE COLLECTION
BIT ARRAYS
CONCURRENT COLLECTIONS
PERFORMANCE
SUMMARY
Chapter 11: Language Integrated Query
LINQ OVERVIEW
STANDARD QUERY OPERATORS
PARALLEL LINQ
EXPRESSION TREES
LINQ PROVIDERS
SUMMARY
Chapter 12: Dynamic Language Extensions
DYNAMIC LANGUAGE RUNTIME
THE DYNAMIC TYPE
HOSTING THE DLR SCRIPTRUNTIME
HOSTING THE DLR SCRIPTRUNTIME
DYNAMICOBJECT AND EXPANDOOBJECT
SUMMARY
Chapter 13: Memory Management and Pointers
MEMORY MANAGEMENT UNDER THE HOOD
FREEING UNMANAGED RESOURCES
UNSAFE CODE
SUMMARY
Chapter 14: Reflection
CUSTOM ATTRIBUTES
USING REFLECTION
SUMMARY
Chapter 15: Errors and Exceptions
EXCEPTION CLASSES
CATCHING EXCEPTIONS
USER-DEFINED EXCEPTION CLASSES
SUMMARY
Part II: Visual Studio
Chapter 16: Visual Studio 2010
WORKING WITH VISUAL STUDIO 2010
REFACTORING TOOLS
MULTI-TARGETING THE .NET FRAMEWORK
WPF, WCF, WF, AND MORE
SUMMARY
Chapter 17: Deployment
PLANNING FOR DEPLOYMENT
SIMPLE DEPLOYMENT OPTIONS
VISUAL STUDIO 2010 SETUP AND DEPLOYMENT PROJECTS
CLICKONCE
VISUAL STUDIO 2010 EDITORS
SUMMARY
Part III: Foundation
Chapter 18: Assemblies
WHAT ARE ASSEMBLIES?
CREATING ASSEMBLIES
APPLICATION DOMAINS
SHARED ASSEMBLIES
CONFIGURING .NET APPLICATIONS
VERSIONING
SUMMARY
Chapter 19: Instrumentation
CODE CONTRACTS
TRACING
EVENT LOGGING
PERFORMANCE MONITORING
SUMMARY
Chapter 20: Threads, Tasks, and Synchronization
OVERVIEW
ASYNCHRONOUS DELEGATES
THE THREAD CLASS
THREAD POOLS
TASKS
PARALLEL CLASS
CANCELLATION FRAMEWORK
THREADING ISSUES
SYNCHRONIZATION
TIMERS
EVENT-BASED ASYNCHRONOUS PATTERN
SUMMARY
Chapter 21: Security
AUTHENTICATION AND AUTHORIZATION
ENCRYPTION
ACCESS CONTROL TO RESOURCES
CODE ACCESS SECURITY
DISTRIBUTING CODE USING CERTIFICATES
SUMMARY
Chapter 22: Localization
NAMESPACE SYSTEM.GLOBALIZATION
RESOURCES
WINDOWS FORMS LOCALIZATION USING VISUAL STUDIO
LOCALIZATION WITH ASP.NET
LOCALIZATION WITH WPF
A CUSTOM RESOURCE READER
CREATING CUSTOM CULTURES
SUMMARY
Chapter 23: System.Transactions
OVERVIEW
DATABASE AND ENTITY CLASSES
TRADITIONAL TRANSACTIONS
SYSTEM.TRANSACTIONS
ISOLATION LEVEL
CUSTOM RESOURCE MANAGERS
TRANSACTIONS WITH WINDOWS 7 AND WINDOWS SERVER 2008
SUMMARY
Chapter 24: Networking
THE WEBCLIENT CLASS
WEBREQUEST AND WEBRESPONSE CLASSES
DISPLAYING OUTPUT AS AN HTML PAGE
UTILITY CLASSES
LOWER-LEVEL PROTOCOLS
SUMMARY
Chapter 25: Windows Services
WHAT IS A WINDOWS SERVICE?
WINDOWS SERVICES ARCHITECTURE
CREATING A WINDOWS SERVICE PROGRAM
MONITORING AND CONTROLLING WINDOWS SERVICES
TROUBLESHOOTING AND EVENT LOGGING
SUMMARY
Chapter 26: Interop
.NET AND COM
USING A COM COMPONENT FROM A .NET CLIENT
USING A .NET COMPONENT FROM A COM CLIENT
PLATFORM INVOKE
SUMMARY
Chapter 27: Core XAML
OVERVIEW
DEPENDENCY PROPERTIES
BUBBLING AND TUNNELING EVENTS
ATTACHED PROPERTIES
MARKUP EXTENSIONS
READING AND WRITING XAML
SUMMARY
Chapter 28: Managed Extensibility Framework
MEF ARCHITECTURE
CONTRACTS
EXPORTS
IMPORTS
CONTAINERS AND EXPORT PROVIDERS
CATALOGS
SUMMARY
Chapter 29: Manipulating Files and the Registry
MANAGING THE FILE SYSTEM
MOVING, COPYING, AND DELETING FILES
READING AND WRITING TO FILES
MAPPED-MEMORY FILES
READING DRIVE INFORMATION
FILE SECURITY
READING AND WRITING TO THE REGISTRY
READING AND WRITING TO ISOLATED STORAGE
SUMMARY
Part IV: Data
Chapter 30: Core ADO.NET
ADO.NET OVERVIEW
USING DATABASE CONNECTIONS
COMMANDS
FAST DATA ACCESS: THE DATA READER
MANAGING DATA AND RELATIONSHIPS: THE DATASET CLASS
XML SCHEMAS: GENERATING CODE WITH XSD
POPULATING A DATASET
PERSISTING DATASET CHANGES
WORKING WITH ADO.NET
SUMMARY
Chapter 31: ADO.NET Entity Framework
OVERVIEW OF THE ADO.NET ENTITY FRAMEWORK
ENTITY FRAMEWORK MAPPING
ENTITY CLIENT
ENTITIES
OBJECT CONTEXT
RELATIONSHIPS
OBJECT QUERY
UPDATES
LINQ TO ENTITIES
SUMMARY
Chapter 32: Data Services
OVERVIEW
CUSTOM HOSTING WITH CLR OBJECTS
HTTP CLIENT APPLICATION
QUERIES WITH URLS
USING WCF DATA SERVICES WITH THE ADO.NET ENTITY FRAMEWORK
SUMMARY
Chapter 33: Manipulating XML
XML STANDARDS SUPPORT IN .NET
INTRODUCING THE SYSTEM.XML NAMESPACE
USING SYSTEM.XML CLASSES
READING AND WRITING STREAMED XML
USING THE DOM IN .NET
USING XPATHNAVIGATORS
XML AND ADO.NET
SERIALIZING OBJECTS IN XML
LINQ TO XML AND .NET
WORKING WITH DIFFERENT XML OBJECTS
USING LINQ TO QUERY XML DOCUMENTS
MORE QUERY TECHNIQUES FOR XML DOCUMENTS
SUMMARY
Chapter 34: .NET Programming with SQL Server
.NET RUNTIME HOST
MICROSOFT.SQLSERVER.SERVER
USER-DEFINED TYPES
USER-DEFINED AGGREGATES
STORED PROCEDURES
USER-DEFINED FUNCTIONS
TRIGGERS
XML DATA TYPE
SUMMARY
Part V: Presentation
Chapter 35: Core WPF
OVERVIEW
SHAPES
GEOMETRY
TRANSFORMATION
BRUSHES
CONTROLS
LAYOUT
STYLES AND RESOURCES
TRIGGERS
TEMPLATES
ANIMATIONS
VISUAL STATE MANAGER
3-D
SUMMARY
Chapter 36: Business Applications with WPF
DATA BINDING
COMMANDING
TREEVIEW
DATAGRID
SUMMARY
Chapter 37: Creating Documents with WPF
TEXT ELEMENTS
FLOW DOCUMENTS
FIXED DOCUMENTS
XPS DOCUMENTS
PRINTING
SUMMARY
Chapter 38: Silverlight
COMPARING WPF AND SILVERLIGHT
CREATING A SILVERLIGHT PROJECT
NAVIGATION
NETWORKING
BROWSER INTEGRATION
SILVERLIGHT OUT-OF-BROWSER APPLICATIONS
SUMMARY
Chapter 39: Windows Forms
CREATING A WINDOWS FORMS APPLICATION
CONTROL CLASS
STANDARD CONTROLS AND COMPONENTS
FORMS
SUMMARY
Chapter 40: Core ASP.NET
ASP.NET INTRODUCTION
ASP.NET WEB FORMS
ADO.NET AND DATA BINDING
APPLICATION CONFIGURATION
SUMMARY
Chapter 41: ASP.NET Features
USER AND CUSTOM CONTROLS
MASTER PAGES
SITE NAVIGATION
SECURITY
THEMES
WEB PARTS
ASP.NET AJAX
WHAT IS AJAX?
SUMMARY
Chapter 42: ASP.NET Dynamic Data and MVC
ROUTING
DYNAMIC DATA
MVC
SUMMARY
Part VI: Communication
Chapter 43: Windows Communications Foundation
WCF OVERVIEW
SIMPLE SERVICE AND CLIENT
SERVICE IMPLEMENTATION
BINDING
HOSTING
CLIENTS
DUPLEX COMMUNICATION
SUMMARY
Chapter 44: Windows Workflow Foundation 4
HELLO WORLD
ACTIVITIES
CUSTOM ACTIVITIES
WORKFLOWS
SUMMARY
Chapter 45: Peer-to-Peer Networking
PEER-TO-PEER NETWORKING OVERVIEW
MICROSOFT WINDOWS PEER-TO-PEER NETWORKING
BUILDING P2P APPLICATIONS
SUMMARY
Chapter 46: Message Queuing
OVERVIEW
MESSAGE QUEUING PRODUCTS
MESSAGE QUEUING ARCHITECTURE
MESSAGE QUEUING ADMINISTRATIVE TOOLS
PROGRAMMING MESSAGE QUEUING
COURSE ORDER APPLICATION
RECEIVING RESULTS
TRANSACTIONAL QUEUES
MESSAGE QUEUING WITH WCF
MESSAGE QUEUE INSTALLATION
SUMMARY
Chapter 47: Syndication
OVERVIEW OF SYSTEM.SERVICEMODEL.SYNDICATION
READING SYNDICATION FEEDS SAMPLE
OFFERING SYNDICATION FEEDS SAMPLE
SUMMARY
Appendix: Guidelines for Windows 7 and Windows Server 2008 R2
OVERVIEW
APPLICATION RECOVERY
USER ACCOUNT CONTROL
DIRECTORY STRUCTURE
NEW CONTROLS AND DIALOGS
SUMMARY
Index
Chapter 48: Graphics with GDI+
UNDERSTANDING DRAWING PRINCIPLES
MEASURING COORDINATES AND AREAS
DRAWING SCROLLABLE WINDOWS
WORLD, PAGE, AND DEVICE COORDINATES
COLORS
PENS AND BRUSHES
DRAWING SHAPES AND LINES
DISPLAYING IMAGES
ISSUES WHEN MANIPULATING IMAGES
DRAWING TEXT
SIMPLE TEXT EXAMPLE
FONTS AND FONT FAMILIES
ENUMERATING FONT FAMILIES EXAMPLE
EDITING A TEXT DOCUMENT: THE CAPSEDITOR EXAMPLE
PRINTING
SUMMARY
Chapter 49: Visual Studio Tools for Office
VSTO OVERVIEW
VSTO PROJECT FUNDAMENTALS
BUILDING VSTO SOLUTIONS
EXAMPLE APPLICATION
SUMMARY
Chapter 50: Managed Add-In Framework
MAF ARCHITECTURE
ADD-IN SAMPLE
SUMMARY
Chapter 51: Enterprise Services
USING ENTERPRISE SERVICES
CREATING A SIMPLE COM+ APPLICATION
DEPLOYMENT
COMPONENT SERVICES EXPLORER
CLIENT APPLICATION
TRANSACTIONS
SAMPLE APPLICATION
INTEGRATING WCF AND ENTERPRISE SERVICES
SUMMARY
Chapter 52: Directory Services
THE ARCHITECTURE OF ACTIVE DIRECTORY
ADMINISTRATION TOOLS FOR ACTIVE DIRECTORY
PROGRAMMING ACTIVE DIRECTORY
SEARCHING FOR USER OBJECTS
ACCOUNT MANAGEMENT
DSML
SUMMARY
Chapter 53: C#, Visual Basic, C++/CLI, and F#
NAMESPACES
DEFINING TYPES
METHODS
STATIC MEMBERS
ARRAYS
CONTROL STATEMENTS
LOOPS
EXCEPTION HANDLING
INHERITANCE
RESOURCE MANAGEMENT
DELEGATES
EVENTS
GENERICS
LINQ QUERIES
C++/CLI MIXING NATIVE AND MANAGED CODE
C# SPECIFICS
SUMMARY
Chapter 54: .NET Remoting
WHY USE .NET REMOTING?
.NET REMOTING TERMS EXPLAINED
CONTEXTS
REMOTE OBJECTS, CLIENTS,AND SERVERS
.NET REMOTING ARCHITECTURE
CONFIGURATION FILES
HOSTING SERVERS IN ASP.NET
CLASSES, INTERFACES, AND SOAPSUDS
ASYNCHRONOUS REMOTING
SECURITY WITH .NET REMOTING
REMOTING AND EVENTS
CALL CONTEXTS
SUMMARY
Chapter 55: Web Services with ASP.NET
SOAP
WSDL
WEB SERVICES
EXTENDING THE EVENT - BOOKING EXAMPLE
EXCHANGING DATA USING SOAP HEADERS
SUMMARY
Chapter 56: LINQ to SQL
LINQ TO SQL USING VISUAL STUDIO 2010
HOW OBJECTS MAP TO LINQ OBJECTS
WORKING WITHOUT THE O/R DESIGNER
CUSTOM OBJECTS AND THE O/R DESIGNER
QUERYING THE DATABASE
STORED PROCEDURES
SUMMARY
Chapter 57: Windows Workflow Foundation 3.0
HELLO WORLD
ACTIVITIES
CUSTOM ACTIVITIES
WORKFLOWS
THE WORKFLOW RUNTIME
WORKFLOW SERVICES
INTEGRATION WITH WINDOWS COMMUNICATION FOUNDATION
HOSTING WORKFLOWS
THE WORKFLOW DESIGNER
MOVING FROM WF 3.X TO WF 4
SUMMARY