Microsoft. NET Framework FAQs

Source: Internet
Author: User

Concept
What is. Net?
To put it simply, Microsoft. NET is a policy for Microsoft to submit software as a service. For more information, see the white paper on this topic ).

The following is a brief introduction to. net:

Microsoft. NET platform
This includes creating and operating next-generation services.. net infrastructure and tools for implementing multi-information clients.. Net user experience, and used to enable a new generation of Smart Internet devices. net to construct the block service and. net device software.

Microsoft. NET products and services
Including Microsoft Windows. net (its core integrates a group of constructed block services), MSN. net, personal subscription service, Microsoft Office.. net, Microsoft Visual Studio. net and Microsoft bcentral.. net.

Third-party. Net Services
Partners and developers in many fields have the opportunity to provide enterprise and vertical services on the. NET platform.
This issue is targeted at the. NET Framework .. The. NET Framework is part of the basic structure of the. NET platform. For more information about the. NET Framework, see the next question.

What Is A. NET Framework?
The. NET Framework is used to create, deploy, and run Web Services and other applications.Program. It consists of three main parts: runtime of Public languages, framework classes, and ASP. NET.

Is the. NET Framework only applicable to users who create Web sites?
The. NET framework allows you to create excellent web applications. However, it can also help you create various existing applications. Compared with the current method of creating an application,. Net has a greater advantage in writing any Windows software (using ATL/COM, MFC, Microsoft Visual Basic, or standard Microsoft Win32. Of course, if you are developing a web site, you will feel the strong appeal of the. NET Framework from ASP. NET.

Where can I obtain the. NET Framework SDK?
You can download the Beta 1 version of the. NET Framework SDK from msdn Online downloads. Given its size, we provide this beta version in multiple ways: as a download file (106 MB), it is divided into 11 parts for download, or order its CD from Microsoft developer store:

US/Canada (English)

International (English)

Which platforms can the. NET Framework run on?
Beta 1 can run on Microsoft Windows 2000, Windows 95/98/ME, and Windows NT 4.0.

In addition, there is also a. NET Framework version called the. NET simplified framework. It is used to enable devices such as cell phones and enhanced TVs to also have some features of the. NET Framework .. . NET will run on Windows CE and other embedded operating systems.

What are supported by the. NET Framework?Programming Language?
The. NET Framework has nothing to do with programming languages. In fact, any language supports the. NET Framework. Currently, you can create. net programs in many languages, including C ++, Microsoft Visual Basic. net, JScript, and Microsoft's latest language-C #. In the future, there will also be a large number of third-party languages that can be used to create. NET Framework applications, including COBOL, Eiffel, Perl, Python, smalltalk, and so on.

What is the relationship between the. NET Framework and the COM + service?
In the. NET Framework, you can not only completely access the COM + service, but also easily create service components.

. NET Framework components can be added to COM + applications. In COM + applications,. NET Framework components can use automatic component services, such as transactions, object pools, queuing components, and events.

What is the relationship between the. NET Framework and DCOM?
DCOM is the basic structure of COM used for inter-process communication .. Net Framework supports a large number of pluggable channels and formatting programs for inter-process communication. In hostingCodeDuring conversion between unmanaged code, the. NET Framework uses the com infrastructure, especially DCOM. All the solutions that use the COM + service use the managed-to-unmanaged conversion, so DCOM is used by default. For inter-process communication that focuses on interoperability, the. NET Framework also supports soap (Simple Object Access Protocol ).

Is the. NET Framework just a new name for Windows DNA?
No. Windows DNA is an architecture used to create tightly coupled distributed Web applications. As distributed applications become more loosely coupled, Microsoft has developed this architecture in. net .. The. NET Framework is part of the. NET architecture.

Technical problems during running
Terms
What is the common language runtime (CLR )?
The Common Language Runtime is the execution engine of. NET Framework applications.

It provides many services, including:

Code Management (loading and execution)

Application memory isolation

Type security verification

Il-to-Local Code Conversion

Metadata (Enhanced type information) Access

Manage memory for Managed Objects

Enforce code access security

Exception Handling, including cross-language exceptions

Interoperability Between hosted code, COM objects, and existing DLL (unmanaged code and data)

Automatic Object Layout

Support for developer services (configuration, debugging, etc.)

What is a common type System (CTS )?
A public-type system is a multi-information-type system that is built into the runtime of a public language and supports types and operations in most programming languages. Public systems support full implementation of a large number of programming languages.

What is CLS )?
A common language specification is a set of structures and Restrictions used as a guide for database writers and compiler writers. It allows all languages that support Cls to fully use libraries and enable these languages to integrate with each other. The public language specification is a subset of Public-type systems. Common Language Standards are also important for application developers who need to write code for other developers. If developers follow the CLS rules to design public-access APIs, they can be easily used in any other programming language that supports the runtime of Public languages.

