Microsoft. NET Framework FAQ

Source: Internet
Author: User
Tags exception handling garbage collection memory usage range web services visual studio

Microsoft. NET Framework FAQ

Microsoft Corporation
July 2001
Summary:This article contains common questions about Microsoft. NET and the Microsoft. NET Framework. (15 page printed)


Conceptual issues
Run-time Library Technical Issues
Application Deployment and Isolation
Garbage collection
Remote processing
Security Conceptual Issues
    • What is a. NET framework?
Run-time Library Technical issues


    • What is the common language runtime (CLR)?
    • What is a common type system (CTS)?
    • What is the common Language specification (CLS)?
    • What is Microsoft Intermediate language (MSIL)?
    • What is managed code and managed data?


    • What is an assembly?
    • What are private assemblies and shared assemblies?
    • If you want to build a shared assembly, do you need to sign and manage the system overhead of the key pair?
    • What is the difference between a namespace name and an assembly name?

Application Deployment and Isolation

    • What options are available for deploying. NET applications?
    • I have written an assembly to be used in multiple applications. Where do you deploy it?
    • How do I view an assembly that is installed in the global assembly cache?
    • What is an application domain?

Garbage collection

    • What is garbage collection?
    • How does non-deterministic garbage collection affect code?
    • Can you avoid using a garbage collection heap?

Remote processing

    • What are the working mechanisms in the common language runtime for both in-process and interprocess communication?


    • Can I use COM objects in the. NET Framework program?
    • Can I use the. NET framework components in a COM program?
    • Can I use the Win32 API in the. NET Framework program?


    • What do I have to do to make the code work for the security system?
    • Why do I get a security exception when I run code from a network shared drive?
    • How do I make the code run when the security system stops it?
    • How do I manage the security of personal computers? How do I manage the security of enterprise computers?
    • How is evidence-based security used with Windows 2000 security?
Conceptual Issues

What is a. NET framework?

The Microsoft. NET Framework is a platform for building, deploying, and running WEB services and applications. It provides a high productivity and standards-based multilingual environment for integrating existing investments with next-generation applications and services while providing flexibility to address the deployment and operational challenges of Internet-scale applications. The. NET framework consists of three main components: the common language runtime, A hierarchical collection of unified class libraries and an Active Server Pages assembly called
Back to Top Run-time Library Technical issues


What is the common language runtime (CLR)?

The common language runtime is the execution engine for. NET Framework applications.
It provides a number of services, including:
    • Code management (load and execute)
    • Application Memory Isolation
    • Type-safe authentication
    • IL to native code conversion
    • Access to meta-data (enhanced type information)
    • Management of managed Object memory
    • Enforcement of code access security
    • Exception handling, including inter-language exceptions
    • Interoperate between managed code, COM objects, and pre-existing DLLs (unmanaged code and data)
    • Automation of Object Layout
    • Support for developer Services (analysis, debugging, etc.)

Back to Top

What is a common type system (CTS)?

A common type system is a rich type system built into the common language runtime that supports the types and operations that exist in most programming languages. Universal type Systems support a complete implementation of a wide range of programming languages.
Back to Top

What is the common Language specification (CLS)?

A common language specification is a set of constructs and constraints that act as wizards for library writers and compiler writers. It makes the library fully accessible through any CLS-compliant language and enables those languages to be integrated with one another. The common language specification is a subset of the common type System. The common language specification is also important for application developers who are writing code that will be used by other developers. When developers design publicly accessible APIs in accordance with CLS rules, these APIs can be easily used by all other programming languages that target the common language runtime.
Back to Top

What is Microsoft Intermediate language (MSIL)?

MSIL is a CPU-independent instruction set, which is compiled into the. NET Framework program. It contains instructions to load, store, initialize, and Invoke methods on an object.
After combining with metadata and common type systems, MSIL allows true language integration.
Before execution, the MSIL is converted to machine code and is not interpreted.
Back to Top

What is managed code and managed data?

