Floating FB popout byF5debug

Interview Questions and Answers on .Net Framework, OOPS, ASP.Net, C#.Net, SQL Server, WCF Series – Part 6

 

Question 51 - What is a Resource File?

Resource files are the files containing data that is logically deployed with an application. These files can contain data in a number of formats including strings, images and persisted objects. It has the main advantage of If we store data in these files then we don't need to compile these if the data get changed. In .NET we basically require them storing culture specific information’s by localizing application's resources. You can deploy your resources using satellite assemblies.


Question 52 - What is Code Access Security(CAS)?

CLR allows code to perform only those operations that the code has permission to perform. So CAS is the CLR's security system that enforces security policies by preventing unauthorized access to protected resources and operations. Using the Code Access Security, you can do the following:

  • Restrict what your code can do
  • Restrict which code can call your code
  • Identify code

Code access security consists of the following elements:

  • Permissions - represent access to a protected resource or the ability to perform a protected operation.
  • Permission sets - A permission set is a collection of permissions.
  • Code groups - logical grouping of code that has a specified condition for membership Evidence
  • Policy - Security policy is the configurable set of rules that the CLR follows when determining the permissions to grant to code.
  • There are four policy levels - Enterprise, Machine, User and Application Domain, each operating independently from each other.

Syntax

  • See CAS objects -- Run 'caspol -lg' from command line.
  • Add CAS objects -- caspol -ag 1.3 -site www.mydomain.com FullTrust
  • Change CAS obj -- caspol -cg 1.3 FullTrust
  • Turn Off -- caspol -s off

 
Question 53 - What is difference between Code Based Security and Role Based Security?

    CAS is the approach of using permissions and permission sets for a given code to run. Example, Admin can disable running executables off the Internet or restrict access to corporate database to only few applications.
  • Role security most of the time involves the code running with the privileges of the current user. This way the code cannot supposedly do more harm than mess up a single user account.
  • Neither is better. It depends on the nature of the application; both code-based and role-based security could be implemented to an extent.


Question 54 -
What is difference between Invoke and Begin Invoke

  • Delegate.Invoke: Executes synchronously, on the same thread.
  • Delegate.BeginInvoke: Executes asynchronously, on a threadpool thread.
  • Control.Invoke: Executes on the UI thread, but calling thread waits for completion before continuing.
  • Control.BeginInvoke: Executes on the UI thread, and calling thread doesn't wait for completion.
  • BeginInvoke is asynchronous. When BeginInvoke is called from the UI thread the request will be executed in parallel with the UI thread. Which means it may not execute until after the currently executing method has returned. So in this case the text box will never appear to update because the for loop will not be interrupted, as the calling thread will not wait for this event to be completed before continuing.
  • Alternatively, Invoke is synchronous. The text box will be updated because the calling thread will wait for the call to complete before continuing execution.


Question 55 -
What is the difference between Debug and Trace?

Tracing is actually the process of collecting information about the program's execution. Debugging is the process of finding & fixing errors in our program. Tracing is the ability of an application to generate information about its own execution.

Trace and Debug work in a similar way, the difference is that tracing from the Debug class only works in builds that have the DEBUG symbol defined, whereas tracing from the Trace class only works in builds that have the TRACE symbol defined.

  • Use System.Diagnostics.Trace.WriteLine for tracing that you want to work in debug and release builds
  • Use System.Diagnostics.Debug.WriteLine for tracing that you want to work only in debug builds.

 Question 56 - What is a Debug version of a code?

  • Preprocessor(Debugging Diagnostic) macro _DEBUG is enabled.
  • More memory size.
  • Support files required. (MFC Dll’s)
  • No Code Optimization
  • Uses MFC Debug Library
  • ASSERT is enabled.
  • Execution takes more time

 
Question 57 -
What is a Release version of a code?

  • Preprocessor(Debugging Diagnostic) macro NDEBUG is enabled.
  • Less memory size.
  • Support files not required. (MFC Dll’s)
  • Code Optimization
  • Uses MFC Release Library
  • ASSERT is disabled anything inside of ASSERT will not be executed.
  • Execution takes less time


Question 58 - What is an IDisposable Interface?

  • The primary use of this interface is to release unmanaged resources. The garbage collector automatically releases the memory allocated to a managed object when that object is no longer used.
  • However, it is not possible to predict when garbage collection will occur.
  • Furthermore, the garbage collector has no knowledge of unmanaged resources such as window handles, or open files and streams.
  • The consumer of an object can call this method when the object is no longer needed.


Question 59 -
What is Finalize block in .net?

  • Finalize() is called by the runtime
  • Is a C# equivalent of destructor, called by Garbage Collector when the object goes out of scope.
  • Implement it when you have unmanaged resources in your code, and want to make sure that these resources are freed when the Garbage collection happens.
  • Finalize() can NOT be overridden or called in C#.
  • Since, Finalize() is called by the Garbage Collector, it is non-deterministic.


Question 60 -
What is Dispose block in .net?

  • Dispose() is called by the user
  • Same purpose as finalize, to free unmanaged resources. However, implement this when you are writing a custom class, that will be used by other users.
  • Overriding Dispose() provides a way for user code to free the unmanaged objects in your custom class.
  • Dispose() has to be implemented in classes implementing IDispose interface.
  • Dispose() method is called explicitly in the code itself.

Disclaimer – F5debug Interview Questions & Answers Series:

You may recopy extracts from these pages ("the material") to individual third parties website or to the local system internal websites for their personal information, but only if:

    You acknowledge the www.f5debug.net as the source of the material. Such acknowledgment should include reference to the www.f5debug.net in the copy of the material and should also include the words " © Karthikeyan Anbarasan, www.f5debug.net ". You inform the third party that these conditions apply to him/her and that he/she must comply with them.

About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Comments (1) -

Shila Commendatore
Shila Commendatore
9/20/2013 1:34:58 AM #

Everyone loves what you guys are usually up too. This sort of clever work and reporting! Keep up the awesome works guys I've added you guys to my personal blogroll.|

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter