You are on page 1of 9

1

1. What are the difference between Value Types and Reference types?
Ans: Value types are those that are created on the stack. Reference types are
created on the heap. Value types are destroyed when the block creating them is
exited. Reference types are garbage collected. Reference types are like pointers.

2. What is boxing and unboxing in .NET?


Ans: Boxing is wrapping a value type into an object, so it can be stored on the
heap. Unboxing is the converse – recovering a value type from a reference type
on the heap. Boxing works always. Unboxing a reference type would work only if
the type was originally a value type that was boxed.

3. What are three to five important differences that you would find between
COM/DCOM and .NET?
Ans:
1. COM/DCOM uses the registry to store all information related to the
component. And .NET stores the information within the component itself
2. All COM/DCOM components must be installed. .NET components can
simply be xcopied (even though shared assemblies would need to be installed
with gacutil.exe)
3. COM/DCOM components implement the interface IUnknown (that has the
methods: AddRef(), Release() and QueryInterface()) All .NET components
inherit from the CTS type System.Object
4. COM/DCOM is not type-independent. For example, all COM server methods
in VB must accept or return variants. In .NET, since all languages share the
same type library (CTS – Common Type System) - this overhead is removed.
5. DCOM uses a proprietary mechanism to discover remote objects, marshall the
parameters and return back values. .NET uses open standards like XML to do
remoting.
6. COM/DCOM depends on reference counts to know if they are needed. In
.NET, the garbage collector takes care of keeping object lifetimes and
collecting them when no longer needed.

4. What is non-CLS compliant code?


Ans: Non CLS compliant code is code where the .NET cross-language standards
are broken. For example: Having two C# methods that accept the same
parameters but differ in case. This would be unusable from the VB.NET world.

5. What does Shared Assembly mean? Can you make any assembly a shared
one?
Ans: Shared Assemblies are those that are installed in a special folder within the
Windows installation (called Global Assembly Cache). They can be used by
any .NET application that needs to be a client to the assembly's methods. To make
an assembly into a shared one, you need to generate a strong name. For this you
have SN.EXE that generates public and private keys that can be used to version
and strongly name the assembly in the GAC. Unless this is done, any and every
assembly cannot become shared.

1
2

6. Where is the metadata related to an assembly stored?


Ans: In a special area of the assembly header, called its manifest. This manifest
contains file ownership details, culture, version numbers, types referenced, types
exported and other media.

7. Can each file of an assembly have its own manifest?


Ans: No. Only one file in an assembly can have its manifest.

8. What are three to five differences you would state, between ASP and
ASP.NET ?
Ans:
1. In ASP all the page contents are in the same file (or in included files). In
ASP.NET, you can split the page's content and code into separate files (the
code-behind file)
2. ASP files end with .asp. ASP.NET files end with .aspx (this is dumb )
3. With ASP you had just two main languages to write code – VBScript and
JScript. With ASP.NET you can write code in any language that has a .NET
compiler installed on the IIS server
4. All ASP pages are interpreted. ASP.NET uses compilation of the code-behind
and runs the binaries everytime the page is requested.
5. ASP.NET adds a lot of functionality to IIS – like server controls, user
controls, improved session management, event driven programming etc.
6. ASP pages usually post their forms to other asp pages. ASP.NET pages post
the forms back to the same page (by calling server methods)

9. What are delegates in .NET? Mention 2 places where they are majorly used
Ans: Delegates are objects representing function pointers. Whenever a delegate is
created, it is given the name of a function of the type it is defined with (like void
return, accepting an int). Invoking the delegate calls the method it was created
with (sort of a callback mechanism). Two places where delegates are employed:
Events and Threads.

10. What are multicast delegates?


Ans: Multicast delegates are delegates that can refer to multiple methods. They
must return void. Whenever we create a delegate with void, .NET internally treats
it as a multicast delegate. We can use the overloaded + operator to add void
methods with the same signature to a multicast delegate. When this delegate is
called, all the methods are called (not in sequence – do not trust sequence).

11. What is meant by ViewState in ASP.NET?