Managed code is code written for services that target the common language runtime (see "What is the common language runtime?"). ”)。 To target these services, the code must provide the runtime with the lowest level of information (metadata). By default, all C #, Visual Basic. NET, and JScript. NET code are managed. By default, Visual Studio. NET C + + code is not managed, but the compiler can generate managed code by specifying a command-line switch (/clr).
Closely related to managed code is managed data (data that is allocated and released by the common language runtime's garbage collector). By default, C #, Visual Basic, and JScript. NET data are managed. However, you can mark C # data as unmanaged by using special keywords. By default, Visual Studio. NET C + + data is unmanaged (even when the/clr switch is used), but when using Managed Extensions for C + +, you can mark the class as managed by using the __gc keyword. As the name implies, this means that the memory used for the class instance is hosted by the garbage collector. In addition, the class becomes a fully engaged member of the. NET framework community, which brings both benefits and limitations. One benefit is the correct interoperability with classes written in other languages (for example, managed C + + classes can inherit from the Visual Basic Class). One limitation is that a managed class can inherit only from a base class.
Back to Top


What is an assembly?

An assembly is the main building block of a. NET Framework application. It is a collection of functions and is built, versioned, and deployed in the form of a single implementation unit (one or more files). All managed types and resources are either marked as accessible in their implementation units, or are marked as accessible by code outside the unit.
An assembly describes itself by its manifest, which is an integral part of each assembly. The checklist can:
    • Establishes an assembly identity (in the form of a text name), version, culture, and digital signature (if the assembly is shared among applications).
    • Defines the files (hashed by name and file) that make up an assembly implementation.
    • Specifies the types and resources that make up the assembly, including the types and resources that are exported from the assembly.
    • Lists compile-time dependencies on other assemblies.
    • Specifies the set of permissions that the assembly needs to run correctly.

This information is used at run time to resolve references, enforce version binding policies, and verify the integrity of the loading assembly. The runtime can determine and locate the assemblies for any running objects, because each type is loaded in the context of the Assembly. Assemblies are also units that apply code access security permissions. Consider the identity evidence for each assembly, respectively, when determining what permissions are granted to the code that is contained by the Assembly.
The feature of Assembly Self-describing also helps to make it feasible to have no impact installation and XCOPY deployment.
Back to Top

What are private assemblies and shared assemblies?

A private assembly is used only by a single application and is stored in the application's installation directory (or in its subdirectories). A shared assembly is an assembly that can be referenced by multiple applications. In order to share an assembly, you must give the assembly an encrypted strong name (sometimes a strong name), and explicitly build the assembly for this purpose. In contrast, a private assembly name only needs to be unique in the application that uses it.
By distinguishing between private assemblies and shared assemblies, we introduce shared concepts in the form of explicit decisions. By simply deploying a private assembly to the application directory, the application is guaranteed to run only with the bit used to build and deploy it. References to private assemblies are only resolved locally to the private application directory.
You can cite multiple reasons for generating and using shared assemblies, such as the ability to represent version policies. The shared assembly has an encrypted strong name, which means that only the author of this Assembly has a key that produces a new version of the assembly. Therefore, if you generate a policy statement that indicates that you want to accept a new version of the assembly, you should be sure that the version update will be controlled and validated by the author. Otherwise, you do not have to accept them.
For locally installed applications, shared assemblies are typically explicitly installed in the global assembly cache (local caching of assemblies maintained by the. NET Framework). The key to the. NET Framework versioning feature is that the downloaded code does not affect the execution of locally installed applications. The downloaded code is placed in a special download cache and is not globally available on the computer, even though some of the download components are generated in the form of a shared assembly.
The classes that are included with the. NET framework are generated in the form of shared assemblies.
Back to Top

If you want to build a shared assembly, do you need to sign and manage the system overhead of the key pair?

Building a shared assembly does involve using an encryption key. When you build an assembly, only the public key is really needed. Compilers that target the. NET framework provide command-line options (or use custom attributes) when generating assemblies to provide a public key. It is common practice to keep a copy of the common public key in the source database and point the build script to that key. Before the assembly is delivered, the Assembly must be fully signed with the corresponding private key. Use the SDK tool called SN.exe (strong name) to do this work.
Unlike Authenticode, a strong name signature does not involve a certificate. No third-party units, no fees to be paid, no certificate chain. Also, validating a strong name is much lower than verifying the Authenticode system overhead. However, a strong name does not make any statement about whether or not a particular publisher is trusted. A strong name enables you to ensure that the contents of a given assembly are not tampered with, and that the assembly that is loaded on your behalf at run time comes from the same publisher that you were developing against. However, it does not make any statement about whether you can trust the identity of this publisher.
Back to Top

What is the difference between a namespace name and an assembly name?

A namespace is a logical naming scheme for a type in which a simple type name, such as MyType, begins with a dotted-delimited hierarchical name. Such a naming scheme is fully controlled by the developer. For example, type MYCOMPANY.FILEACCESS.A and mycompany.fileaccess.b might logically have functionality related to file access. The. NET framework uses hierarchical naming schemes to divide types into related functions, such as Application framework) or the logical category of remoting capabilities. Designers can use namespaces to make it easier for developers to browse and reference types in code. The concept of namespaces is independent of the concept of an assembly. A single assembly can contain types that have hierarchical names with different namespace roots, whereas logical namespace roots can span multiple assemblies. In the. NET framework, namespaces are logical design-time naming facilities, while assemblies establish the type's range of names at run time.
Back to Top

