Interview questions

.NET managed vs. unmanaged code


Managed vs. unmanaged code

Managed vs. unmanaged code
Explain - consuming unmanaged DLL functions using PInvoke.
Explain how managed code slower than unmanaged code.

Managed vs. unmanaged code - March 13, 2009 at 15:20 PM by Amit Satpute

Managed vs. unmanaged code

  • Managed code runs through a runtime which is a software layer that the application communicates due to which many functions are automatically done. Some of these functions are garbage collecting and exception handling.
  • A programmer needs to write many common functions in an unmanaged code. So functions like garbage collecting, exception handling, etc have to be handled explicitly.

Explain - consuming unmanaged DLL functions using PInvoke.

PInvoke = Platform invoke.
Calling a function located in an unmanaged DLL library from .NET framework is called consuming unmanaged DLL function.
When PInvoke calls an unmanaged function,
The DLL containing the function is located and loaded it into memory.
Then the function arguments are pushed into the stake and then the data is marshalled required.
And then the control is transferred to the unmanaged function.
PInvoke throws exceptions generated by the unmanaged function to the managed caller.

Explain how managed code slower than unmanaged code.

Managed code executes under the management of a virtual machine. It is executed by a common language runtime environment rather than directly by the operating system. Tasks such as Exception handling and GC too are handled in the managed code environment. Due to all these reasons, managed code is slower than the unmanaged code.



Write your comment - Share Knowledge and Experience


More Related Links
NET Assembly

Define .Net Assembly.
What does an assembly contain?
Define a private assembly and a shared assembly.
What are Satellite Assemblies?
What do you understand by side-by-site execution of assembly?
How do you create a resource-only assembly?

What Is AJAX? History of AJAX, Advantages of AJAX

With AJAX, only the necessary data is transferred back and forth between the client and the web server. This minimizes the network utilization and processing on the client........

What Is ASP.NET 2.0 AJAX?

AJAX-style communications between client and server. This communication is over web services. Asynchronous communication. All client-to-server communication in the ASP.NET 2.0 AJAX framework is asynchronous................

Potential benefits of using Ajax

AJAX makes it possible to create better and more responsive websites and web applications...............

Potential problems with AJAX

Search engines may not be able to index all portions of your AJAX application site.........

What Is ASP.NET AJAX?

ASP.NET AJAX is the name of Microsoft’s AJAX solution, and it refers to a set of client and server technologies that focus on improving web development with Visual Studio...............

 
Latest placement tests
Latest links
 
Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us | We are hiring