Ans: ViewState is a hidden form member created with each control in ASP.NET.
Like, when we populate a dropdown list on a page – its members are stored with
the viewstate. They help in persisting form content state and can be used in a
scenario where we have multiple web servers (as in a server farm).

2
3

12. What are static constructors in C#?


Ans: Static constructors are constructors in a class, defined with the word static.
They must not accept any parameter and must return nothing. They are called
once - whenever the class is loaded by the CLR. Every class can have 0 or 1 static
constructors.

13. Are you aware of a keyword called fixed in C#? What is it used for?
Ans: The fixed keyword is used with references defined in a class. Whenever the
word fixed is encountered, the .NET runtime/CLR flags this particular object on
the heap.So that the garbage collector will not move it when it compacts the heap.
Using fixed allows you to perform pointer arithmetic on objects (unsafe code)

14. What is the meaning of the following keywords:


a. Internal
Ans: Internal flags a member as being accessible only within the current
assembly
b. Override
Ans: override allows a derived class to create a method that specializes a
base class virtual method.
c. Sealed
Sealed classes are those that cannot be inherited from. You can make
objects from a sealed class, but you cannot subclass it.

15. What are hidden methods in C#/.NET


Ans: hidden methods in C# use the new keyword. They are methods in a derived
class that have the same signature as a base class virtual method, but are not
related in inheritance to it. In effect, the derived class hides the base class method.