What is Microsoft intermediate language (msil )?
Msil is a CPU-independent instruction set .. NET framework program is compiled into msil. It contains commands for loading, storing, initializing, and calling object methods.

Combined with metadata and public-type systems, msil allows true cross-language integration.

Msil is converted to machine code before execution, rather than being interpreted and executed.

What is managed code and managed data?
Managed code is written as code that supports runtime services in public languages (see "What Is runtime in public languages ?"). To support these services, the Code must provide the minimum level of information (metadata) to the runtime ). By default, all C #, Visual Basic. net, and JScript. Net code are hosted code. Visual Studio. net c ++ code is not hosted by default. However, by specifying the command line switch (/CLR), the compiler can also generate managed code.

Managed Data is closely related to managed code. Managed Data is the data that is allocated and released by the garbage collector when the public language is running. By default, C #, Visual Basic, and JScript. NET data are hosted data. However, by using special keywords, C # data can be labeled as unmanaged data. Visual Studio. net C ++ data is not hosted by default (even when/CLR is enabled), but when C ++'s managed extension is used, you can use the "_ GC" keyword to mark the class as a Managed class. As shown in the name, it indicates that the memory of the class instance is managed by the garbage collector. In addition, this class has completely become a member of the. NET Framework and has the benefits and restrictions it brings. An example of the benefit is that it can correctly interoperate with classes written in other languages (for example, hosted C ++ classes can be inherited from visual basic classes); an example of the limitation is: managed classes can only inherit from one base class.

Assembly
What is an assembly?
An assembly is the main construction block of. NET Framework applications. It is a set of functions used to create, identify, and deploy a single implementation unit (including one or more files. All managed types and resources can be marked as only accessible within their implementation units, or marked as accessible by code other than this unit.

The Assembly describes itself through the list. A list is an indispensable component of each Assembly. List:

Create an assembly identifier (in text name format), version, category, and digital signature (if you want to share the Assembly between applications ).

Defines the files that constitute the Assembly implementation (by name and file hash ).

Specifies the types and resources that constitute the assembly, including which are exported from the Assembly.

Record dependencies on other sets one by one during compilation.

Specifies the set of permissions required for the correct running of the Assembly.
This information is used at runtime to parse references, enforce version binding policies, and verify the integrity of the loaded assembly. Because each type is loaded into the context of the Assembly, the runtime can determine and locate the assembly of any running object. An assembly is also a unit that applies the code access security permissions. When determining which permissions are granted to the code it contains, the identification evidence of each Assembly is considered independent.

The self-explanatory feature of the Assembly also helps achieve installation without impact and xcopy deployment.

What is a private assembly and a shared assembly?
Private assembly is only used by a single application and stored in the installation directory (or its subdirectories) of the application ). A shared assembly is an assembly that can be referenced by multiple applications. To share an assembly, the Assembly must be explicitly created for this purpose, which can be achieved by specifying an encrypted enhanced name (used as a shared name) for it. Instead, the private assembly name must be unique only in the application that uses it.

By distinguishing between private and shared assemblies, we will introduce the key points for determining the sharing. Simply deploy the dedicated assembly in the application directory to ensure that the application runs only in the part where it is created and deployed. Reference to a private assembly is parsed only within the private application directory.

You can choose to create and use a shared assembly for multiple reasons, such as expressing version policies. The fact that a shared assembly has an encrypted enhanced name means that only the creator of the Assembly has a key to generate a new version of the Assembly. Therefore, if you make a policy declaration and want to accept the new version of the assembly, you can be sure that the version update will be controlled and verified by the author. Otherwise, you will not accept them.