Application Deployment and Isolation

What options are available for deploying. NET applications?

The. NET framework simplifies deployment by making application-free installation and XCOPY deployment practical. Because all requests are first resolved to the dedicated application directory, you can run the application by simply copying the application's directory file to disk. No registration is required.
This scenario is particularly urgent for Web applications, Web services, and stand-alone desktop applications. In some cases, however, XCOPY is not sufficient as a distribution mechanism. This is the case for applications that have very few proprietary code and are dependent on the availability of shared assemblies, or that applications are not installed locally (but are downloaded on demand). In these cases, the. NET Framework provides a large number of code download services and integration with Windows installer. For the current platform, the code download support provided by the. NET Framework provides some advantages, including incremental downloads, code access security (No other Authenticode dialog boxes), and application isolation (code downloaded on behalf of one application does not affect other applications). Windows Installer is another powerful deployment mechanism that you can use for. NET applications. All of the features of Windows Installer, including publish, advertise, and application repair, apply to the. NET application in Windows Installer 2.0.
Back to Top

I have written an assembly to be used in multiple applications. Where do you deploy it?

Assemblies that will be used by multiple applications, such as shared assemblies, are deployed in the global assembly cache. In pre-release and beta releases, use the/I option of the gacutil SDK tool to install assemblies into the cache:
gacutil/i MyDll.dll

Windows Installer 2.0, which is attached to Windows XP and Visual Studio. NET, enables you to install assemblies into the global assembly cache.
Back to Top

How do I view an assembly that is installed in the global assembly cache?

The. NET Framework provides a Windows shell extension to view the assembly cache. Navigating to% windir%\assembly through Windows Explorer activates the viewer.
Back to Top

What is an application domain?

An application domain (typically AppDomain) is a virtual process for isolating applications. All objects created within the same application scope (in other words, anywhere in the object activation sequence beginning with the application entry point) are created in the same application domain. Multiple application domains can exist in a single operating system process, which makes them a lightweight method for application isolation.
The operating system process provides isolation by providing a unique memory address space. While this works, it is expensive and cannot be scaled to the size required for a large WEB server. On the other hand, the common language runtime enforces application isolation by managing memory usage of code running in the application domain. This ensures that it does not access memory other than the domain boundary. Note It is important that only type-safe code can be managed in this way (the runtime cannot guarantee isolation when unsafe code is loaded into an application domain).
Back to Top

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.