16. Can you have a catch block with no parameters (no catch (Exception e) ?
Ans: Yes. When you define a catch block with no parameters, you are defining a
block that will handle exceptional information from the non .NET world. This
would take care of problems arising in method calls on COM components that
don’t raise the System.Exception derived object.

17. What is stackalloc in C#?


Ans: stackalloc is used for creating C/C++ style stack arrays. When you desire a
contiguous block of memory where you could perform pointer arithmetic with a
set of data, you use stackalloc. This is unsafe/unmanaged code. By default, all
.NET arrays are objects created on the heap – even with integer arrays (Recall,
you have a length property for all arrays!) You have no length property for stack
allocated arrays

18. How is threading done in .NET?


Ans: The System.Threading namespace defines a class called Thread. This thread
is created with a ThreadStart delegate class object. This ThreadStart object must
refer to a method that accepts and returns void. When the start method is called on

3
4

the thread, it runs the delegate method parallel with the current thread of
execution.

19. What is meant by strongly typed assemblies?


Ans: Strongly typed assemblies can be placed in the GAC. They are created with
a strong name (public/private key, generated with sn.exe)

20. What is the mechanism used to peep inside an object and know about its
methods, public members etc?
Ans: Reflection. It is possible as all types inherit from System.Object, that
contains a method GetType that returns a Type structure, describing the object's
type.

21. Can session information be shared between ASP and ASP.NET?


Ans: No. They are maintained differently and cannot be shared. Session info
written by an ASP.NET page cannot be viewed in an ASP page linked to the
former.

22. Can you have two files in the same assembly, created with different
programming languages?
Ans: Yes. .NET allows this.

23. Can you have a page where the code behind uses two different .NET
languages?
Ans: No. Every page or class in .NET must be created in the same language.

24. What is the concept of generations in objects, as related to garbage


collection?
Ans: Every object has a generation counter that is set and used by the garbage
collector. It is incremented every time the object skips the garbage collection
mechanism as its reference is present with some place else on the heap. The GC
compacts the heap and places all objects with the same generation count together.

25. What is meant by DNA programming, in the Windows world?


DNA is short for Distributed interNet Architecture. It envisages an n-tier design
where the client has UI functionality, the middle tiers have business logic and
process routing architecture and the back-end has the database logic. DNA
architecture allows the same business tiers and back-ends to be used by multiple
clients (web, application-based or device)

26. What are the means to implement security in ASP.NET?


Ans:
1. Integrated Windows Authentication: Where the user's information and roles
are defined in the windows installation where the IIS instance is active
2. Config file-based: The web.config file for the website has XML tags to
indicate which users must be allowed and those that must be denied access.

4
5

You can make the root web folder publicly accessible, while restricting access
to subfolders or selected files
3. Web-Service based: Microsoft runs a Passport web service that has a single
door entry to authenticate users. Web applications could utilize this service to
identify and permit users to access the system.

27. What is the class DataSet – in the ADO.NET world.


Ans: DataSet is an in-memory image of a database. It contains a set of tables and
relations between them, that can be used by applications.

28. Is this possible? I use a Connection object to retrieve a SqlDataReader. I


iterate through the records in the DataReader, using
while (sqlDataReaderObject.Read())
Inside the while block, I connect to some webservice to retrieve a value
corresponding to a particular column in the record. Can I update another
table in the same database, using the above connection – or would I have to
create another connection object for the update thing?
Ans: No. This is not possible, as the Connection is locked by the SqlDataReader
object, as long as it is being read from. You must create a new instance of the
connection object, with the same connection string

29. Can I write an ASP.NET page using Managed C++?


Ans: Yes. But the C++ language must be enabled in the IIS' configuration files
and the compiler must be available. By default, only two languages are supported
– C# and VB.NET. To enable Managed C++, the compiler must be available.
Else, the answer is no.

30. What is the Monitor class in the threading world?


Ans: Monitor is used to synchronize access to a block of code between threads.
When a certain operation is to be performed by only one thread at a time, it must
obtain the monitor to that object. Once it has acquired the monitor, all other
threads to that method must wait till the monitor is exited.

5
6

.NET Framework Tools

The Microsoft .NET Framework SDK tools are designed to make it easier for you to
create, deploy, and manage applications and components that target the .NET
Framework. This section contains detailed information about the tools.

You can run all the tools from the command line with the exception of the Assembly
Cache Viewer (Shfusion.dll) and the Microsoft CLR Debugger (DbgCLR.exe). You
must access Shfusion.dll from Microsoft Windows Explorer. DbgCLR.exe is located
in the Microsoft.NET\FrameworkSDK\GuiDebug folder.

Configuration and Deployment Tools

Tool Description
Assembly Cache Viewer (Shfusion.dll) Allows you to view and manipulate the
contents of the global assembly cache using
Windows Explorer.
Assembly Linker (Al.exe) Generates a file with an assembly manifest
from one or more files that are either
resource files or Microsoft intermediate
language (MSIL) files.
Assembly Registration Tool (Regasm.exe) Reads the metadata within an assembly and
adds the necessary entries to the registry,
which allows COM clients to create .NET
Framework classes transparently.
Assembly Binding Log Viewer Displays details for failed assembly binds.
(Fuslogvw.exe) This information helps you diagnose why
the .NET Framework cannot locate an
assembly at run time.
Global Assembly Cache Tool (Gacutil.exe) Allows you to view and manipulate the
contents of the global assembly cache and
download cache. While Shfusion.dll
provides similar functionality, you can use
Gacutil.exe from build scripts, makefile
files, and batch files.
Installer Tool (Installutil.exe) Allows you to install and uninstall server
resources by executing the installer
components of a specified assembly.
Isolated Storage Tool (Storeadm.exe) Lists or removes all existing stores for the
currently logged-on user.
Native Image Generator (Ngen.exe) Creates a native image from a managed
assembly and installs it in the native image
cache on the local computer.
.NET Framework Configuration Tool Provides a graphical interface for
(Mscorcfg.msc) managing .NET Framework security policy

6
7

and applications that use remoting services.


This tool also allows you to manage and
configure assemblies in the global assembly
cache.
.NET Services Installation Tool Adds managed classes to Windows 2000
(Regsvcs.exe) Component Services by loading and
registering the assembly and generating,
registering, and installing the type library
into an existing COM+ 1.0 application.
Soapsuds Tool (Soapsuds.exe) Helps you compile client applications that
communicate with XML Web services using
a technique called remoting.
Type Library Exporter (Tlbexp.exe) Generates a type library from a common
language runtime assembly.
Type Library Importer (Tlbimp.exe) Converts the type definitions found within a
COM type library into equivalent definitions
in managed metadata format.
Web Services Description Language Tool Generates code for XML Web services and
(Wsdl.exe) XML Web services clients from Web
Services Description Language (WSDL)
contract files, XML Schema Definition
(XSD) schema files and discomap
discovery documents.
Web Services Discovery Tool (Disco.exe) Discovers the URLs of XML Web services
located on a Web server, and saves
documents related to each XML Web
service on a local disk.
XML Schema Definition Tool (Xsd.exe) Generates XML schemas that follow the
XSD language proposed by the World Wide
Web Consortium (W3C). This tool generates
common language runtime classes and
Dataset classes from an XSD schema file.

Debugging Tools

Tool Description
Microsoft CLR Debugger (DbgCLR.exe) Provides debugging services with a
graphical interface to help application
developers find and fix bugs in programs
that target the runtime.
Runtime Debugger (Cordbg.exe) Provides command-line debugging services
using the common language runtime Debug
API. Used to find and fix bugs in programs
that target the runtime.

7
8

Security Tools

Tool Description
Certificate Creation Tool (Makecert.exe) Generates X.509 certificates for testing
purposes only.
Certificate Manager Tool (Certmgr.exe) Manages certificates, certificate trust lists
(CTLs), and certificate revocation lists
(CRLs).
Certificate Verification Tool (Chktrust.exe) Verifies the validity of a file signed with an
X.509 certificate.
Code Access Security Policy Tool Allows you to examine and modify
(Caspol.exe) machine, user, and enterprise-level code
access security policies.
File Signing Tool (Signcode.exe) Signs a portable executable (PE) file with an
Authenticode digital signature.
Permissions View Tool (Permview.exe) Displays the minimal, optional, and refused
permission sets requested by an assembly.
You can also use this tool to view all
declarative security used by an assembly.
PEVerify Tool (PEverify.exe) Performs MSIL type safety verification
checks and metadata validation checks on a
specified assembly.
Secutil Tool (Secutil.exe) Extracts strong name public key information
or Authenticode publisher certificates from
an assembly, in a format that can be
incorporated into code.
Set Registry Tool (Setreg.exe) Allows you to change the registry settings
for the Software Publishing State keys,
which control the behavior of the certificate
verification process.
Software Publisher Certificate Test Tool Creates, for test purposes only, a Software
(Cert2spc.exe) Publisher's Certificate (SPC) from one or
more X.509 certificates.
Strong Name Tool (Sn.exe) Helps create assemblies with strong names.
Sn.exe provides options for key
management, signature generation, and
signature verification.

General Tools

Tool Description
Common Language Runtime Minidump Creates a file containing information that is
Tool (Mscordmp.exe) useful for analyzing system issues in the
runtime. The Microsoft Dr. Watson tool
(Drwatson.exe) invokes this program

8
9

automatically.
License Compiler (Lc.exe) Reads text files that contain licensing
information and produces a .licenses file that
can be embedded in a common language
runtime executable.
Management Strongly Typed Class Allows you to quickly generate an early-
Generator (Mgmtclassgen.exe) bound class in C#, Visual Basic, or JScript
for a specified Windows Management
Instrumentation (WMI) class.
MSIL Assembler (Ilasm.exe) Generates a PE file from Microsoft
intermediate language (MSIL). You can run
the resulting executable, which contains
MSIL code and the required metadata, to
determine whether the MSIL code performs
as expected.
MSIL Disassembler (Ildasm.exe) Takes a PE file that contains MSIL code and
creates a text file suitable as input to the
MSIL Assembler (Ilasm.exe).
Resource File Generator Tool (Resgen.exe) Converts text files and .resx (XML-based
resource format) files to .NET common
language runtime binary .resources files that
can be embedded in a runtime binary
executable or compiled into satellite
assemblies.
Windows Forms ActiveX Control Importer Converts type definitions in a COM type
(Aximp.exe) library for an ActiveX control into a
Windows Forms control.
Windows Forms Class Viewer (Wincv.exe) Finds managed classes matching a specified
search pattern, and displays information
about those classes using the Reflection
API.
Windows Forms Resource Editor Allows you to quickly and easily localize
(Winres.exe) Windows Forms forms.

You might also like