For locally installed applications, the shared assembly is usually explicitly installed in the Global Assembly Cache (the local cache of the Assembly is maintained by the. NET Framework ).. The key to the version management feature of the. NET Framework is that the downloaded code does not affect the execution of locally installed applications. The downloaded code is stored in a special download cache. Even if some download components are compiled as shared assembly, they cannot be used globally on the machine.

Classes released together with the. NET Framework are compiled into shared assembly.

If I want to create a shared assembly, do I need additional overhead in marking and managing key pairs?
Creating a shared Assembly does involve encryption keys. When creating an assembly, only the public key is necessary. Compilers that support the. NET Framework provide command line options (or use custom attributes) to provide public keys when creating an assembly. A common public key is usually retained in the resource database, and the compilation script points to this key. Before releasing an assembly, you must use the corresponding private key to fully mark it. This is done through the SDK tool sn.exe (enhanced name.

Unlike Authenticode, the enhanced name tag requires a certificate. It does not involve Third-Party organizations, does not require payment, and is not subject to certificate constraints. In addition, the additional overhead for verifying the enhanced name is much less than the overhead for verifying the Authenticode. However, an enhanced name does not generate statements that trust a publisher. The enhanced name makes sure that the content of the given assembly is not tampered with and that the Assembly you load at runtime comes from the publisher you developed. However, it does not generate statements about whether to trust the publisher's identity.

What is the difference between the namespace and the Assembly name?
A namespace is a type logical naming scheme. A simple type name (such as mytype) is preceded by a hierarchical name separated by points. Such a naming scheme is completely under the control of developers. For example, if you type mycompany. fileaccess. A and mycompany. fileaccess. B, you will logically have file access-related functions .. The. NET Framework uses a hierarchical naming scheme to group types by logical category of related functions, such as ASP. NET application framework or remote processing. The design tool can use namespaces to make it easier for developers to browse and reference types in code. There is no connection between the concept of a namespace and the concept of an assembly. An assembly can contain the types of its hierarchical structure names with different namespaces, while a logical namespace root can span multiple assemblies. In the. NET Framework, a namespace is a convenient way to perform logical naming during design, while an Assembly creates a name scope for the type at runtime.

Application Deployment and isolation
What options can be used to deploy. NET applications?
The. NET framework simplifies the deployment by making installation and xcopy deployment of applications unaffected. Because all requests are first parsed in the dedicated application directory, you only need to copy the directory file of an application to the disk to run the application without registration.

This solution is particularly attractive to Web applications, Web Services, and independent desktop applications. However, in some scenarios, xcopy is not enough to serve as a distribution mechanism. For example, when an application has very little dedicated code and relies on available shared assembly, or the application is not installed locally (but downloaded on demand ). In these cases, the. NET Framework provides extended code download services and integration with Windows Installer .. Net Framework provides code download support through the current platform provides many advantages, including incremental download, code access security (there is no "Authenticode" dialog box) isolated from applications (the code downloaded for an application does not affect other applications ). Windows Installer is another powerful deployment mechanism that can be used by. NET applications. In Windows Installer 1.5, all features of Windows Installer (including release, publish, and application patching) can be used in. NET applications.

If I have compiled an assembly and want to use it in multiple applications, where should I deploy it?
The assembly to be used by multiple applications (such as shared assembly) needs to be deployed to the global assembly cache. In pre-release and beta versions, use the/I option of the alink SDK tool to install the Assembly into the cache:

Al/I: mydll. dll
Later versions of Windows Installer can install the Assembly into the global assembly cache.

How can I see which assembly is installed in the global assembly cache?
The. NET Framework comes with a Windows Shell extension used to view the Assembly Cache. In Windows Resource Manager, go to % WinDir % \ assembly to activate the viewer.

What is an application domain?
An application domain (usually appdomain) is a virtual process used to isolate an application. All objects created in the same application scope (in other words, from the entry point of the application to any place in the object activation sequence) are created in the same application domain. Multiple application domains can exist in an operating system process, making them an easy way to isolate applications.

Operating system processes are isolated by using different memory address spaces. Although it is effective, it is expensive and cannot meet the needs of large Web servers. In contrast, when running in a common language, application isolation is enforced by managing the memory usage of the code running in the application domain. This ensures that it does not access the memory outside the application domain. Note that only type-safe code can be managed in this way (runtime isolation cannot be guaranteed when Insecure code is loaded in the application domain ).

Garbage Collection
What is garbage collection?
Garbage collection is a mechanism that enables computers to detect when an object is no longer accessible. It will automatically release the memory used by the object (also called the "Terminator" cleaning routine written by the user ). Some garbage collectors (such as those used by. Net) compress the memory and reduce the working sets of the program.

How does uncertain garbage collection affect code?
For most programmers, having a garbage collector (and using objects that can be recycled as garbage) means never having to worry about releasing memory or referencing counting objects, even if you use a complex data structure. However, if you usually release system resources (file handles, locks, and so on) in the same code block used to release the object memory, you need to modify the encoding style. When using garbage collection objects, you should provide a method to explicitly release system resources (that is, controlled by your program ), meanwhile, the garbage collector is allowed to release memory when compressing the working set.

Can I avoid using a heap that can be used as garbage collection?
All runtime languages allow you to allocate class objects from the heap that can be used as garbage collection. This brings benefits in fast allocation, and allows programmers not to calculate when to explicitly "free" each object on their own.

CLR also provides valuetypes objects-they are similar to classes, but valuetype objects are allocated in the runtime stack (not heap, therefore, when your code exits the process of defining these objects, it will be automatically recycled. This is the "struct" operation method in C.

The hosting extension of C ++ allows you to select the Class Object allocation location. If the _ GC keyword is declared as a Managed class, they are allocated from the heap that can be used as garbage collection; if they do not contain the _ GC keyword, they will be allocated from the C ++ heap like normal c ++ objects, and are explicitly released using the "free" method.

For more information about garbage collection, see:

Garbage Collection: Automatic Memory Management in the Microsoft. NET Framework)

Garbage collection-Part 1: Automatic Memory Management in the Microsoft. NET Framework)

