Working with Legacy Code 699

Total Page:16

File Type:pdf, Size:1020Kb

Working with Legacy Code 699 14 0789728222 Ch10 4/7/03 11:08 AM Page 695 O BJECTIVES This chapter covers the following Microsoft-specified objectives for the “Creating User Services” section of Exam 70-315, “Developing and Implementing Web Applications with Microsoft Visual C# .NET and Microsoft Visual Studio .NET”: Incorporate existing code into ASP.NET pages. Add Web server controls, HTML server con- trols, user controls, and HTML code to ASP.NET pages. • Instantiate and invoke an ActiveX control. • Instantiate and invoke Web services or component • Instantiate and invoke a COM or COM+ component. • Call native functions by using platform invoke. Although the .NET Framework can handle nearly all of your application development needs, most organizations have already accumulated a large amount of useful code before they begin using the .NET Framework. It doesn’t make sense to simply throw away this legacy code and rewrite everything from scratch. Fortunately, if you’ve followed rec- ommendations to encapsulate your code into com- ponents over the years, you don’t need to abandon old code to start getting the benefits of the .NET Framework. Instead, you can make use of the .NET Framework’s interoperability features to use several types of legacy code: CHAPTER . ASP pages and ASP.NET pages can co-exist. 10 . ActiveX controls can be placed on Web forms. Component Object Model (COM) and COM+ components can be instantiated and Working with invoked by .NET code. The .NET platform invoke capability (usually Legacy Code referred to as PInvoke) can be used to call the Windows application programming interface (API). 14 0789728222 Ch10 4/7/03 11:08 AM Page 696 O BJECTIVES O UTLINE . By using these interoperability features, you can Introduction 698 ease your migration to .NET development. Making use of legacy components from .NET code means that you can migrate an application piece-by-piece Incorporating Existing Code 699 rather than trying to do it all at once. Running ASP and ASP.NET Together 699 Converting ASP Pages to ASP.NET 701 Using Late-Bound COM Components 702 Using ActiveX Controls 707 Using COM Components 711 Understanding Runtime Callable Wrappers 712 Using the Type Library Importer Tool (tlbimp.exe) 714 Using COM Components Directly 717 Using COM+ Components 719 Using Platform Invoke 723 Chapter Summary 726 Apply Your Knowledge 728 14 0789728222 Ch10 4/7/03 11:08 AM Page 697 S TUDY S TRATEGIES . If you have an existing ASP application, import . If you have an existing COM or COM+ object to the pages to an ASP.NET application and make work with, create a runtime callable wrapper for the changes necessary to run them under the object to investigate the conversion ASP.NET. process. If you don’t have any existing objects, . Convert several ActiveX controls for use in the you can build one with an older version of .NET Framework. Try using the Visual Studio Visual Basic or Visual C++. .NET tools for converting the ActiveX controls. Experiment with PInvoke to invoke some com- mon Windows API calls. 14 0789728222 Ch10 4/7/03 11:08 AM Page 698 698 Part I DEVELOPING WEB APPLICATIONS INTRODUCTION Migrating to a new development platform can be a painful process. In extreme cases, you might have to throw away the results of years of work when you decide it’s time for a new set of tools. This can make switching to a new platform a very difficult decision. Fortunately, Microsoft recognized the need to provide easy migra- tion paths from previous versions of its tools to the .NET world. In particular, if you heeded the advice to use COM for inter- component communications and to design your applications as sets of COM servers and clients, you’ll find the upgrade path to .NET smooth. That’s because the .NET Framework includes good support for interoperating with existing COM-based code. From .NET components, you can easily instantiate and call COM components such as ActiveX controls or COM libraries. (In fact, interoperability works in the other direction, too, with COM com- ponents able to call .NET code, although I won’t cover those tech- niques here.) Combine this with an existing modular architecture, and you get an easy migration path: Move one module at a time from COM to .NET, and use the .NET interoperability features so that the components can continue to talk to one another. In this chapter, you’ll learn about the facilities that the .NET Framework provides for using COM components and other legacy code. In particular, you’ll learn about the tools and techniques that are necessary to call ActiveX controls, COM components, and Windows API code from the .NET Framework. You’ll also see how you can move an existing ASP application to ASP.NET. 14 0789728222 Ch10 4/7/03 11:08 AM Page 699 Chapter 10 WORKING WITH LEGACY CODE 699 INCORPORATING EXISTING CODE Incorporate existing code into ASP.NET pages. Sometimes you have the luxury of starting a new project from scratch, and sometimes you don’t. Many organizations will be imple- menting ASP.NET on the same servers that already host existing ASP applications. Fortunately, ASP and ASP.NET work fine togeth- er. You can continue to run existing ASP pages on your ASP.NET servers, convert the pages to the new format, or move COM compo- nents from ASP pages to ASP.NET pages. In this section, you’ll learn about this level of interoperability. Running ASP and ASP.NET Together ASP and ASP.NET run perfectly well together on the same server. That’s a fundamental consequence of the architecture of the two sys- tems. When you install Internet Information Services (IIS), it associ- ates each file extension that the server understands with a particular application. ASP pages are handled by asp.dll (usually present in the System32\inetsrv folder of the Windows installation directory), whereas ASP.NET pages are handled by aspnet_isapi.dll (usually present in the Microsoft .NET Framework installation directory). Thus there’s no confusion on the part of the server between the two file types, and no need to worry that old pages will be executed incorrectly after you install ASP.NET. ASP pages and ASP.NET pages can even be incorporated into the same ASP.NET application, as you’ll see in the Step by Step 10.1. STEP BY STEP 10.1 Running ASP and ASP.NET Pages Together 1. Open a Visual C# ASP.NET Web application in the Visual Studio .NET IDE. 2. Add a new Web form to your Visual C# .NET project. Name the new Web form StepByStep10_1.aspx. continues 14 0789728222 Ch10 4/7/03 11:08 AM Page 700 700 Part I DEVELOPING WEB APPLICATIONS continued 3. Add two Label controls (lblDate and lblSession) and a HyperLink control to the Web form. Set the Text property of the HyperLink control to “Go to Classic ASP page” and set its NavigateUrl property to StepByStep10_1.asp. 4. Add a new Text File to your Visual C# .NET project. Name the new text file StepByStep10_1.asp. This will make the file an ASP file. 5. Make sure that the ASP file is in HTML view in the designer and add this code to it: <html> <head> <title>Classic ASP page</title> <%@ Language=VBScript %> </head> <body> <% Dim vToday Dim sSession vToday = Date() sSession = Session(“RandomVar”) %> <p>Today’s date is: <%= vToday %></p> <p>The random session variable is: <%= sSession %></p> <p> <a href=”StepByStep10_1.aspx”> Return to ASP.NET page</a> </p> </body> </html> 6. Double-click the ASP.NET Web form and enter the fol- lowing code to handle the Page Load event: private void Page_Load(object sender, System.EventArgs e) { lblDate.Text = “Today’s date is: “ + DateTime.Today; Random r = new Random(); Session[“RandomVar”] = r.Next(1, 1000); lblSession.Text = “The random session variable is: “ + Session[“RandomVar”]; } 14 0789728222 Ch10 4/7/03 11:08 AM Page 701 Chapter 10 WORKING WITH LEGACY CODE 701 7. Set the ASP.NET Web form as the start page for the pro- ject. No Shared State If you run this example, you’ll discover one of the TIP 8. Run the project to display the ASP.NET page. Click the major problems in using ASP and hyperlink to go to the ASP page. You can click the hyper- ASP.NET pages together in the link on that page to return to the original page. same application. Session and EXAM application state is not shared between the two types of pages. If you set a session or application Being able to run both types of pages on the same server is a useful variable in ASP.NET code, there’s no technique, but in the long run you should probably want to migrate way to retrieve it from ASP code, all of your ASP code to ASP.NET code. That will allow you to make and vice versa. use of the improved features of ASP.NET in the applications. Converting ASP Pages to ASP.NET One strategy for migrating an existing ASP application to ASP.NET is to rename the existing files so that they have the aspx extension instead of the asp extension. As soon as you do this, the pages will be delivered by ASP.NET instead of ASP. The syntax of ASP.NET pages is very close to the syntax of ASP pages. But it’s not identical. Here’s a partial list of things you might need to change if you want to convert an existing ASP page to run as an ASP.NET page. á In ASP, you could declare global variables and methods in <%...%> blocks, and they would be visible to all code on the page.
Recommended publications
  • 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]
  • 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]
  • 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]
  • Dot Net Interview Questions
    Dear Friends, Hi I am satish marwat, this documents contains all the important questions that usually asked during the .NET interview, I had downloaded all the material from the Internet from various websites and collected to form a single film, u will find few repeated questions also, all the material are from the various websites, so I had just bind it into a single file. So for any mistake I am not responsible, this is just for the view purpose. My view was only to collect a material to a single file. Please, if u find any mistake in this file, please contact me to my email address [email protected], so that I can able to correct it. ALL THE BEST Thanks Satish J Satish Marwat Dot Net Web Resources [email protected] 1 Page .NET FRAME WORK Introduction 1.1 What is .NET? .NET is a general-purpose software development platform, similar to Java. At its core is a virtual machine that turns intermediate language (IL) into machine code. High-level language compilers for C#, VB.NET and C++ are provided to turn source code into IL. C# is a new programming language, very similar to Java. An extensive class library is included, featuring all the functionality one might expect from a contempory development platform - windows GUI development (Windows Form s), database access (ADO.NET), web development (ASP.NET), web services, XML etc. 1.2 When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET.
    [Show full text]
  • Call C# Dll from Php
    Call c# dll from php click here to download PHP has a built-in Windows-only extension called DOTNET that allows you to www.doorway.ru libraries in a PHP application. Note that you'll need to make sure your assemblies are declared as COM visible: [assembly: ComVisible(true)]. Here are two examples. php $stack = new DOTNET("mscorlib", "System. Build it as dll library output type www.doorway.ru framework ver as target. 4. load it to GAC vA. 5. Get public token from assembly list. 6. Put the token, and the class into php code and let Apache run: php $phpdotnet = new DOTNET("ClassLibraryTestPHP, Version=, Culture=neutral. Net assembly and call its methods and access its properties. $obj = new . exercise to try different type of method signature and calling them in php. www.doorway.ru Code . IMPORTANT NOTE: PHP "caches" the dll library, so every time that the dll library is compiled, the php service should be restarted (restart the apache service). A project of mine requires that I call a dll using php via a COM object call: $obj = new COM("www.doorway.ruObj") or die ("Unable to instantiate the COM!"); This call seems to work ok but the moment I try to call a function from the object using: $result = $obj->put_Name("A") ; none of the code after this. I currently have a classic ASP Web Application, it calls www.doorway.ru dll, setting it up as not easy but its possible. This year we will start moving all the ASP code and MS SQL to MySQL and PHP.
    [Show full text]
  • NET Interoperability Guidelines
    CAPE-OPEN Delivering the power of component software and open standard interfaces in Computer-Aided Process Engineering .NET Interoperability Guidelines www.colan.org ARCHIVAL INFORMATION Filename Interoperability.doc Authors CO-LaN consortium Status Internal Date June 2006 Version version 0.70 Number of pages 43 Versioning Version 0.4 edited by Bill Barrett (US EPA) Version 0.5 edited by Michel Pons (CO-LaN) Version 0.6 edited by Lars von Wedel (AixCAPE) Version 0.61 edited by Lars von Wedel (AixCAPE) Version 0.62 proofread by Michel Pons (CO-LaN) Version 0.70 edited by Lars von Wedel and Bill Barrett Additional material Web location Implementation specifications version Comments 2 IMPORTANT NOTICES Disclaimer of Warranty CO-LaN documents and publications include software in the form of sample code. Any such software described or provided by CO-LaN --- in whatever form --- is provided "as-is" without warranty of any kind. CO-LaN and its partners and suppliers disclaim any warranties including without limitation an implied warrant or fitness for a particular purpose. The entire risk arising out of the use or performance of any sample code --- or any other software described by the CAPE-OPEN Laboratories Network --- remains with you. Copyright © 2006 CO-LaN and/or suppliers. All rights are reserved unless specifically stated otherwise. CO-LaN is a non for profit organization established under French law of 1901. Trademark Usage Many of the designations used by manufacturers and seller to distinguish their products are claimed as trademarks. Where those designations appear in CO-LaN publications, and the authors are aware of a trademark claim, the designations have been printed in caps or initial caps.
    [Show full text]
  • Drill Into .NET Framework Internals to See How the CLR Creates Runtime Objects Hanu Kommalapati and Tom Christian
    JIT and Run Drill Into .NET Framework Internals to See How the CLR Creates Runtime Objects Hanu Kommalapati and Tom Christian This article discusses: This article uses the following . SystemDomain, SharedDomain, and technologies: DefaultDomain .NET Framework, C# . Object layout and other memory specifics . Method table layout . Method dispatching Contents Domains Created by the CLR Bootstrap System Domain SharedDomain DefaultDomain LoaderHeaps Type Fundamentals ObjectInstance MethodTable Base Instance Size Method Slot Table MethodDesc Interface Vtable Map and Interface Map Virtual Dispatch Static Variables EEClass Conclusion Since the common language runtime (CLR) will be the premiere infrastructure for building applications in Windows® for some time to come, gaining a deep understanding of it will help you build efficient, industrial-strength applications. In this article, we'll explore CLR internals, including object instance layout, method table layout, method dispatching, interface-based dispatching, and various data structures. We'll be using very simple code samples written in C#, so any implicit references to language syntax should default to C#. Some of the data structures and algorithms discussed will change for the Microsoft® .NET Framework 2.0, but the concepts should largely remain the same. We'll use the Visual Studio® .NET 2003 Debugger and the debugger extension Son of Strike (SOS) to peek into the data structures we discuss in this article. SOS understands CLR internal data structures and dumps out useful information. See the "Son of Strike" sidebar for loading SOS.dll into the Visual Studio .NET 2003 debugger process. Throughout the article, we will describe classes that have corresponding implementations in the Shared Source CLI (SSCLI).
    [Show full text]
  • Code Access Security
    21a Code Access Security Code Access Security (CAS) allows the CLR to create a locked-down or sandboxed environment that prevents code from performing certain kinds of operations (such as reading operating system files, performing reflection, or creating a user interface). The sandboxed environment created by CAS is referred to as a partial trust environment, whereas the normal unrestricted environment is referred to as full trust . CAS was considered strategic in the early days of .NET, as it enabled the following: • Running C# ActiveX controls inside a web browser (like Java applets) • Lowering the cost of shared web hosting by allowing multiple web sites to run inside the same .NET process • Deploying permission-restricted ClickOnce applications via the Internet The first two are no longer relevant, and the third was always of dubious value, because end-users are unlikely to know or understand the consequences of restricted permission sets prior to installation. And while there are other use-cases for CAS, they are more specialized. A further problem is that the sandbox created by CAS is not entirely robust: Microsoft stated in 2015 that CAS should not be relied upon as a mechanism for enforcing security boundaries (and CAS has been largely excluded from .NET Standard 2.0). This is in spite of the improvements to CAS introduced with CLR 4 in 2010. Sandboxing that does not rely on CAS is still well and alive: UWP applications run in a sandbox, as do SQL CLR libraries. These sandboxes are enforced by the operating system or hosted CLR, and are more robust than CAS sandboxes, as well as being simpler to understand and manage.
    [Show full text]
  • Microsoft NET WP Cover Front.Ai
    white paper Rocket U2 Using U2 and Microsoft® .NET Jianfeng Mao Rajan Kumar Rocket ® bluezone.rocketsoftware.com using U2 and Microsoft® .NET............................................................................................................................................. 1 introduction................................................................................................................................................................................................ 3 overview of Microsoft® .NET................................................................................................................................................. 3 what is the .NET framework?.......................................................................................................................................................4 common language runtime (CLR) ...........................................................................................................................................5 Microsoft intermediate language (MSIL)........................................................................................................................5 managed code................................................................................................................................................................................5 unmanaged code..........................................................................................................................................................................5 class
    [Show full text]