Sample Content from Customizing the Microsoft .NET Framework

Total Page:16

File Type:pdf, Size:1020Kb

Sample Content from Customizing the Microsoft .NET Framework To learn more about this book, visit Microsoft Learning at http://www.microsoft.com/MSPress/books/6895.aspx A05T619883.fm Page vii Friday, December 10, 2004 8:27 AM Table of Contents Foreword. xiii Acknowledgments. .xv Introduction . .xvii 1 CLR Hosts and Other Extensible Applications . .1 Summary . 4 2 A Tour of the CLR Hosting API. .5 CorBindToRuntimeEx and ICLRRuntimeHost. 5 CLR Hosting Managers . 7 CLR Initialization and Startup . 9 Other Unmanaged Functions on mscoree.dll . 12 Hosting Manager Discovery . 12 Discovering Host-Implemented Managers . 13 Obtaining CLR-Implemented Managers. 15 Overview of the Hosting Managers. 16 Assembly Loading . 16 Customizing Failure Behavior. 19 Programming Model Enforcement . 20 Memory and Garbage Collection . 21 Threading and Synchronization . 23 Other Hosting API Features . 25 Summary . 27 3 Controlling CLR Startup and Shutdown . 29 The CLR Startup Configuration Settings . 29 Version . 30 The Server and Workstation Builds . 40 Concurrent Garbage Collection . 41 Domain-Neutral Code. 42 Setting the Startup Options Using CorBindToRuntimeEx . 43 Starting the CLR . 44 Handling Failures from CorBindToRuntimeEx. 45 Deferring CLR Initialization and Startup . 45 What do you think of this book? Microsoft is interested in hearing your feedback about this publication so we can continually improve our books and learning resources for you. To participate in a brief We want to hear from you! online survey, please visit: www.microsoft.com/learning/booksurvey/ A05T619883.fm Page viii Friday, December 10, 2004 8:27 AM viii Table of Contents The CLR and Process Lifetime . 49 Summary . 49 4 Using the Default CLR Host . 51 Invoking the Default Host: Running Managed Executables . 51 Invoking the Default Host: Activating Managed Types Through COM Interop. 53 Defaults for the CLR Startup Options . 54 Selecting a CLR Version . 54 Customizing the Default Host Using Configuration Files . 57 Concurrent Garbage Collection. 58 Build Type . 59 Version. 62 Summary . 66 5 Using Application Domains Effectively . 67 The Role of Application Domains . 67 Type Safety and Verification . 68 Application Isolation . 70 Application Domain Structure . 73 The Default Application Domain. 75 The AppDomainViewer Tool . 76 Guidelines for Partitioning a Process into Multiple Application Domains . 81 Code Unloading. 82 Cross-Domain Communication . 82 Sample Application Domain Boundaries . 84 Application Domain Managers . 85 Creating an Application Domain Manager . 86 Associating an Application Domain Manager with a Process . 89 Creating Application Domains. 98 Application Domains and Threads . 101 The CLR Thread Pool. 103 Unloading Application Domains . 106 Step 1: Aborting the Threads Running in the Domain . 107 Step 2: Raising an Unload Event . 108 Step 3: Running Finalizers . 108 Step 4: Freeing the Internal CLR Data Structures . 109 Exceptions Related to Unloading Application Domains . 109 Receiving Application Domain Unload Events . 109 Summary . 114 A05T619883.fm Page ix Friday, December 10, 2004 8:27 AM Table of Contents ix 6 Configuring Application Domains. 115 Application Domain Configuration Settings . 115 Private Assembly Directory Settings . 118 Customizing the ApplicationBase Directory Structure . 119 Turning Off ApplicationBase Searching. 121 Configuration File Settings . 122 Shadow Copy Settings. 123 Turning on Shadow Copy . 124 Specifying the Location for the Copied Files . 124 Specifying Which Files Are Copied . 125 The Shadow Copy Sample . ..
Recommended publications
  • Domain-Specific Programming Systems
    Lecture 22: Domain-Specific Programming Systems Parallel Computer Architecture and Programming CMU 15-418/15-618, Spring 2020 Slide acknowledgments: Pat Hanrahan, Zach Devito (Stanford University) Jonathan Ragan-Kelley (MIT, Berkeley) Course themes: Designing computer systems that scale (running faster given more resources) Designing computer systems that are efficient (running faster under constraints on resources) Techniques discussed: Exploiting parallelism in applications Exploiting locality in applications Leveraging hardware specialization (earlier lecture) CMU 15-418/618, Spring 2020 Claim: most software uses modern hardware resources inefficiently ▪ Consider a piece of sequential C code - Call the performance of this code our “baseline performance” ▪ Well-written sequential C code: ~ 5-10x faster ▪ Assembly language program: maybe another small constant factor faster ▪ Java, Python, PHP, etc. ?? Credit: Pat Hanrahan CMU 15-418/618, Spring 2020 Code performance: relative to C (single core) GCC -O3 (no manual vector optimizations) 51 40/57/53 47 44/114x 40 = NBody 35 = Mandlebrot = Tree Alloc/Delloc 30 = Power method (compute eigenvalue) 25 20 15 10 5 Slowdown (Compared to C++) Slowdown (Compared no data no 0 data no Java Scala C# Haskell Go Javascript Lua PHP Python 3 Ruby (Mono) (V8) (JRuby) Data from: The Computer Language Benchmarks Game: CMU 15-418/618, http://shootout.alioth.debian.org Spring 2020 Even good C code is inefficient Recall Assignment 1’s Mandelbrot program Consider execution on a high-end laptop: quad-core, Intel Core i7, AVX instructions... Single core, with AVX vector instructions: 5.8x speedup over C implementation Multi-core + hyper-threading + AVX instructions: 21.7x speedup Conclusion: basic C implementation compiled with -O3 leaves a lot of performance on the table CMU 15-418/618, Spring 2020 Making efficient use of modern machines is challenging (proof by assignments 2, 3, and 4) In our assignments, you only programmed homogeneous parallel computers.
    [Show full text]
  • Eagle: Tcl Implementation in C
    Eagle: Tcl Implementation in C# Joe Mistachkin <[email protected]> 1. Abstract Eagle [1], Extensible Adaptable Generalized Logic Engine, is an implementation of the Tcl [2] scripting language for the Microsoft Common Language Runtime (CLR) [3]. It is designed to be a universal scripting solution for any CLR based language, and is written completely in C# [4]. Su- perficially, it is similar to Jacl [5], but it was written from scratch based on the design and imple- mentation of Tcl 8.4 [6]. It provides most of the functionality of the Tcl 8.4 interpreter while bor- rowing selected features from Tcl 8.5 [7] and the upcoming Tcl 8.6 [8] in addition to adding en- tirely new features. This paper explains how Eagle adds value to both Tcl/Tk and CLR-based applications and how it differs from other “dynamic languages” hosted by the CLR and its cousin, the Microsoft Dy- namic Language Runtime (DLR) [9]. It then describes how to use, integrate with, and extend Ea- gle effectively. It also covers some important implementation details and the overall design phi- losophy behind them. 2. Introduction This paper presents Eagle, which is an open-source [10] implementation of Tcl for the Microsoft CLR written entirely in C#. The goal of this project was to create a dynamic scripting language that could be used to automate any host application running on the CLR. 3. Rationale and Motivation Tcl makes it relatively easy to script applications written in C [11] and/or C++ [12] and so can also script applications written in many other languages (e.g.
    [Show full text]
  • Starting up an Application Domain
    04_596985 ch01.qxp 12/14/05 7:46 PM Page 1 Initial Phases of a Web Request Before the first line of code you write for an .aspx page executes, both Internet Information Services (IIS) and ASP.NET have performed a fair amount of logic to establish the execution context for a HyperText Transfer Protocol (HTTP) request. IIS may have negotiated security credentials with your browser. IIS will have determined that ASP.NET should process the request and will perform a hand- off of the request to ASP.NET. At that point, ASP.NET performs various one-time initializations as well as per-request initializations. This chapter will describe the initial phases of a Web request and will drill into the various security operations that occur during these phases. In this chapter, you will learn about the following steps that IIS carries out for a request: ❑ The initial request handling and processing performed both by the operating system layer and the ASP.NET Internet Server Application Programming Interface (ISAPI) filter ❑ How IIS handles static content requests versus dynamic ASP.NET content requests ❑ How the ASP.NET ISAPI filter transitions the request from the world of IIS into the ASP.NET world Having an understandingCOPYRIGHTED of the more granular portions MATERIAL of request processing also sets the stage for future chapters that expand on some of the more important security processing that occurs during an ASP.NET request as well as the extensibility points available to you for modifying ASP.NET’s security behavior. This book describes security behavior primarily for Windows Server 2003 running IIS6 and ASP.NET.
    [Show full text]
  • Data Driven Software Engineering Track
    Judith Bishop Microsoft Research 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 C# 1.0 C# 2.0 C# 3.0 C#4.0 Spec#1.0 Spec# Code CodeCont .5 1.0.6 Contracts racts 1.4 Java 1.5 F# Java 6 F# in VS F# C Ruby on LINQ Python Rails 3.0 Firefox 2 Firefox 3 IE6 Safari 1 IE7 Safari 4 IE8 Safari 5 Windows Windows DLR beta Windows DLR 1.0 XP Vista 7 .NET Rotor Mono 1.0 .NET 2 Rotor 2.0 .NET 3.5 .Net 4.0 Mac OS Ubuntu Mac OS Mac OSX Mac OS X Linux X Intel Leopard XSnow. VS 2003 VS 2005 VS2008 VS2010 Eclipse Eclipse Eclipse 1.0 3.0 3.6 Advantages Uses • Rapid feedback loop (REPL) • Scripting applications • Simultaneous top-down and • Building web sites bottom-up development • Test harnesses • Rapid refactoring and code • Server farm maintenance changing • One-off utilities or data • Easy glue code crunching C# 1.0 2001 C# 2.0 2005 C# 3.0 2007 C# 4.0 2009 structs generics implicit typing dynamic lookup properties anonymous anonymous types named and foreach loops methods object and array optional autoboxing iterators initializers arguments delegates and partial types extension COM interop events nullable types methods, variance indexers generic lambda operator delegates expressions overloading query expressions enumerated types (LINQ) with IO in, out and ref parameters formatted output API Serializable std generic Reflection delegates The dynamic language runtime (DLR) is a runtime environment that adds a set of services for dynamic languages – and dynamic featues of statically typed languages – to the common language runtime (CLR) • Dynamic Lookup • Calls, accesses and invocations bypass static type checking and get resolved at runtime • Named, default and optional parameters • COM interop • Variance • Extends type checking in generic types • E.g.
    [Show full text]
  • Arquitectura .NET
    Distribution and Integration Technologies .NET Architecture Traditional Architectures Web Local Distributed Other applications applications applications applications GUI Network Scripts Data Other Services Services Web Access Services Libraries Execution environment (Posix, Win32, ...) Operating System .NET Architecture 2 Java Architecture Web Local Distributed Other applications applications applications applications Swing Enterprise Java Server JDBC Others Java Beans Pages Standard Java Packages Java Virtual Machine (JVM) Operating System .NET Architecture 3 .NET Architecture Web Local Distributed Other applications applications applications applications Windows Enterprise ASP.NET ADO.NET Others Forms Services .NET Framework Class Library (FCL) Common Language Runtime (CLR) Operating System .NET Architecture 4 Common Language Runtime (CLR) All .NET applications use the CLR The CLR is OO It is independent from high level languages The CLR supports: . A common set of data types for all languages (CTS) . An intermediate language independent from the native code (CIL) . A common format for compiled code files (assemblies) All the software developed using the CLR is known as managed code .NET Architecture 5 Common Type System (CTS) All the languages able to generate code for the CLR make use of the CTS (the CLR implements the CTS) heap There is 2 type categories: string . Value “abcdef” • Simple types stack • Allocated in the stack top class A 41 String: . Reference Double: 271.6 • Complex types • Allocated in the heap • Destroyed automatically
    [Show full text]
  • COPYRIGHTED MATERIAL ➤➤ Chapter 11: Language Integrated Query
    PART I The C# Language ➤➤ CHAPtER 1: .NET Architecture ➤➤ CHAPtER 2: Core C# ➤➤ CHAPtER 3: Objects and Types ➤➤ CHAPtER 4: Inheritance ➤➤ CHAPtER 5: Generics ➤➤ CHAPtER 6: Arrays and Tuples ➤➤ CHAPtER 7: Operators and Casts ➤➤ CHAPtER 8: Delegates, Lambdas, and Events ➤➤ CHAPtER 9: Strings and Regular Expressions ➤➤ CHAPtER 10: Collections COPYRIGHTED MATERIAL ➤➤ CHAPtER 11: Language Integrated Query ➤➤ CHAPtER 12: Dynamic Language Extensions ➤➤ CHAPtER 13: Asynchronous Programming ➤➤ CHAPtER 14: Memory Management and Pointers ➤➤ CHAPtER 15: Reflection ➤➤ CHAPtER 16: Errors and Exceptions c01.indd 1 22-01-2014 07:50:30 c01.indd 2 22-01-2014 07:50:30 1 .NET Architecture WHAt’S IN THiS CHAPtER? ➤➤ Compiling and running code that targets .NET ➤➤ Advantages of Microsoft Intermediate Language (MSIL) ➤➤ Value and reference types ➤➤ Data typing ➤➤ Understanding error handling and attributes ➤➤ Assemblies, .NET base classes, and namespaces CODE DOwNlOADS FOR THiS CHAPtER There are no code downloads for this chapter. THE RElAtiONSHiP OF C# tO .NET This book emphasizes that the C# language must be considered in parallel with the .NET Framework, rather than viewed in isolation. The C# compiler specifically targets .NET, which means that all code written in C# always runs using the .NET Framework. This has two important consequences for the C# language: 1. The architecture and methodologies of C# reflect the underlying methodologies of .NET. 2. In many cases, specific language features of C# actually depend on features of .NET or of the .NET base classes. Because of this dependence, you must gain some understanding of the architecture and methodology of .NET before you begin C# programming, which is the purpose of this chapter.
    [Show full text]
  • COM and .NET Interoperability
    *0112_ch00_CMP2.qxp 3/25/02 2:10 PM Page i COM and .NET Interoperability ANDREW TROELSEN *0112_ch00_CMP2.qxp 3/25/02 2:10 PM Page ii COM and .NET Interoperability Copyright © 2002 by Andrew Troelsen All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN (pbk): 1-59059-011-2 Printed and bound in the United States of America 12345678910 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Technical Reviewers: Habib Heydarian, Eric Gunnerson Editorial Directors: Dan Appleman, Peter Blackburn, Gary Cornell, Jason Gilmore, Karen Watterson, John Zukowski Managing Editor: Grace Wong Copy Editors: Anne Friedman, Ami Knox Proofreaders: Nicole LeClerc, Sofia Marchant Compositor: Diana Van Winkle, Van Winkle Design Artist: Kurt Krames Indexer: Valerie Robbins Cover Designer: Tom Debolski Marketing Manager: Stephanie Rodriguez Distributed to the book trade in the United States by Springer-Verlag New York, Inc., 175 Fifth Avenue, New York, NY, 10010 and outside the United States by Springer-Verlag GmbH & Co. KG, Tiergartenstr. 17, 69112 Heidelberg, Germany. In the United States, phone 1-800-SPRINGER, email [email protected], or visit http://www.springer-ny.com. Outside the United States, fax +49 6221 345229, email [email protected], or visit http://www.springer.de.
    [Show full text]
  • Programming with Windows Forms
    A P P E N D I X A ■ ■ ■ Programming with Windows Forms Since the release of the .NET platform (circa 2001), the base class libraries have included a particular API named Windows Forms, represented primarily by the System.Windows.Forms.dll assembly. The Windows Forms toolkit provides the types necessary to build desktop graphical user interfaces (GUIs), create custom controls, manage resources (e.g., string tables and icons), and perform other desktop- centric programming tasks. In addition, a separate API named GDI+ (represented by the System.Drawing.dll assembly) provides additional types that allow programmers to generate 2D graphics, interact with networked printers, and manipulate image data. The Windows Forms (and GDI+) APIs remain alive and well within the .NET 4.0 platform, and they will exist within the base class library for quite some time (arguably forever). However, Microsoft has shipped a brand new GUI toolkit called Windows Presentation Foundation (WPF) since the release of .NET 3.0. As you saw in Chapters 27-31, WPF provides a massive amount of horsepower that you can use to build bleeding-edge user interfaces, and it has become the preferred desktop API for today’s .NET graphical user interfaces. The point of this appendix, however, is to provide a tour of the traditional Windows Forms API. One reason it is helpful to understand the original programming model: you can find many existing Windows Forms applications out there that will need to be maintained for some time to come. Also, many desktop GUIs simply might not require the horsepower offered by WPF.
    [Show full text]
  • NET Technology Guide for Business Applications // 1
    .NET Technology Guide for Business Applications Professional Cesar de la Torre David Carmona Visit us today at microsoftpressstore.com • Hundreds of titles available – Books, eBooks, and online resources from industry experts • Free U.S. shipping • eBooks in multiple formats – Read on your computer, tablet, mobile device, or e-reader • Print & eBook Best Value Packs • eBook Deal of the Week – Save up to 60% on featured titles • Newsletter and special offers – Be the first to hear about new releases, specials, and more • Register your book – Get additional benefits Hear about it first. Get the latest news from Microsoft Press sent to your inbox. • New and upcoming books • Special offers • Free eBooks • How-to articles Sign up today at MicrosoftPressStore.com/Newsletters Wait, there’s more... Find more great content and resources in the Microsoft Press Guided Tours app. The Microsoft Press Guided Tours app provides insightful tours by Microsoft Press authors of new and evolving Microsoft technologies. • Share text, code, illustrations, videos, and links with peers and friends • Create and manage highlights and notes • View resources and download code samples • Tag resources as favorites or to read later • Watch explanatory videos • Copy complete code listings and scripts Download from Windows Store Free ebooks From technical overviews to drilldowns on special topics, get free ebooks from Microsoft Press at: www.microsoftvirtualacademy.com/ebooks Download your free ebooks in PDF, EPUB, and/or Mobi for Kindle formats. Look for other great resources at Microsoft Virtual Academy, where you can learn new skills and help advance your career with free Microsoft training delivered by experts.
    [Show full text]
  • Appendixes APPENDIX A
    PART 8 Appendixes APPENDIX A COM and .NET Interoperability The goal of this book was to provide you with a solid foundation in the C# language and the core services provided by the .NET platform. I suspect that when you contrast the object model provided by .NET to that of Microsoft’s previous component architecture (COM), you’ll no doubt be con- vinced that these are two entirely unique systems. Regardless of the fact that COM is now considered to be a legacy framework, you may have existing COM-based systems that you would like to inte- grate into your new .NET applications. Thankfully, the .NET platform provides various types, tools, and namespaces that make the process of COM and .NET interoperability quite straightforward. This appendix begins by examin- ing the process of .NET to COM interoperability and the related Runtime Callable Wrapper (RCW). The latter part of this appendix examines the opposite situation: a COM type communicating with a .NET type using a COM Callable Wrapper (CCW). ■Note A full examination of the .NET interoperability layer would require a book unto itself. If you require more details than presented in this appendix, check out my book COM and .NET Interoperability (Apress, 2002). The Scope of .NET Interoperability Recall that when you build assemblies using a .NET-aware compiler, you are creating managed code that can be hosted by the common language runtime (CLR). Managed code offers a number of ben- efits such as automatic memory management, a unified type system (the CTS), self-describing assemblies, and so forth. As you have also seen, .NET assemblies have a particular internal compo- sition.
    [Show full text]
  • Ultimate C#, .Net Interview Q&AE-Book
    Register your resume: www.terrafirmajobs.com _________________________________________________ www.terrafirmajobs.com Ultimate C#, .Net Interview Q&AE-book Free E-books available with Terra Firma Java Interview Q&A Terra Firma’s Interview Kit Are you stressed at your Desk Restore the rhythm of your life IT Resume writing tips Heart-Care Tips To get these free e-books, email to: [email protected] with the title of the e-book. Copy Right Note You are permitted to freely distribute/print the unmodified version of this issue/e-book/article. We are not attempting to obtain commercial benefit from the valuable work of the authors and the Editor/Publisher claims the ‘fair use’ of copyrighted material. If you think that by publishing a particular material, your copyright has been violated, please let us know. The Editor/Publisher is not responsible for statements or opinions expressed herein nor do such statements necessarily express the views of Editor/Publisher. 1 More Career Tips: http://www.terrafirmajobs.com/ITpros/IT_resources.asp?id=4 ______________________________________________________________________________ Register your resume: www.terrafirmajobs.com _________________________________________________ Index Chapter Name Page 1) C# interview Questions and Answers. 4 1.1) Advance C# interview Questions 2) General Questions 17 2.1 ) General Questions 2.2 ) Methods and Property 2.3) Assembly Questions 2.4) XML Documentation Question 2.5) Debugging and Testing 3) ADO.net and Database Question 26 4) C#, DOT NET, XML, IIS Interview Questions 28 4.1 ) Framework. 4.2 ) COM 4.3 ) OOPS 4.4 ) C# Language Features 4.5 ) Access Specifier 4.6 ) Constructor / Destructor 4.7 ) ADO.net 4.8 ) ASP.net 4.8.1) Session.
    [Show full text]
  • Developing ADO.NET and OLE DB Applications
    DB2 ® DB2 Version 9 for Linux, UNIX, and Windows Developing ADO.NET and OLE DB Applications SC10-4230-00 DB2 ® DB2 Version 9 for Linux, UNIX, and Windows Developing ADO.NET and OLE DB Applications SC10-4230-00 Before using this information and the product it supports, be sure to read the general information under Notices. Edition Notice This document contains proprietary information of IBM. It is provided under a license agreement and is protected by copyright law. The information contained in this publication does not include any product warranties, and any statements provided in this manual should not be interpreted as such. You can order IBM publications online or through your local IBM representative. v To order publications online, go to the IBM Publications Center at www.ibm.com/shop/publications/order v To find your local IBM representative, go to the IBM Directory of Worldwide Contacts at www.ibm.com/ planetwide To order DB2 publications from DB2 Marketing and Sales in the United States or Canada, call 1-800-IBM-4YOU (426-4968). When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. © Copyright International Business Machines Corporation 2006. All rights reserved. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Chapter 1. ADO.NET development for .NET common language runtime (CLR) routines . .57 Supported .NET CLR routine development software 58 DB2 databases . .1 Support for external routine development in ADO.NET application development .
    [Show full text]