Remote Processing
How can we conduct intra-process and inter-process communication in the public language runtime?
There are two types of intra-process communication: in the context of a single application domain, or across application domains. In the context of the same application domain, the proxy is used as the listening mechanism, without sending/serializing packets. When cross-application domains are used, the runtime binary protocol is used for sending, processing, and serialization.

Inter-process communication uses a pluggable channel and formatting protocol for each specific purpose.

If a developer uses the soapsuds.exe tool to specify an endpoint to generate a metadata proxy, the default value is the HTTP channel with the soap formatter.

If developers execute explicit remote processing in the hosted world, you need to specify the channel and formatting program to use. This can be represented by a configuration file in a manageable way, or by calling an API to load a specific channel. The options are as follows:
HTTP channel with soap formatting Program (HTTP runs well on the Internet or any communication that must be performed through the firewall)

TCP channel with binary formatting (for LAN, TCP is an option with High Performance)

SMTP channel with soap formatting Program (valid only for cross-computer)

The com infrastructure (especially DCOM) is used for remote processing when the hosted and unmanaged code are converted. In the intermediate version of CLR, this applies to service components (components using COM + services ). In the final version, it is possible to configure any remote components.

The distributed garbage collection of objects is managed by a system named "lease lifetime. Each object has a lease time. When it expires, the object is disconnected from the CLR remote processing infrastructure. The object has a default Update time. When the client successfully calls the object, the lease is updated. The client can explicitly update the lease.

Interoperability
Can I use COM objects in. NET Framework programs?
Yes. Any COM component you deploy now can be used in managed code. Generally, the necessary adjustments are completely automatic.

In particular, you can use runtime callable packaging (RCW) to access COM components from the. NET Framework. This package converts the COM interface provided by the COM component to an interface compatible with the. NET Framework. For OLE Automation interfaces, RCW can be automatically generated from the Type Library; for non-OLE Automation interfaces, developers can write custom RCW and manually map the types provided by the COM interface.. NET Framework compatible type.

