MiRoSoft .NET Framework FAQ (2)
(www.jojoo.net) 2001-3-27 (Please double-click the automatic scroll to watch, click Stop, then hit ..)
What is the difference between the namespace and assembly name?
Namespace is a logical naming scheme of the type, where simple type names (such as MyType) have a hierarchy name separated by point. Such a naming scheme is completely under the control of the developer. For example, type mycompany.fileAccess.a and mycompany.fileAccess.b will have functions that are logically accessible to file access. The .NET framework uses a hierarchical naming scheme to group the type by the logical category of the relevant function, for example, an ASP.NET application framework or remote processing. Design tools can make developers easier to browse and reference types in your code. There is no connection between the concept of name space and the concept of the assembly. A assembly can include the type of its hierarchical name has different namespace roots, and a logical namespace root can span multiple assemblies. In the .NET framework, the namespace is a convenient way to logically naming during design, and the assembly establishes a name roof in the runtime.
Which options can I use when app deployment and isolation deployment .NET application? The .NET framework simplifies deployment by making the application's non-affected installation and XCOPY deployment. Because all requests are first parsed in the dedicated application directory, just simply copy the directory files of an application to the disk, you can run the application without requiring registration.
This solution is particularly attractive for web applications, web services, and separate desktop applications. However, in some scenarios, Xcopy is not enough to take the distribution mechanism. For example, when the application has few special code, depending on the available shared assembly; or the application is not installed locally (but downloaded on demand). For these cases, the .NET framework provides an extended code download service and integration with Windows Installer. The code download support provided by the .NET framework provides many advantages through the current platform, including incremental downloads, code access security (no longer "Authenticode" dialog box) and application isolation (code downloaded for an application does not affect Other applications). Windows Installer is another powerful deployment mechanism that .NET application can use. In Windows Installer 1.5, all features of Windows Installer (including issues, publishing, and application patches) can be used in .NET applications.
If I have written an assembly, I hope to use it in multiple applications, what should I deploy it? To be deployed to the global program cache by multiple applications (such as shared assemblies). In the pre-release and beta, the / i option using the Alink SDK tool can install the assembly to the cache:
AL /I: MYDLL.DLLWINDOWINDOWS Installer's subsequent versions can install the assembly into the global assembly cache.
How can I see which assemblies have been installed in the global assembly cache? The .NET frame comes with a Windows housing extension to view the program set cache. In the Windows Explorer, turn to% Windir% / Assembly to activate the viewer.
What is the application domain? Application domains (usually appdomain) are virtual processes used to isolate applications. All objects created in the same application scope (in other words, starting from the application's entry point) will be created in the same application domain anywhere along the object activation sequence. Multiple application domains can exist in an operating system process that makes them an easy way to isolate applications. The operating system process provides isolation by using different memory address spaces. Although it is effective, it is also expensive, and cannot meet the number of large web servers. Instead, the application isolation is enforced by managing memory usage of code running in the application domain. This ensures that it does not access memory than the application domain. It should be noted that only types of secure code can be managed in this way (isolation is not guaranteed when running inactive code in the application domain).
What is garbage recovery? Garbage Recycling is a mechanism that allows your computer to detect when to access an object. It will automatically release the memory used by the object (also calling the user's clearing routine). Some garbage collectors (as used by .NET) will compress memory and thus reduce the work set of the program.
How does non-deterministic garbage recovery affect code? For most programmers, there is a garbage collector (and objects that can be used as garbage) means that it will never be worried to release memory or reference count objects, even if you use a complex data structure. However, if you usually release system resources (file handle, lock, etc.) in code blocks used to release objects, then you need to make some modifications in coding style. When using objects that can be used as garbage, you should provide a way to explicitly release system resources (that is, controlled by your program) while allowing the garbage collector to release memory during compressed work set.
Can you avoid the use of a pile that can be recovered as garbage? All languages that support runtime allow you to assign a class object from a stack that can be recovered as garbage. This has brought benefits in rapid distribution and makes programmers do not need to calculate when they should explicit "free".
The CLR also provides a ValueTypes object - they are similar to the class, but the valueetype object is allocated in the runtime stack (not pile), so when your code exits defines these objects, they will be automatically recovered. This is the mode of operation of "struct" in C #.
C hosted extensions allow you to select the location of the class object assignment. If the __gc keyword is declared as a hosted class, they will be allocated from a heap that can be recovered as garbage; if they do not include the __gc keyword, they will allocate from the C bile as the normal C object, and use "free "The method explicitly released.
For more information on garbage collection, see:
Garbage Recycling: Automatic Memory Management in Microsoft .NET Frame (English)
Garbage Recycling - Part 2: Automatic Memory Management in Microsoft .NET Frame (English)
How to communicate inter-process communication between processes and processes in the process of running in public language runtime? There are two communication in the process: in the context of a single application domain, or cross-use program domain. In the context of the same application domain, the agent is used as the listening mechanism without related to sealing processing / serialization. When using the application domain, use the runtime binary protocol to seal processing / serialization.
Inter-process communication uses an insertable channel and formatting program protocol for each particular purpose.
If the developer specifies the endpoint to generate a metadata agent using the SOAVSUDS.EXE tool, the default value is an HTTP channel with the SOAP formatting program. If the developer performs explicit remote processing in the hosted world, it is necessary to specify the channels and formatting programs used. This can be represented by the configuration file, or use API calls to load a specific channel. The options are as follows: HTTP channels with SOAP formatted programs (HTTP are working well on the Internet or any must be communicated through the firewall)
TCP channel with binary formatting procedures (for local area network, TCP is high performance option)
SMTP channel with SOAP formatting program (meaning only across computers)
When the transition is performed between the managed code and the non-hosting code, the COM infrastructure (especially DCOM) is used for remote processing. In the intermediate version of the CLR, this also applies to service components (components of COM services). In the final version, all remote components are all possible.
The distributed garbage collection of objects is managed by systems named "leased survival". Each object has a rental time that is disconnected from the CLR remote processing infrastructure when expired. The object has a default update time - the rent will be updated when the client successfully calls an object. The client can explicitly update rental.
Can interoperability use COM objects in the .NET framework program? Yes. Any COM components you are now deploying can be used in managed code. Normally, the required adjustment is completely automated.
In particular, you can use the runtime to call the COM component from the .NET framework. This packaging converts the COM interface provided by the COM component to an interface compatible with the .NET framework. For OLE Automation Interfaces, RCW can automatically generate from the type library; for non-OLE automation interfaces, developers can write custom RCWs, manually map the type of types provided by the COM interface to the type compatible with the .NET framework.
Can I use the .NET Framework component in a COM program? Yes. You can use the managed type you now access to COM. Normally, the required configuration is completely automated. Some new features of the hosted development environment cannot be accessed in COM. For example, a static method and a parameterized constructor cannot be used in COM. Typically, it is a good way to determine the user for a given type in advance. If the type needs to be used in COM, you will be restricted to use COM accessible features.
By default, managed types may be visible, or may be invisible, which is determined by the language used to write managed types.
In particular, you can use COM to access the .NET framework component from the COM. This is similar to RCW (see the previous problem), but their direction is opposite. Similarly, if the .NET framework development tool cannot automatically generate a package, or if the automatic mode is not what you need, you can develop a custom CCW.
Can I use Win32 API in the .NET framework? Yes. Using P / Invoke, the .NET Framework program can access the native code base by static DLL entry points.
Below 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);}}
How does security work in coordination between code and security system? Usually, this is not problematic - Most applications can run safely and will not be disturbed by malicious attacks. Security is implemented by these libraries by simply using standard class libraries to access resources (such as files) or perform protected operations (such as reverse type private members). A simple job that application developers need to complete is to include permission requests (a disclosed security), which limits the permissions that the code may receive within the permission range it needs. This also ensures that if the code is allowed to run, it will have the required permissions when runtime.
They only need to directly process the security system only when developers need to write new base libraries that provide new resources. In this case, not all the code has potential security issues, and the code access security mechanism limits it on the part of the security system.
Why do security exceptions occur when running code in a network shared drive? The default security policy only grants limited permissions from the code from the local intranet area. This area is defined by Internet Explorer security settings, which should be configured to match the local network within the company. Since files named by UNC or mapping drives (eg, using NET USE commands) need to be sent on the local network, they are also in the local Intranet area.
The default is set for unsafe intranet this worst case. If your intranet is secure, you can modify the security policy (with the Caspol tool) to grant more permissions to local intranet or part (such as a specific computer sharing name).
How to write code so that it runs when the security system stops this code? Safety exceptions will occur when the code is attempting to perform unauthorized operations. Permissions are granted based on code (especially its location). For example, the permissions obtained from the code running in the Internet are less than the permissions resulting from the code running on the local computer, because of the proven, its reliability is low. Therefore, you have to run the code that failed due to safety exceptions, you must add permission to grant it. A simple way is to move the code to a more trusted location (such as a local file system). But this method is not effective in any case (the web application is a good example, and the intranet application on the enterprise network is another example). Therefore, do not change the code location, but give this location more permissions by changing security policies. Use the code access security policy tool (Caspol.exe) or graphical management tool (available in Beta 2 and later) to do this. If you are a developer or issuer of the code, you can also digitally sign it, then modify the security policy, grant more permissions to the code with the digital signature. However, when performing any of the above operations, remember that this code is granted less permissions because it is not from trusted sources - before moving the code, you should make sure you should make sure these code Will not perform malicious or damaged operations.
How to manage personal or corporate computers? Currently, the Caspol command line tool is the only way to manage security. The security policy consists of two levels: pressing the computer and by the user. We plan to provide comprehensive management tools and enterprise policy management support in the first edition of the .NET Framework.
How is the security of evidence work with Windows 2000 security work? Evidence-based security (based on the authorization code) can work with Windows 2000 security (based on login identity). For example, to access a file, the hosted code must have code access security file permissions, and must also run under the login identity of NTFS file access. The checkered library included in the .NET framework provides classes for role-based security. These make the application work with Windows login identity and user group work.