Difference between a Debug and Release build?
Debug mode and Release mode are different configurations for building your .Net project. Programmers generally use the Debug mode for debugging step by step their .Net project and select the Release mode for the final build of Assembly file (.dll or .exe).The Debug mode does not optimize the binary it produces because the relationship between source code and generated instructions is more complex. This allows breakpoints to be set accurately and allows a programmer to step through the code one line at a time. The Debug configuration of your program is compiled with full symbolic debug information which help the debugger figure out where it is in the source code.
Is Release mode is faster than Debug mode ?
The Release mode enables optimizations and generates without any debug data, so it is fully optimized. . Lots of your code could be completely removed or rewritten in Release mode. The resulting executable will most likely not match up with your written code. Because of this release mode will run faster than debug mode due to the optimizations.
What is .pdb files ?
Debug information can be generated in a .pdb (Program Database File) file depending on the compiler options that are used. A .pdb file holds debugging and project state information that allows incremental linking of a Debug configuration of your program. A Program Database File is created when you compile a VB.Net or C# program with debug mode.
In Asp.Net ?
It is important to note that Debug mode or Release mode in a web application is controlled by the web.config file, not your settings within Visual Studio.
e.g.
<system.web>
<compilation debug="true">
Difference between normal DLL and .Net DLL
dll: A .dll file contains compiled code you can use in your application to perform specific program functions and may be required by another application or module (such as .exe or .dll) to load it through an entry point. It is a library that contains code and data that can be used by more than one program at the same time. It helps promote modularization of code, code reuse, efficient memory usage, and reduced disk space. So the operating system and the programs load faster, run faster, and take less disk space on the computer.What is .Net dll ?
When you implement a .Net DLL (Assembly) in .NET Languages such as C# or VB.NET you produce a Managed Assembly. Managed Assembly is the component standard specified by the .NET. Hence, .Net assemblies are understandable only to Microsoft.NET and can be used only in .NET managed applications. A manage assembly contains managed code and it is executing by the .NET Runtime. When you create a DLL with C++ you produce a win32/Com DLL. If you use this dll in a .NET Language, the Visual Studio create automatically an INTEROP file for you, so you can call the "unmanaged" dll from manage code .
For using a .Net DLL (Assembly), the simplest option is to copy the dll to the bin folder. Normal DLL files are need to be register with the "regsvr32" tool.
Difference between a thread and a process
The processes and threads are independent sequences of execution, the typical difference is that threads run in a shared memory space, while processes run in separate memory spaces.A process has a self contained execution environment that means it has a complete, private set of basic run time resources purticularly each process has its own memory space. Threads exist within a process and every process has at least one thread.
Each process provides the resources needed to execute a program. Each process is started with a single thread, known as the primary thread. A process can have multiple threads in addition to the primary thread.
On a multiprocessor system, multiple processes can be executed in parallel. Multiple threads of control can exploit the true parallelism possible on multiprocessor systems.
Threads have direct access to the data segment of its process but a processes have their own copy of the data segment of the parent process.
Changes to the main thread may affect the behavior of the other threads of the process while changes to the parent process does not affect child processes.
Processes are heavily dependent on system resources available while threads require minimal amounts of resource, so a process is considered as heavyweight while a thread is termed as a lightweight process.
What is multithreading ?
In .NET languages you can write applications that perform multiple tasks simultaneously. Tasks with the potential of holding up other tasks can execute on separate threads is known as multithreading.
Differences between a control and a component
Control and a Component ?
A component is a class that implements the IComponent interface or that derives directly or indirectly from a class that implements IComponent.public class BaseComponent : IComponent {}
A component does not draw itself on the form, but a control draws itself on the form or on another control. Both the Components and the Controls can be dropped onto a design surface. If you double click the item on the toolbox and it will get placed inside the form then it the item known as Controls where as the item placed below the form area (component tray) then it is known as component.
e.g. Timer is a component and that has no visual representation during runtime, but you can see it in the component tray during the design time. Progress Bar is a control and it has visual representation in both design time and runtime.
All controls are also components, but not all components are controls.
You can create a component if you want to provide functionality without UI such as with the BackgroundWorker component, then you would only need to derive from Component directly. e.g. Timer , Data Source etc.. You can create a custom control if you want to make a component where you have full control over its visual appearance. e.g. Textbox , Button etc.
Globalization and Localization
Globalization allows your web application to be useful for different people in different parts of the world who speaks different languages. ASP.Net makes it easy to localize an application through the use of resource files. Resource files are xml files with .resx extension. Resources can either be a global resource, in which it is accessible throughout the site and placed in App_GlobalResources folder in a website or a local resource which is specific to a page only and is placed in App_LocalResources folder.
What is .Net Localization ?
Localization is the process of translating an application's resources into localized versions for each culture that the application will support. Localization support is possible to automatically detect the user's culture and to respond to that detection with properly formatted dates, currency and other numeric values, properly configured controls etc. You should proceed to the localization step only after completing the Localizability step to verify that the globalized application is ready for localization.
For each localized version of your application, add a new satellite assembly that contains the localized user interface block translated into the appropriate language for the target culture. The code block for all cultures should remain the same. The combination of a localized version of the user interface block with the code block produces a localized version of your application.
CultureInfo Class ,Provides information about a specific culture . The information includes the names for the culture, the writing system, the calendar used, and formatting for dates and sort strings.
Difference between managed and unmanaged code
Managed code C#Managed code is the code that is written to target the services of the managed runtime execution environment such as Common Language Runtime in .Net Technology.
The Managed Code running under a Common Language Runtime cannot be accessed outside the runtime environment as well as cannot call directly from outside the runtime environment. It refers to a contract of cooperation between natively executing code and the runtime. It offers services like garbage collection, run-time type checking, reference checking etc. By using managed code you can avoid many typical programming mistakes that lead to security holes and unstable applications, also, many unproductive programming tasks are automatically taken care of, such as type safety checking, memory management, destruction of unused Objects etc.
What is Unmanaged Code ?
Unmanaged code compiles straight to machine code and directly executed by the Operating System. The generated code runs natively on the host processor and the processor directly executes the code generated by the compiler. It is always compiled to target a specific architecture and will only run on the intended platform. So, if you want to run the same code on different architecture then you will have to recompile the code using that particular architecture.
Unmanaged executable files are basically a binary image, x86 code, directly loaded into memory. This approach typically results in fastest code execution, but diagnosing and recovery from errors might difficult and time consuming in most cases. The memory allocation, type safety, security, etc needs to be taken care of by the programmer and this will lead unmanaged code prone to memory leaks like buffer overruns, pointer overrides etc.
All code compiled by traditional C/C++ compilers are Unmanaged Code. COM components, ActiveX interfaces, and Win32 API functions are examples of unmanaged code. Managed code is code written in many high-level programming languages that are available for use with the Microsoft .NET Framework, including VB.NET, C#, J#, JScript.NET etc. Since Visual C++ can be compiled to either managed or unmanaged code it is possible to mix the two in the same application.
.NET in-built support for serialization
Serialization is the process of converting the state of an object into a form that can be persisted or transported. There are two separate mechanisms provided by the .NET class library: XmlSerializer and SoapFormatter/BinaryFormatter . Microsoft uses XmlSerializer for Web Services, and SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code. Binary serialization preserves type fidelity, which is useful for preserving the state of an object between different invocations of an application. Because XML is an open standard, it is an attractive choice for sharing data across the Web. SOAP is likewise an open standard, which makes it an attractive choice.XML Serialization
XML Serialization is the process of serializing a .Net Object to the form of XML or from an XML to .Net Object. The primary purpose of XML serialization in the .NET Framework is to enable the conversion of XML documents and streams to common language runtime objects and vice versa. This is the process of converting an object into a form that can be readily transported.
How many types of Jit Compilers?
Just-In-Time compiler- It converts the MSIL code to CPU native code as it is needed during code execution.
Different Types of JIT
Pre JIT CompilerEcono JIT Compiler
Normal JIT Compiler
Pre JIT Compiler. This Compiler compiles complete source code into native code in a single compilation cycle. It is done through NGen (the process of precompiling from CIL to a native image). It will convert the compiled .NET code from the platform-independent intermediate state to a platform specific stage. This means that, it converts the .NET application that can run on both Windows, Mac and Linux 32-bit and 64-bit to an traditional EXE file that can only run on one of these.
The advantage of PRE JIT Compiler is that you don't have the initial compilation delay that the compiler can introduce when an assembly or type is loaded for the first time in code. It improves the warm startup time of your program. A warm start is one where the assembly data is already in the file system cache so no time is spent by the disk drive to locate the DLL on the disk. As opposed to a cold start, one you'll get when the assembly has never been loaded before or was loaded long ago, the disk drive has to find the file first. Which is slow. You almost always only care about cold start time because that's the one that's so noticeable to the user.
Econo JIT Compiler: Econo JIT Compiler compiles only those methods that are called at runtime . However, these compiled methods are removed when they are not required. The idea of Econo JIT is to spend less time compiling so that startup latency is lower for interactive applications. This is actually what you want once you notice the app takes seconds to start up.
Normal JIT Compiler: Normal-JIT compiles only those methods that are called at runtime . After execution this method is stored in the memory and it is commonly referred as "jitted" . No further compilation is required for the same method. Subsequent method calls are accessible directly from the memory cache.
Difference between web service and .net remoting
What is Web services ?
A web service is a method of communication between two software
units over the World Wide Web. Applications can access Web services through
different data formats such as HTTP, XML, and SOAP, with no need to worry about
how each Web service is implemented.
Extensible Markup Language (XML) is used to tag the data, Simple
Object Access Protocol (SOAP) is used to transfer the data, Web Services
Description Language (WSDL) is used for describing the services available and
Universal Description Discovery and Integration (UDDI) is used for listing what
services are available.
Web services do not provide the user with a GUI, instead it share
business logic, data and processes through a programmatic interface across a
network.
What is .Net Remoting ?
.NET Remoting is a mechanism that allows objects to interact with
each other across application domains, whether application components are all
on one computer or spread out across the entire world. Remoting was designed in
such a way that it hides the most difficult aspects like managing connections,
marshaling data, and reading and writing XML and SOAP.
You can study more in detail about .Net Remoting with sample
Source code :
Which one is better ?
Both technologies are powerful that provide a suitable framework
for developing distributed applications. Web services favor the XML Schema type
system, and provide a simple programming model with broad cross-platform reach,
while.NET Remoting favors the runtime type system, and provides a more complex
programming model with much more limited reach.
If both your clients and components are inside the firewall, Web
services will work fine. However, all of your data travels through a Web
server, which can slow performance. Remoting is allowing you to communicate
between a client application and components in a binary format. It is more
suitable as a high speed solution for binary communication between proprietary
.NET components, usually over an internal network.
It is important to understand how both technologies work and to
choose the one that is right for your application.
What is code access security (CAS)?
Code Access Security (CAS) is the security sandbox for .NET. Local apps typically have full trust which means they can do anything. The .NET apps that are hosted in the browser can't do much. In between, just about any security setting can be fine-tuned using CAS.
The .NET Security Model provides code access permissions and code identity permissions. Code Access Security is the part of the .NET security model that determines whether or not the code is allowed to run, and what resources it can use when it is running. Code Access Security policy uses evidence to help grant the right permissions to the right assembly.
An administrator can configure Code Access Security policy to restrict the resource types that code can access and the other privileged operations it can perform. Code Access Security allows code to be trusted to varying degrees depending on where the code originates and on other aspects of the code's identity. Code Access Security can also help minimize the damage that can result from security vulnerabilities in your code.
Difference between Math.Floor() and Math.Truncate()?
Mat.floor() will always round down and Math.Truncate rounds towards zero.Math.Floor(2.5) = 2
Math.Truncate(2.5) = 2
Math.Floor(-2.5) = -3
Math.Truncate(-2.5) = -2
.Net Assembly Manifest
An Assembly Manifest is a file that containing Metadata about .NET Assemblies. Assembly Manifest contains a collection of data that describes how the elements in the assembly relate to each other. It describes the relationship and dependencies of the components in the Assembly, versioning information, scope information and the security permissions required by the Assembly.The Assembly Manifest can be stored in Portable Executable (PE) file with Microsoft Intermediate Language (MSIL) code. You can add or change some information in the Assembly Manifest by using assembly attributes in your code. The Assembly Manifest can be stored in either a PE file (an .exe or .dll) with Microsoft Intermediate Language (MSIL) code or in a standalone PE file that contains only assembly manifest information. Using ILDasm, you can view the manifest information for any managed DLL.
.Net Garbage Collection
The .Net Framework provides a new mechanism for releasing unreferenced objects from the memory (that is we no longer needed that objects in the program) ,this process is called Garbage Collection (GC). When a program creates an Object, the Object takes up the memory. Later when the program has no more references to that Object, the Object's memory becomes unreachable, but it is not immediately freed. The Garbage Collection checks to see if there are any Objects in the heap that are no longer being used by the application. If such Objects exist, then the memory used by these Objects can be reclaimed. So these unreferenced Objects should be removed from memory , then the other new Objects you create can find a place in the Heap.The reclaimed Objects have to be Finalized later. Finalization allows a resource to clean up after itself when it is being collected. This releasing of unreferenced Objects is happening automatically in .Net languages by the Garbage Collector (GC). The programming languages like C++, programmers are responsible for allocating memory for Objects they created in the application and reclaiming the memory when that Object is no longer needed for the program. In .Net languages there is a facility that we can call Garbage Collector (GC) explicitly in the program by calling System.GC.Collect.
.Net Application Domain
An application domain is a virtual process and is used to isolate applications from one another. Each application domain has their own virtual address space which scopes the resources for the application domain using that address space.Each application running within its main process boundaries and its application domain boundaries. All objects created within the same application scope are created within the same application domain. Multiple application domains can exist in a single operating system process. An application running inside one application domain cannot directly access the code running inside another application domain.
System.AppDomain is the main class you can use to deal with application domains.
No comments:
Post a Comment