Can I use the. NET Framework component in a com program?
Yes. All the managed types you create can be accessed through COM. Generally, the configuration is completely automatic. Some new features of the managed development environment cannot be accessed in COM. For example, static methods and parameterized constructors cannot be used in COM. Generally, it is a good way to determine the users for a given type in advance. If the type needs to be used in COM, you will be restricted in using the accessible features of COM.

By default, the managed type may be visible or invisible, which is determined by the language used to write the managed type.

In particular, you can use com callable packaging (CCW) to access. NET Framework components from Com. This is similar to RCW (see the previous issue), but they are in the opposite direction. Similarly, if the. NET Framework development tool cannot automatically generate packaging, or if the automatic method is not what you need, you can develop a custom CCW.

Can Win32 APIs be used in. NET Framework programs?
Yes. With P/invoke, the. NET Framework Program can access the local code library through the static DLL entry point.

The following is an example of C # calling the Win32 MessageBox function:

Using system;
Using system. runtime. interopservices;

Class mainapp
{
[Dllimport ("user32.dll", entrypoint = "MessageBox")]
Public static extern int MessageBox (INT hwnd, string strmessage, string strcaption, uint uitype );

Public static void main ()
{
MessageBox (0, "Hello, this is pinvoke! ",". Net ", 0 );
}
}

Security
How can I coordinate code with the security system?
Generally, this is not a problem-most applications can run securely without being disturbed by malicious attacks. By simply using standard class libraries to access resources (such as files) or performing protected operations (such as reverse type private members), security is implemented by these libraries. One simple task that an application developer needs to do is to include permission requests (a public security) and restrict the permissions that the Code may receive to the permissions it requires. This also ensures that if the code is allowed to run, it will have all the required permissions at runtime.

Only when developers need to write new base class libraries that provide new resources, they need to directly process the security system. In this case, not all codes have potential security issues. The code access security mechanism limits them to the part of the Code that replaces the security system.

Why is a security exception occurring when running code in a network shared drive?
By default, the security policy only grants limited permissions to codes from the local Intranet region. This region is defined by Internet Explorer security settings and should be configured to match the local network in the enterprise. Because files named by UNC or ing drives (such as using the net use command) need to be sent over the local network, they are also in the Local intranet region.

The default value is set for the worst case of insecure intranet. If your intranet is secure, you can modify the Security Policy (using the caspol tool) and grant more permissions to the local Intranet or a part of it (such as a specific computer sharing name.

How do I write code so that it runs when the security system stops the code?
Security exceptions occur when the Code tries to perform unauthorized operations. Permissions are granted based on code (especially its location. For example, the permission for Running code on the internet is less than that for Running code on a local computer. This is because experience has proved that it is less reliable. Therefore, to run code that fails due to a security exception, you must grant it the permission. A simple method is to move the code to a more trusted location (such as a local file system ). However, this method is not always effective in any situation (web applications are a good example, and intranet applications on the enterprise network are another example ). Therefore, do not change the code location, but grant more permissions to the location by changing the security policy. Use the code access security policy tool (caspol.exe) or graphical management tool (available in Beta 2 and later versions) to perform this operation. If you are a code developer or publisher, you can also sign the Code, modify the Security Policy, and grant more permissions to the Code with the digital signature. However, when performing any of the preceding operations, remember that this code has been granted fewer permissions, it is because it is not from a trusted source-before moving code to a local computer or changing security policies, you should ensure that the Code does not perform malicious or corrupt operations.

How to manage the security of personal or enterprise computers?
Currently, the caspol command line tool is the only way to manage security. A security policy consists of two levels: by computer and by user. We plan to provide comprehensive management tools and enterprise policy management support in the first version of the. NET Framework.

How does evidence-based security work with Windows 2000 Security?
Evidence-based security (based on authorization code) can work with Windows 2000 Security (based on logon identity. For example, to access a file, the managed code must have the security file access permission for the code, and must also run under the login identity with the NTFS file access permission .. The role library included in the. NET Framework also provides classes for role-based security. These enable the application to work with the Windows logon identity and user group.

Author: Benjamin from: www.dircity.com

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: info-contact@alibabacloud.com 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.