Beruflich Dokumente
Kultur Dokumente
• Mahesu .K
· Versioning: The runtime enforces versioning constraints only on shared assemblies, not
on private assemblies.
3.4 How do assemblies find each other?
By searching directory paths. There are several factors, which can affect the path (such as
the AppDomain host, and application configuration files), but for private assemblies the
search path is normally the application's directory and its sub-directories. For shared
assemblies, the search path is normally same as the private assembly path plus the shared
assembly cache.
3.5 How does assembly versioning work?
Each assembly has a version number called the compatibility version. Also each
reference to an assembly (from another assembly) includes both the name and version of
the referenced assembly.
The version number has four numeric parts (e.g. 5.5.2.33). Assemblies with either of the
first two parts different are normally viewed as incompatible. If the first two parts are the
same, but the third is different, the assemblies are deemed as 'maybe compatible'. If only
the fourth part is different, the assemblies are deemed compatible. However, this is just
the default guideline - it is the version policy that decides to what extent these rules are
enforced. The version policy can be specified via the application configuration file.
Remember: versioning is only applied to shared assemblies, not private assemblies.
4. Application Domains
4.1 What is an Application Domain?
An AppDomain can be thought of as a lightweight process. Multiple AppDomains can
exist inside a Win32 process. The primary purpose of the AppDomain is to isolate an
application from other applications.
Win32 processes provide isolation by having distinct memory address spaces. This is
effective, but it is expensive and doesn't scale well. The .NET runtime enforces
AppDomain isolation by keeping control over the use of memory - all memory in the
AppDomain is managed by the .NET runtime, so the runtime can ensure that
AppDomains do not access each other's memory.
4.2 How does an AppDomain get created?
AppDomains are usually created by hosts. Examples of hosts are the Windows Shell,
ASP.NET and IE. When you run a .NET application from the command-line, the host is
the Shell. The Shell creates a new AppDomain for every application.
AppDomains can also be explicitly created by .NET applications. Here is a C# sample
which creates an AppDomain, creates an instance of an object inside it, and then executes
one of the object's methods. Note that you must name the executable 'appdomaintest.exe'
for this code to work as-is.
using System;
using System.Runtime.Remoting;
Code Groups:
using System;
namespace AndyMc
{
public class CSharpCOMServer
{
public CSharpCOMServer() {}
public void SetName( string name ) { m_name = name; }
public string GetName() { return m_name; }
private string m_name;
}
}
Then compile the .cs file as follows:
csc /target:library testcomserver.cs
You should get a dll, which you register like this:
regasm testcomserver.dll /tlb:testcomserver.tlb /codebase
Now you need to create a client to test your .NET COM component. VBScript will do -
put the following in a file called comclient.vbs:
Dim dotNetObj
Set dotNetObj = CreateObject("AndyMc.CSharpCOMServer")
dotNetObj.SetName ("bob")
MsgBox "Name is "& dotNetObj.GetName()
and run the script like this:
wscript comclient.vbs
And hey presto you should get a message box displayed with the text "Name is bob".
10.6 Is ATL redundant in the .NET world?
Yes, if you are writing applications that live inside the .NET framework. Of course many
developers may wish to continue using ATL to write C++ COM components that live
outside the framework, but if you are inside you will almost certainly want to use C#.
Raw C++ (and therefore ATL which is based on it) doesn't have much of a place in the
.NET world - it's just too near the metal and provides too much flexibility for the runtime
to be able to manage it.
11. Miscellaneous
11.1 How does .NET remoting work?
.NET remoting involves sending messages along channels. Two of the standard channels
are HTTP and TCP. TCP is intended for LANs only - HTTP can be used for LANs or
WANs (internet).
Support is provided for multiple message serializarion formats. Examples are SOAP
(XML-based) and binary. By default, the HTTP channel uses SOAP (via the .NET
runtime Serialization SOAP Formatter), and the TCP channel uses binary (via the .NET
runtime Serialization Binary Formatter). But either channel can use either serialization
format.
There are a number of styles of remote access:
· SingleCall. Each incoming request from a client is serviced by a new object. The object
is thrown away when the request has finished. This (essentially stateless) model can be
made stateful in the ASP.NET environment by using the ASP.NET state service to store
application or session state.
· Singleton. All incoming requests from clients are processed by a single server object.
· Client-activated object. This is the old stateful (D)COM model whereby the client
receives a reference to the remote object and holds that reference (thus keeping the
remote object alive) until it is finished with it.
Distributed garbage collection of objects is managed by a system called 'leased based
lifetime'. Each object has a lease time, and when that time expires the object is
disconnected from the .NET runtime remoting infrastructure. Objects have a default
renew time - the lease is renewed when a successful call is made from the client to the
object. The client can also explicitly renew the lease.
11.2 How can I get at the Win32 API from a .NET program?
Use P/Invoke. This uses similar technology to COM Interop, but is used to access static
DLL entry points instead of COM objects. Here is an example of C# calling the Win32
MessageBox function:
using System;
using System.Runtime.InteropServices;
class MainApp
{
[DllImport("user32.dll", EntryPoint="MessageBox", SetLastError=true,
CharSet=CharSet.Auto)]
public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint
uiType);
public static void Main()
{
MessageBox( 0, "Hello, this is PInvoke in operation!", ".NET", 0 );
}
}
12. Class Library
12.1 File I/O
12.1.1 How do I read from a text file?
First, use a System.IO.FileStream object to open the file:
FileStream fs = new FileStream( @"c:\test.txt", FileMode.Open, FileAccess.Read );
FileStream inherits from Stream, so you can wrap the FileStream object with a
StreamReader object. This provides a nice interface for processing the stream line by
line:
StreamReader sr = new StreamReader( fs );
string curLine;
while( (curLine = sr.ReadLine()) != null )
Console.WriteLine( curLine );
Finally close the StreamReader object:
sr.Close();
Note that this will automatically call Close() on the underlying Stream object, so an
explicit fs.Close() is not required.
12.1.2 How do I write to a text file?
Similar to the read example, except use StreamWriter instead of StreamReader.
12.1.3 How do I read/write binary files?
Similar to text files, except wrap the FileStream object with a BinaryReader/Writer object
instead of a StreamReader/Writer object.
12.1.4 How do I delete a file?
Use the static Delete() method on the System.IO.File object:
File.Delete( @"c:\test.txt" );
12.2 Text Processing
12.2.1 Are regular expressions supported?
Yes. Use the System.Text.RegularExpressions.Regex class. For example, the following
code updates the title in an HTML file:
FileStream fs = new FileStream( "test.htm", FileMode.Open, FileAccess.Read );
StreamReader sr = new StreamReader( fs );
Fred
Bill
while( reader.Read() )
{
if( reader.NodeType == XmlNodeType.Element && reader.Name == "PERSON" )
{
reader.Read(); // Skip to the child text
Console.WriteLine( reader.Value );
}
}
12.4.3 Is XPath supported?
Yes, via the XPathXXX classes:
XPathDocument xpdoc = new XPathDocument("test.xml");
XPathNavigator nav = xpdoc.CreateNavigator();
XPathExpression expr = nav.Compile("descendant::PEOPLE/PERSON");
C SHARP FAQ’S
1. Introduction
1.1 What is C#?
C# is a programming language designed by Microsoft. It is loosely based on C/C++, and
bears a striking similarity to Java in many ways. Describe C# as follows:
"C# is a simple, modern, object oriented, and type-safe programming language derived
from C and C++. C# (pronounced 'C sharp') is firmly planted in the C and C++ family
tree of languages, and will immediately be familiar to C and C++ programmers. C# aims
to combine the high productivity of Visual Basic and the raw power of C++."
2. Basic types
2.1 What standard types does C# supply?
C# supports a very similar range of basic types to C++, including int, long, float, double,
char, string, arrays, structs and classes. However, don't assume too much. The names may
be familiar, but some of the details are different. For example, a long is 64 bits in C#,
whereas in C++ the size of a long depends on the platform (typically 32 bits on a 32-bit
platform, 64 bits on a 64-bit platform). Also classes and structs are almost the same in
C++ - this is not true for C#.
2.2 Is it true that all C# types derive from a common base class?
Yes and no. All types can be treated as if they derive from object (System.Object), but in
order to treat an instance of a value type (e.g. int, float) as object-derived, the instance
must be converted to a reference type using a process called 'boxing'. In theory a
developer can forget about this and let the run-time worry about when the conversion is
necessary, but in reality this implicit conversion can have side-effects that may trip up the
unwary.
2.3 So this means I can pass an instance of a value type to a method that takes an object
as a parameter?
Yes. For example:
class CApplication
{
public static void Main()
{
int x = 25;
string s = "fred";
DisplayMe( x );
DisplayMe( s );
}
2.4 What are the fundamental differences between value types and reference types?
C# divides types into two categories - value types and reference types. Most of the basic
intrinsic types (e.g. int, char) are value types. Structs are also value types. Reference
types include classes, interfaces, arrays and strings. The basic idea is straightforward - an
instance of a value type represents the actual data (stored on the stack), whereas an
instance of a reference type represents a pointer or reference to the data (stored on the
heap).
int x1 = 3; // x1 is a value on the stack
int x2 = new int();
x2 = 3; // x2 is also a value on the stack!
2.5 Okay, so an int is a value type, and a class is a reference type. How can int be derived
from object?
It isn't, really. When an int is being used as an int, it is a value (on the stack). However,
when it is being used as an object, it is a reference to an integer value on the heap. In
other words, when you treat an int as an object, the runtime automatically converts the int
value to an object reference. This process is called boxing. The conversion involves
copying the contents of the int from the stack to the heap, and creating an object instance
which refers to it. Unboxing is the reverse process - the object is converted back to a
stack-based value.
int x = 3; // new int value 3 on the stack
object objx = x; // new int on heap, set to value 3 - still have x=3 on stack
int y = (int)objx; // new value 3 on stack, still got x=3 on stack and objx=3 on heap
3. Classes and structs
3.1 Structs are largely redundant in C++. Why does C# have them?
In C++, a struct and a class are pretty much the same thing. The only difference is the
default visibility level (public for structs, private for classes). However, In C# structs and
classes are very different. In C#, structs are value types (stored on the stack), whereas
classes are reference types (stored on the heap). Also structs cannot inherit from structs or
classes, though they can implement interfaces. Structs cannot have destructors.
3.2 Does C# support multiple inheritance (MI)?
C# supports multiple inheritance of interfaces, but not of classes.
3.7 What is a static constructor?
A constructor for a class, rather than instances of a class. The static constructor is called
when the class is loaded.
3.8 Are all methods virtual in C#?
No. Methods are non-virtual by default, but can be marked as virtual.
3.9 How do I declare a pure virtual function in C#?
Use the abstract modifier on the method. The class must also be marked as abstract
(naturally). Note that abstract methods cannot have an implementation.
4. Exceptions
4.1 Can I use exceptions in C#?
Yes, in fact exceptions are the recommended error-handling mechanism in C# (and in
.NET in general). Most of the .NET framework classes use exceptions to signal errors.
4.2 What types of object can I throw as exceptions?
Only instances of the System.Exception classes, or classes derived from
System.Exception.
4.3 Can I define my own exceptions?
Yes, as long as you follow the rule that exceptions derive from System.Exception. More
specifically, recommend that user-defined exceptions inherit from
System.ApplicationException (which is derived from System.Exception).
4.5 Does the System.Exception class have any cool features?
Yes - the feature which stands out is the StackTrace property. This provides a call stack
which records where the exception was thrown from. For example, the following code:
using System;
class CApp
{
public static void Main()
{
try
{
f();
}
catch( Exception e )
{
Console.WriteLine( "System.Exception stack trace = \n{0}", e.StackTrace );
}
}
class CApp
{
public static void Main()
{
string s = "fred";
long i = 10;
class CTest
{
class CApp
{
public static void Main()
{
long i = 10;
CTest ctest = new CTest();
DisplayTypeInfo( ctest );
DisplayTypeInfo( i );
}
class CAmerican
{
public void BePatriotic()
{
Console.WriteLine( "... ... God bless America.");
}
}
class CBrit
{
public void BeXenophobic()
{
Console.WriteLine( "Bloody foreigners ... " );
}
}
class CApplication
{
public static void RevealYourStereotype( Stereotype[] stereotypes )
{
foreach( Stereotype s in stereotypes )
s();
}
// Reveal yourselves!
RevealYourStereotype(stereotypes );
}
}
This produces the following result:
... ... God bless America.
Bloody foreigners ...
6.2 Are delegates just like interfaces with a single method?
Conceptually delegates can be used in a similar way to an interface with a single method.
The main practical difference is that with an interface the method name is fixed, whereas
with a delegate only the signature is fixed - the method name can be different, as shown
in the example above.
8. Miscellaneous
8.1 String comparisons using == seem to be case-sensitive? How do I do a case-
insensitive string comparison?
Use the String.Compare function. Its third parameter is a boolean which specifies
whether case should be ignored or not.
"fred" == "Fred" // false
System.String.Compare( "fred", "Fred", true ) // true
8.2 I've seen some string literals which use the @ symbol, and some which don't. What's
that all about?
The @ symbol before a string literal means that escape sequences are ignored. This is
particularly useful for file names, e.g.
string fileName = "c:\\temp\\test.txt"
versus:
string fileName = @"c:\temp\test.txt"
8.3 Does C# support a variable number of arguments?
Yes, using the params keyword. The arguments are specified as a list of arguments of a
specific type, e.g. int. For ultimate flexibility, the type can be object. The standard
example of a method which uses this approach is System.Console.WriteLine().
8.4 How can I process command-line arguments?
Like this:
using System;
class CApp
{
public static void Main( string[] args )
{
Console.WriteLine( "You passed the following arguments:" );
foreach( string arg in args )
Console.WriteLine( arg );
}
}
8.5 Does C# do array bounds checking?
Yes. An IndexOutOfRange exception is used to signal an error.
8.6 How can I make sure my C# classes will interoperate with other .NET languages?
Make sure your C# code conforms to the Common Language Subset (CLS). To help with
this, add the [assembly:CLSCompliant(true)] global attribute to your C# source files. The
compiler will emit an error if you use a C# feature which is not CLS-compliant.
User Controls:
In ASP.NET: A user-authored server control that enables an ASP.NET page to be re-used
as a server control. An ASP.NET user control is authored declaratively and persisted as a
text file with an ascx extension. The ASP.NET page framework compiles a user control
on the fly to a class that derives from the System.Web.UI.UserControl class.
What are the validation controls?
A set of server controls included with ASP.NET that test user input in HTML and Web
server controls for programmer-defined requirements. Validation controls perform input
checking in server code. If the user is working with a browser that supports DHTML, the
validation controls can also perform validation using client script.
Where does the Web page belong in the .NET Framework class hierarchy?
System.Web.UI.Page
xmlns="urn:schemas-dynamicdiscovery:disco.2000-03-17">
Can you give an example of when it would be appropriate to use a web service as
opposed to a non-serviced .NET component?
· Communicating through a Firewall When building a distributed application with
100s/1000s of users spread over multiple locations, there is always the problem of
communicating between client and server because of firewalls and proxy servers.
Exposing your middle tier components as Web Services and invoking the directly from a
Windows UI is a very valid option.
· Application Integration When integrating applications written in various languages and
running on disparate systems. Or even applications running on the same platform that
have been written by separate vendors.
· Business-to-Business Integration This is an enabler for B2B intergtation which allows
one to expose vital business processes to authorized supplier and customers. An example
would be exposing electronic ordering and invoicing, allowing customers to send you
purchase orders and suppliers to send you invoices electronically.
· Software Reuse This takes place at multiple levels. Code Reuse at the Source code level
or binary componet-based resuse. The limiting factor here is that you can reuse the code
but not the data behind it. Webservice overcome this limitation. A scenario could be when
you are building an app that aggregates the functionality of serveral other Applicatons.
Each of these functions could be performed by individual apps, but there is value in
perhaps combining the the multiple apps to present a unifiend view in a Portal or Intranet.
· When not to use Web Services: Single machine Applicatons When the apps are running
on the same machine and need to communicate with each other use a native API. You
also have the options of using component technologies such as COM or .NET Componets
as there is very little overhead.
· Homogeneous Applications on a LAN If you have Win32 or Winforms apps that want to
communicate to their server counterpart. It is much more efficient to use DCOM in the
case of Win32 apps and .NET Remoting in the case of .NET Apps
Can you give an example of what might be best suited to place in the Application_Start
and Session_Start subroutines?
The Application_Start event is guaranteed to occur only once throughout the lifetime of
the application. It's a good place to initialize global variables. For example, you might
want to retrieve a list of products from a database table and place the list in application
state or the Cache object. SessionStateModule exposes both Session_Start and
Session_End events.
What are the advantages and disadvantages of viewstate?
The primary advantages of the ViewState feature in ASP.NET are:
1. Simplicity. There is no need to write possibly complex code to store form data between
page submissions.
2. Flexibility. It is possible to enable, configure, and disable ViewState on a control-by-
control basis, choosing to persist the values of some fields but not others.
There are, however a few disadvantages that are worth pointing out:
1. Does not track across pages. ViewState information does not automatically transfer
from page to page. With the session
approach, values can be stored in the session and accessed from other pages. This is not
possible with ViewState, so storing
data into the session must be done explicitly.
2. ViewState is not suitable for transferring data for back-end systems. That is, data still
has to be transferred to the back
end using some form of data object.
Describe session handling in a webfarm, how does it work and what are the limits?
ASP.NET Session supports storing of session data in 3 ways, i] in In-Process ( in the
same memory that ASP.NET uses) , ii] out-of-process using Windows NT Service )in
separate memory from ASP.NET ) or iii] in SQL Server (persistent storage). Both the
Windows Service and SQL Server solution support a webfarm scenario where all the
web-servers can be configured to share common session state store.
1. Windows Service :
We can start this service by Start | Control Panel | Administrative Tools | Services | . In
that we service names ASP.NET State Service. We can start or stop service by manually
or configure to start automatically. Then we have to configure our web.config file
mode = “StateServer”
stateConnectionString = “tcpip=127.0.0.1:42424”
stateNetworkTimeout = “10”
sqlConnectionString=”data source = 127.0.0.1; uid=sa;pwd=”
cookieless =”Flase”
timeout= “20” />
Here ASP.Net Session is directed to use Windows Service for state management on local
server (address : 127.0.0.1 is TCP/IP loop-back address). The default port is 42424. we
can configure to any port but for that we have to manually edit the registry.
Follow these simple steps
- In a webfarm make sure you have the same config file in all your web servers.
- Also make sure your objects are serializable.
- For session state to be maintained across different web servers in the webfarm, the
application path of the web-site in the IIS Metabase should be identical in all the web-
servers in the webfarm.
Which template must you provide, in order to display data in a Repeater control?
You have to use the ItemTemplate to Display data. Syntax is as follows,
< ItemTemplate >
< div class =”rItem” >
< img src=”images/” hspace=”10” />
<b>
< /div >
< ItemTemplate >
How can you provide an alternating color scheme in a Repeater control?
Using the AlternatintItemTemplate
What property must you set, and what method must you call in your code, in order to
bind the data from some data source to the Repeater control?
Set the DataMember property to the name of the table to bind to. (If this property is not
set, by default the first table in the dataset is used.)
DataBind method, use this method to bind data from a source to a server control. This
method is commonly used after retrieving a data set through a database query.
What method do you use to explicitly kill a user s session?
You can dump (Kill) the session yourself by calling the method Session.Abandon.
ASP.NET automatically deletes a user's Session object, dumping its contents, after it has
been idle for a configurable timeout interval. This interval, in minutes, is set in the
section of the web.config file. The default is 20 minutes.
How do you turn off cookies for one page in your site?
Use Cookie.Discard property, Gets or sets the discard flag set by the server. When true,
this property instructs the client application not to save the Cookie on the user's hard disk
when a session ends.
Which two properties are on every validation control?
We have two common properties for every validation controls
1. Control to Validate,
2. Error Message.
What tags do you need to add within the asp:datagrid tags to bind columns manually?
< asp:DataGrid id="dgCart" AutoGenerateColumns="False" CellPadding="4"
Width="448px" runat="server">
< Columns >
< asp:ButtonColumn HeaderText="SELECT" Text="SELECT"
CommandName="select">< /asp:ButtonColumn >
< asp:BoundColumn DataField="ProductId" HeaderText="Product ID"><
/asp:BoundColumn >
< asp:BoundColumn DataField="ProductName" HeaderText="Product Name"><
/asp:BoundColumn >
< asp:BoundColumn DataField="UnitPrice" HeaderText="UnitPrice"><
/asp:BoundColumn >
< /Columns >
< /asp:DataGrid >
How do you create a permanent cookie?
Permanent cookies are the ones that are most useful. Permanent cookies are available
until a specified expiration date, and are stored on the hard disk. The location of cookies
differs with each browser, but this doesn’t matter, as this is all handled by your browser
and the server. If you want to create a permanent cookie called Name with a value of
Nigel, which expires in one month, you’d use the following code
Response.Cookies ("Name") = "Nigel"
Response.Cookies ("Name"). Expires = DateAdd ("m", 1, Now ())
What tag do you use to add a hyperlink column to the DataGrid?
< asp:HyperLinkColumn >
Which method do you use to redirect the user to another page without performing a round
trip to the client?
Server.transfer
What is the transport protocol you use to call a Web service SOAP ?
HTTP Protocol
Explain role based security ?
Role Based Security lets you identify groups of users to allow or deny based on their role
in the organization.In Windows NT and Windows XP, roles map to names used to
identify user groups. Windows defines several built-in groups, including Administrators,
Users, and Guests.To allow or deny access to certain groups of users, add the element to
the authorization list in your Web application's Web.config file.e.g.
< authorization >
< allow roles="Domain NameAdministrators" / >< !-- Allow Administrators in domain. --
>
< deny users="*" / >< !-- Deny anyone else. -- >
< /authorization >
How do you register JavaScript for webcontrols ?
You can register javascript for controls using Attribtues.Add(scriptname,scripttext)
method.
When do you set "" ?
Identity is a webconfig declaration under System.web, which helps to control the
application Identity of the web applicaton. Which can be at any
level(Machine,Site,application,subdirectory,or page), attribute impersonate with "true" as
value specifies that client impersonation is used.
What are different templates available in Repeater,DataList and Datagrid ?
Templates enable one to apply complicated formatting to each of the items displayed by a
control.Repeater control supports five types of templates.HeaderTemplate controls how
the header of the repeater control is formatted.ItemTemplate controls the formatting of
each item displayed.AlternatingItemTemplate controls how alternate items are formatted
and the SeparatorTemplate displays a separator between each item
displyed.FooterTemplate is used for controlling how the footer of the repeater control is
formatted.The DataList and Datagrid supports two templates in addition to the above
five.SelectedItem Template controls how a selected item is formatted and
EditItemTemplate controls how an item selected for editing is formatted.
What is ViewState ? and how it is managed ?
ASP.NET ViewState is a new kind of state service that developers can use to track UI
state on a per-user basis. Internally it uses an an old Web programming trick-
roundtripping state in a hidden form field and bakes it right into the page-processing
framework.It needs less code to write and maintain state in your Web-based forms.
What is web.config file ?
Web.config file is the configuration file for the Asp.net web application. There is one
web.config file for one asp.net application which configures
the particular application. Web.config file is written in XML with specific tags having
specific meanings.It includes databa which includes
connections,Session States,Error Handling,Security etc.
For example :
< configuration >
< appSettings >
< add key="ConnectionString"
value="server=localhost;uid=sa;pwd=;database=MyDB" / >
< /appSettings >
< /configuration >
Which property on a Combo Box do you set with a column name, prior to setting the
DataSource, to display data in the combo box?
DataTextField and DataValueField
Which control would you use if you needed to make sure the values in two different
controls matched?
CompareValidator is used to ensure that two fields are identical.
What is validationsummary server control?where it is used?.
The ValidationSummary control allows you to summarize the error messages from all
validation controls on a Web page in a single location. The summary can be displayed as
a list, a bulleted list, or a single paragraph, based on the value of the DisplayMode
property. The error message displayed in the ValidationSummary control for each
validation control on the page is specified by the ErrorMessage property of each
validation control. If the ErrorMessage property of the validation control is not set, no
error message is displayed in the ValidationSummary control for that validation control.
You can also specify a custom title in the heading section of the ValidationSummary
control by setting the HeaderText property.
You can control whether the ValidationSummary control is displayed or hidden by setting
the ShowSummary property. The summary can also be displayed in a message box by
setting the ShowMessageBox property to true.
What is the sequence of operation takes place when a page is loaded?
BeginTranaction - only if the request is transacted
Init - every time a page is processed
LoadViewState - Only on postback
ProcessPostData1 - Only on postback
Load - every time
ProcessData2 - Only on Postback
RaiseChangedEvent - Only on Postback
RaisePostBackEvent - Only on Postback
PreRender - everytime
BuildTraceTree - only if tracing is enabled
SaveViewState - every time
Render - Everytime
End Transaction - only if the request is transacted
Trace.EndRequest - only when tracing is enabled
UnloadRecursive - Every request
Difference between asp and asp.net?.
"ASP (Active Server Pages) and ASP.NET are both server side technologies for building
web sites and web applications, ASP.NET is Managed compiled code - asp is interpreted.
and ASP.net is fully Object oriented. ASP.NET has been entirely re-architected to provide
a highly productive programming experience based on the .NET Framework, and a robust
infrastructure for building reliable and scalable web
applications."
Name the validation control available in asp.net?.
RequiredField, RangeValidator,RegularExpression,Custom validator,compare Validator
What are the various ways of securing a web site that could prevent from hacking etc .. ?
1) Authentication/Authorization
2) Encryption/Decryption
3) Maintaining web servers outside the corporate firewall. etc.,
What is the difference between in-proc and out-of-proc?
An inproc is one which runs in the same process area as that of the client giving tha
advantage of speed but the disadvantage of stability becoz if it crashes it takes the client
application also with it.Outproc is one which works outside the clients memory thus
giving stability to the client, but we have to compromise a bit on speed.
When you’re running a component within ASP.NET, what process is it running within on
Windows XP? Windows 2000? Windows 2003?
On Windows 2003 (IIS 6.0) running in native mode, the component is running within the
w3wp.exe process associated with the application pool which has been configured for the
web application containing the component.
On Windows 2003 in IIS 5.0 emulation mode, 2000, or XP, it's running within the IIS
helper process whose name I do not remember, it being quite a while since I last used IIS
5.0.
What does aspnet_regiis -i do ?
Aspnet_regiis.exe is The ASP.NET IIS Registration tool allows an administrator or
installation program to easily update the script maps for an ASP.NET application to point
to the ASP.NET ISAPI version associated with the tool. The tool can also be used to
display the status of all installed versions of ASP. NET, register the ASP.NET version
coupled with the tool, create client-script directories, and perform other configuration
operations.
When multiple versions of the .NET Framework are executing side-by-side on a single
computer, the ASP.NET ISAPI version mapped to an ASP.NET application determines
which version of the common language runtime is used for the application.
The tool can be launched with a set of optional parameters. Option "i" Installs the version
of ASP.NET associated with Aspnet_regiis.exe and updates the script maps at the IIS
metabase root and below. Note that only applications that are currently mapped to an
earlier version of ASP.NET are affected
What is a PostBack?
The process in which a Web page sends data back to the same page on the server.
What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState?
ViewState is the mechanism ASP.NET uses to keep track of server control state values
that don't otherwise post back as part of the HTTP form. ViewState Maintains the UI
State of a Page
ViewState is base64-encoded.
It is not encrypted but it can be encrypted by setting EnableViewStatMAC="true"&
setting the machineKey validation type to 3DES. If you want to NOT maintain the
ViewState, include the directive < %@ Page EnableViewState="false" % > at the top of
an .aspx page or add the attribute EnableViewState="false" to any control.
What is the < machinekey > element and what two ASP.NET technologies is it used for?
Configures keys to use for encryption and decryption of forms authentication cookie data
and view state data, and for verification of out-of-process session state
identification.There fore 2 ASP.Net technique in which it is used are
Encryption/Decryption & Verification
What three Session State providers are available in ASP.NET 1.1? What are the pros and
cons of each?
ASP.NET provides three distinct ways to store session data for your application: in-
process session state, out-of-process session state as a Windows service, and out-of-
process session state in a SQL Server database. Each has it advantages.
1.In-process session-state mode
Limitations:
* When using the in-process session-state mode, session-state data is lost if
aspnet_wp.exe or the application domain restarts.
* If you enable Web garden mode in the < processModel > element of the application's
Web.config file, do not use in-process session-state mode. Otherwise, random data loss
can occur.
Advantage:
* in-process session state is by far the fastest solution. If you are storing only small
amounts of volatile data in session state, it is recommended that you use the in-process
provider.
2. The State Server simply stores session state in memory when in out-of-proc mode. In
this mode the worker process talks directly to the State Server
3. SQL mode, session states are stored in a SQL Server database and the worker process
talks directly to SQL. The ASP.NET worker processes are then able to take advantage of
this simple storage service by serializing and saving (using .NET serialization services)
all objects within a client's Session collection at the end of each Web request
Both these out-of-process solutions are useful primarily if you scale your application
across multiple processors or multiple computers, or where data cannot be lost if a server
or process is restarted.
What is the difference between HTTP-Post and HTTP-Get?
As their names imply, both HTTP GET and HTTP POST use HTTP as their underlying
protocol. Both of these methods encode request parameters as name/value pairs in the
HTTP request.
The GET method creates a query string and appends it to the script's URL on the server
that handles the request.
The POST method creates a name/value pairs that are passed in the body of the HTTP
request message.
Name and describe some HTTP Status Codes and what they express to the requesting
client.
When users try to access content on a server that is running Internet Information Services
(IIS) through HTTP or File Transfer Protocol (FTP), IIS returns a numeric code that
indicates the status of the request. This status code is recorded in the IIS log, and it may
also be displayed in the Web browser or FTP client. The status code can indicate whether
a particular request is successful or unsuccessful and can also reveal the exact reason why
a request is unsuccessful. There are 5 groups ranging from 1xx - 5xx of http status codes
exists.
101 - Switching protocols.
200 - OK. The client request has succeeded
302 - Object moved.
400 - Bad request.
500.13 - Web server is too busy.
Explain < @OutputCache% > and the usage of VaryByParam, VaryByHeader.
OutputCache is used to control the caching policies of an ASP.NET page or user control.
To cache a page @OutputCache directive should be defined as follows < %@
OutputCache Duration="100" VaryByParam="none" % >
VaryByParam: A semicolon-separated list of strings used to vary the output cache. By
default, these strings correspond to a query string value sent with GET method attributes,
or a parameter sent using the POST method. When this attribute is set to multiple
parameters, the output cache contains a different version of the requested document for
each specified parameter. Possible values include none, *, and any valid query string or
POST parameter name.
VaryByHeader: A semicolon-separated list of HTTP headers used to vary the output
cache. When this attribute is set to multiple headers, the output cache contains a different
version of the requested document for each specified header.
What is the difference between repeater over datalist and datagrid?
The Repeater class is not derived from the WebControl class, like the DataGrid and
DataList. Therefore, the Repeater lacks the stylistic properties common to both the
DataGrid and DataList. What this boils down to is that if you want to format the data
displayed in the Repeater, you must do so in the HTML markup.
The Repeater control provides the maximum amount of flexibility over the HTML
produced. Whereas the DataGrid wraps the DataSource contents in an HTML < table >,
and the DataList wraps the contents in either an HTML < table > or < span > tags
(depending on the DataList's RepeatLayout property), the Repeater adds absolutely no
HTML content other than what you explicitly specify in the templates.
While using Repeater control, If we wanted to display the employee names in a bold font
we'd have to alter the "ItemTemplate" to include an HTML bold tag, Whereas with the
DataGrid or DataList, we could have made the text appear in a bold font by setting the
control's ItemStyle-Font-Bold property to True.
The Repeater's lack of stylistic properties can drastically add to the development time
metric. For example, imagine that you decide to use the Repeater to display data that
needs to be bold, centered, and displayed in a particular font-face with a particular
background color. While all this can be specified using a few HTML tags, these tags will
quickly clutter the Repeater's templates. Such clutter makes it much harder to change the
look at a later date. Along with its increased development time, the Repeater also lacks
any built-in functionality to assist in supporting paging, editing, or editing of data. Due to
this lack of feature-support, the Repeater scores poorly on the usability scale.
However, The Repeater's performance is slightly better than that of the DataList's, and is
more noticeably better than that of the DataGrid's. Following figure shows the number of
requests per second the Repeater could handle versus the DataGrid and DataList
Can we handle the error and redirect to some pages using web.config?
Yes, we can do this, but to handle errors, we must know the error codes; only then we can
take the user to a proper error message page, else it may confuse the user.
CustomErrors Configuration section in web.config file:
The default configuration is:
< customErrors mode="RemoteOnly" defaultRedirect="Customerror.aspx">
< error statusCode="404" redirect="Notfound.aspx" / >
< /customErrors >
If mode is set to Off, custom error messages will be disabled. Users will receive detailed
exception error messages.
If mode is set to On, custom error messages will be enabled.
If mode is set to RemoteOnly, then users will receive custom errors, but users accessing
the site locally will receive detailed error messages.
Add an < error > tag for each error you want to handle. The error tag will redirect the user
to the Notfound.aspx page when the site returns the 404 (Page not found) error.
[Example]
There is a page MainForm.aspx
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
'Put user code to initialize the page here
Dim str As System.Text.StringBuilder
str.Append("hi") ' Error Line as str is not instantiated
Response.Write(str.ToString)
End Sub
[Web.Config]
< customErrors mode="On" defaultRedirect="Error.aspx"/ >
' a simple redirect will take the user to Error.aspx [user defined] error file.
< customErrors mode="RemoteOnly" defaultRedirect="Customerror.aspx">
< error statusCode="404" redirect="Notfound.aspx" / >
< /customErrors >
'This will take the user to NotFound.aspx defined in IIS.
How do you implement Paging in .Net?
The DataGrid provides the means to display a group of records from the data source (for
example, the first 10), and then navigate to the "page" containing the next 10 records, and
so on through the data.
Using Ado.Net we can explicit control over the number of records returned from the data
source, as well as how much data is to be cached locally in the DataSet.
1.Using DataAdapter.fill method give the value of 'Maxrecords' parameter
(Note: - Don't use it because query will return all records but fill the dataset based on
value of 'maxrecords' parameter).
2.For SQL server database, combines a WHERE clause and a ORDER BY clause with
TOP predicate.
3.If Data does not change often just cache records locally in DataSet and just take some
records from the DataSet to display.
What is the difference between Server.Transfer and Response.Redirect?
Server.Transfer() : client is shown as it is on the requesting page only, but the all the
content is of the requested page. Data can be persist across the pages using Context.Item
collection, which is one of the best way to transfer data from one page to another keeping
the page state alive.
Response.Dedirect() :client knows the physical location (page name and query string as
well). Context.Items loses the persistence when navigate to destination page. In earlier
versions of IIS, if we wanted to send a user to a new Web page, the only option we had
was Response.Redirect. While this method does accomplish our goal, it has several
important drawbacks. The biggest problem is that this method causes each page to be
treated as a separate transaction. Besides making it difficult to maintain your transactional
integrity, Response.Redirect introduces some additional headaches. First, it prevents good
encapsulation of code. Second, you lose access to all of the properties in the Request
object. Sure, there are workarounds, but they're difficult. Finally, Response.Redirect
necessitates a round trip to the client, which, on high-volume sites, causes scalability
problems. As you might suspect, Server.Transfer fixes all of these problems. It does this
by performing the transfer on the server without requiring a roundtrip to the client.
Response.Redirect sends a response to the client browser instructing it to request the
second page. This requires a round-trip to the client, and the client initiates the Request
for the second page. Server.Transfer transfers the process to the second page without
making a round-trip to the client. It also transfers the HttpContext to the second page,
enabling the second page access to all the values in the HttpContext of the first page.
Can you create an app domain?
Yes, We can create user app domain by calling on of the following overload static
methods of the System.AppDomain class
1. Public static AppDomain CreateDomain(String friendlyName)
2. Public static AppDomain CreateDomain(String friendlyName, Evidence securityInfo)
3. Public static AppDomain CreateDomain(String friendlyName, Evidence securityInfo,
AppDomainSetup info)
4. Public static AppDomain CreateDomain(String friendlyName, Evidence securityInfo,
String appBasePath, String appRelativeSearchPath, bool shadowCopyFiles)
What are the various security methods which IIS Provides apart from .NET ?
The various security methods which IIS provides are
a) Authentication Modes
b) IP Address and Domain Name Restriction
c) DNS Lookups DNS Lookups
d) The Network ID and Subnet Mask
e) SSL
Next >>
When was .NET announced?
Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET
'vision'. The July 2000 PDC had a number of sessions on .NET technology, and delegates
were given CDs containing a pre-release version of the .NET framework/SDK and Visual
Studio.NET.
When was the first version of .NET released?
The final version of the 1.0 SDK and runtime was made publicly available around 6pm
PST on 15-Jan-2002. At the same time, the final version of Visual Studio.NET was made
available to MSDN subscribers.
What is IL?
IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or
CIL (Common Intermediate Language). All .NET source code (of any language) is
compiled to IL. The IL is then converted to machine code at the point where the software
is installed, or at run-time by a Just-In-Time (JIT) compiler.
What is reflection?
All .NET compilers produce metadata about the types defined in the modules they
produce. This metadata is packaged along with the module (modules in turn are packaged
together in assemblies), and can be accessed by a mechanism called reflection. The
System.Reflection namespace contains classes that can be used to interrogate the types
for a module/assembly.
Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to
access type library data in COM, and it is used for similar purposes - e.g. determining
data type sizes for marshaling data across context/process/machine boundaries.
Reflection can also be used to dynamically invoke methods (see
System.Type.InvokeMember ) , or even create types dynamically at run-time (see
System.Reflection.Emit.TypeBuilder).
What is side-by-side execution? Can two application one using private assembly and
other using Shared assembly be stated as a side-by-side executables?
Side-by-side execution is the ability to run multiple versions of an application or
component on the same computer. You can have multiple versions of the common
language runtime, and multiple versions of applications and components that use a
version of the runtime, on the same computer at the same time. Since versioning is only
applied to shared assemblies, and not to private assemblies, two application one using
private assembly and one using shared assembly cannot be stated as side-by-side
executables.
What's the difference between the Debug class and Trace class?
Documentation looks the same. Use Debug class for debug builds, use Trace class for
both debug and release builds.
What is serialization?
Serialization is the process of converting an object into a stream of bytes. Deserialization
is the opposite process of creating an object from a stream of bytes. Serialization /
Deserialization is mostly used to transport objects (e.g. during remoting), or to persist
objects (e.g. to a file or database).
Note that the numeric label (1.3.1) is just a caspol invention to make the code groups easy
to manipulate from the command-line. The underlying runtime never sees it.
I can't be bothered with all this CAS stuff. Can I turn it off?
Yes, as long as you are an administrator. Just run: caspol -s off
Heap:
A portion of memory reserved for a program to use for the temporary storage of data
structures whose existence or size cannot be determined until the program is running.
Un-Managed Code:
Code that is created without regard for the conventions and requirements of the common
language runtime. Unmanaged code executes in the common language runtime
environment with minimal services (for example, no garbage collection, limited
debugging, and so on).
Value Type:
Value types are allocated on the stack just like primitive types in VBScript, VB6 and
C/C++. Value types are not instantiated using new go out of scope when the function they
are defined within returns.
Value types in the CLR are defined as types that derive from system.valueType.
A data type that fully describes a value by specifying the sequence of bits that constitutes
the value's representation. Type information for a value type instance is not stored with
the instance at run time, but it is available in metadata. Value type instances can be
treated as objects using boxing.
Un-Boxing:
The conversion of an object instance to a value type.
What is JIT and how is works ?
An acronym for "just-in-time," a phrase that describes an action that is taken only when it
becomes necessary, such as just-in-time compilation or just-in-time object activation
What is namespace used for loading assemblies at run time and name the methods?
System.Reflection
Explain encapsulation ?
The implementation is hidden, the interface is exposed.
What data type should you use if you want an 8-bit value that's signed?
sbyte.
What happens when you encounter a continue statement inside the for loop?
The code for the rest of the loop is ignored, the control is transferred back to the
beginning of the loop.
What's the .NET datatype that allows the retrieval of data by a unique key?
HashTable.
Will finally block get executed if the exception had not occurred?
Yes.
What's a delegate?
A delegate object encapsulates a reference to a method. In C++ they were referred to as
function pointers.
What's the difference between the Debug class and Trace class?
Documentation looks the same. Use Debug class for debug builds, use Trace class for
both debug and release builds.
What are three test cases you should go through in unit testing?
Positive test cases (correct data, correct output), negative test cases (broken or missing
data, proper handling), exception test
cases (exceptions are thrown and caught properly).
What's the implicit name of the parameter that gets passed into the class' set method?
Value, and it's datatype depends on whatever variable we're changing.
Can you declare the override method static while the original method is non-static?
No, you can't, the signature of the virtual method must remain the same, only the
keyword virtual is changed to keyword override.
Can you prevent your class from being inherited and becoming a base class for some
other classes?
Yes, that's what keyword sealed in the class definition is for. The developer trying to
derive from your class will get a message: cannot inherit from Sealed class
WhateverBaseClassName. It's the same concept as final class in Java.
Can you allow class to be inherited, but prevent the method from being over-ridden?
Yes, just leave the class public and make the method sealed.
Why can't you specify the accessibility modifier for methods inside the interface?
They all must be public. Therefore, to prevent you from getting the false impression that
you have any freedom of choice, you are not allowed to specify any accessibility, it's
public by default.
If a base class has a bunch of overloaded constructors, and an inherited class has another
bunch of overloaded constructors, can you enforce a call from an inherited constructor to
an arbitrary base constructor?
Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate
constructor) in the overloaded constructor definition inside the inherited class.
What's the .NET class that allows the retrieval of a data element using a unique key?
HashTable.
Will the finally block get executed if an exception has not occurred?
Yes.
What's an interface?
It's an abstract class with public abstract methods all of which must be implemented in
the inherited classes.
Why can't you specify the accessibility modifier for methods inside the interface?
They all must be public. Therefore, to prevent you from getting the false impression that
you have any freedom of choice,
you are not allowed to specify any accessibility, it's public by default.
Can you declare an override method to be static if the original method is non-static?
No. The signature of the virtual method must remain the same, only the keyword virtual
is changed to keyword override.
Can you write a class without specifying namespace? Which namespace does it belong to
by default?
Yes, you can, then the class belongs to global namespace which has no name. For
commercial products, naturally, you wouldn't want global namespace.
What is a formatter?
A formatter is an object that is responsible for encoding and serializing data into
messages on one end, and deserializing and decoding messages into data on the other
end.
Different b/w .NET & J2EE ?
Differences between J2EE and the .NET Platform
Vendor Neutrality
The .NET platform is not vendor neutral, it is tied to the Microsoft operating systems. But
neither are any of the J2EE implementations
Many companies buy into J2EE believing that it will give them vendor neutrality. And, in
fact, this is a stated goal of Sun's vision:
A wide variety of J2EE product configurations and implementations, all of which meet
the requirements of this specification, are possible. A portable J2EE application will
function correctly when successfully deployed in any of these products. (ref : Java 2
Platform Enterprise Edition Specification, v1.3, page 2-7 available at
http://java.sun.com/j2ee/)
Overall Maturity
Given that the .NET platform has a three year lead over J2EE, it should be no surprise to
learn that the .NET platform is far more mature than the J2EE platform. Whereas we have
high volume highly reliable web sites using .NET technologies (NASDAQ and Dell
being among many examples)
Interoperability and Web Services
The .NET platform eCollaboration model is, as I have discussed at length, based on the
UDDI and SOAP standards. These standards are widely supported by more than 100
companies. Microsoft, along with IBM and Ariba, are the leaders in this area. Sun is a
member of the UDDI consortium and recognizes the importance of the UDDI standards.
In a recent press release, Sun's George Paolini, Vice President for the Java Community
Development, says:
"Sun has always worked to help establish and support open, standards-based technologies
that facilitate the growth of network-based applications, and we see UDDI as an
important project to establish a registry framework for business-to-business e-commerce
But while Sun publicly says it believes in the UDDI standards, in reality, Sun has done
nothing whatsoever to incorporate any of the UDDI standards into J2EE.
Scalability
Typical Comparision w.r.t Systems and their costs
J2EE
Company System Total Sys. Cost
Bull Escala T610 c/s 16,785 $1,980,179
IBM RS/6000 Enterprise Server F80 16,785 $2,026,681
Bull Escala EPC810 c/s 33,375 $3,037,499
IBM RS/6000 Enterprise Server M80 33,375 $3,097,055
Bull Escala EPC2450 110,403 $9,563,263
IBM IBM eServer pSeries 680 Model 7017-S85 110,403 $9,560,594
Framework Support
The .NET platform includes such an eCommerce framework called Commerce Server. At
this point, there is no equivalent vendor-neutral framework in the J2EE space. With J2EE,
you should assume that you will be building your new eCommerce solution from scratch
Moreover, no matter what [J2EE] vendor you choose, if you expect a component
framework that will allow you to quickly field complete e-business applications, you are
in for a frustrating experience
Language
In the language arena, the choice is about as simple as it gets. J2EE supports Java, and
only Java. It will not support any other language in the foreseeable future. The .NET
platform supports every language except Java (although it does support a language that is
syntactically and functionally equivalent to Java, C#). In fact, given the importance of the
.NET platform as a language independent vehicle, it is likely that any language that
comes out in the near future will include support for the .NET platform.
Some companies are under the impression that J2EE supports other languages. Although
both IBM's WebSphere and BEA's WebLogic support other languages, neither does it
through their J2EE technology. There are only two official ways in the J2EE platform to
access other languages, one through the Java Native Interface and the other through
CORBA interoperability. Sun recommends the later approach. As Sun's Distinguished
Scientist and Java Architect Rick Cattell said in a recent interview.
Portability
The reason that operating system portability is a possibility with J2EE is not so much
because of any inherent portability of J2EE, as it is that most of the J2EE vendors support
multiple operating systems. Therefore as long as one sticks with a given J2EE vendor and
a given database vendor, moving from one operating system to another should be
possible. This is probably the single most important benefit in favor of J2EE over the
.NET platform, which is limited to the Windows operating system. It is worth noting,
however, that Microsoft has submitted the specifications for C# and a subset of the .NET
Framework (called the common language infrastructure) to ECMA, the group that
standardizes JavaScript.
J2EE offers an acceptable solution to ISVs when the product must be marketed to non-
Windows customers, particularly when the J2EE platform itself can be bundled with the
ISV's product as an integrated offering.
If the primary customer base for the ISV is Windows customers, then the .NET platform
should be chosen. It will provide much better performance at a much lower cost.
Conclusion
Sun's J2EE vision is based on a family of specifications that can be implemented by
many vendors. It is open in the sense that any company can license and implement the
technology, but closed in the sense that it is controlled by a single vendor, and a self
contained architectural island with very limited ability to interact outside of itself. One of
J2EE's major disadvantages is that the choice of the platform dictates the use of a single
programming language, and a programming language that is not well suited for most
businesses. One of J2EE's major advantages is that most of the J2EE vendors do offer
operating system portability.
Microsoft's .NET platform vision is a family of products rather than specifications, with
specifications used primarily to define points of interoperability. The major disadvantage
of this approach is that if is limited to the Windows platform, so applications written for
the .NET platform can only be run on .NET platforms. Their are several important
advantages to the .NET platform:
* The cost of developing applications is much lower, since standard business languages
can be used and device independent presentation tier logic can be written.
* The cost of running applications is much lower, since commodity hardware platforms
(at 1/5 the cost of their Unix counterparts) can be used.
* The ability to scale up is much greater, with the proved ability to support at least ten
times the number of clients any J2EE platform has shown itself able to support.
* Interoperability is much stronger, with industry standard eCollaboration built into the
platform.
What are the Main Features of .NET platform?
Features of .NET Platform are :-
Common Language Runtime
Explains the features and benefits of the common language runtime, a run-time
environment that manages the execution of code and provides services that simplify the
development process.
Assemblies
Defines the concept of assemblies, which are collections of types and resources that form
logical units of functionality. Assemblies are the fundamental units of deployment,
version control, reuse, activation scoping, and security permissions.
Application Domains
Explains how to use application domains to provide isolation between applications.
Runtime Hosts
Describes the runtime hosts supported by the .NET Framework, including ASP.NET,
Internet Explorer, and shell executables.
Common Type System
Identifies the types supported by the common language runtime.
Metadata and Self-Describing Components
Explains how the .NET Framework simplifies component interoperation by allowing
compilers to emit additional declarative information, or metadata, into all modules and
assemblies.
Cross-Language Interoperability
Explains how managed objects created in different programming languages can interact
with one another.
.NET Framework Security
Describes mechanisms for protecting resources and code from unauthorized code and
unauthorized users.
.NET Framework Class Library
Introduces the library of types provided by the .NET Framework, which expedites and
optimizes the development process and gives you access to system functionality.
What is the use of JIT ?
JIT (Just - In - Time) is a compiler which converts MSIL code to Native Code (ie.. CPU-
specific code that runs on the same computer architecture).
Because the common language runtime supplies a JIT compiler for each supported CPU
architecture, developers can write a set of MSIL that can be JIT-compiled and run on
computers with different architectures. However, your managed code will run only on a
specific operating system if it calls platform-specific native APIs, or a platform-specific
class library.
JIT compilation takes into account the fact that some code might never get called during
execution. Rather than using time and memory to convert all the MSIL in a portable
executable (PE) file to native code, it converts the MSIL as needed during execution and
stores the resulting native code so that it is accessible for subsequent calls. The loader
creates and attaches a stub to each of a type's methods when the type is loaded. On the
initial call to the method, the stub passes control to the JIT compiler, which converts the
MSIL for that method into native code and modifies the stub to direct execution to the
location of the native code. Subsequent calls of the JIT-compiled method proceed directly
to the native code that was previously generated, reducing the time it takes to JIT-compile
and run the code.
What meant of assembly & global assembly cache (gac) & Meta data.
Assembly :-- An assembly is the primary building block of a .NET based application. It is
a collection of functionality that is built, versioned, and deployed as a single
implementation unit (as one or more files). All managed types and resources are marked
either as accessible only within their implementation unit, or as accessible by code
outside that unit. It overcomes the problem of 'dll Hell'.The .NET Framework uses
assemblies as the fundamental unit for several purposes:
· Security
· Type Identity
· Reference Scope
· Versioning
· Deployment
Global Assembly Cache :-- Assemblies can be shared among multiple applications on the
machine by registering them in global Assembly cache(GAC). GAC is a machine wide a
local cache of assemblies maintained by the .NET Framework. We can register the
assembly to global assembly cache by using gacutil command.
We can Navigate to the GAC directory, C:winntAssembly in explore. In the tools menu
select the cache properties; in the windows displayed you can set the memory limit in
MB used by the GAC
MetaData :--Assemblies have Manifests. This Manifest contains Metadata information of
the Module/Assembly as well as it contains detailed Metadata of other
assemblies/modules references (exported). It's the Assembly Manifest which
differentiates between an Assembly and a Module.
What are the mobile devices supported by .net platform
The Microsoft .NET Compact Framework is designed to run on mobile devices such as
mobile phones, Personal Digital Assistants (PDAs), and embedded devices. The easiest
way to develop and test a Smart Device Application is to use an emulator.
These devices are divided into two main divisions:
1) Those that are directly supported by .NET (Pocket PCs, i-Mode phones, and WAP
devices)
2) Those that are not (Palm OS and J2ME-powered devices).
What is GUID , why we use it and where?
GUID :-- GUID is Short form of Globally Unique Identifier, a unique 128-bit number
that is produced by the Windows OS or by some Windows applications to identify a
particular component, application, file, database entry, and/or user. For instance, a Web
site may generate a GUID and assign it to a user's browser to record and track the
session. A GUID is also used in a Windows registry to identify COM DLLs. Knowing
where to look in the registry and having the correct GUID yields a lot information about a
COM object (i.e., information in the type library, its physical location, etc.). Windows
also identifies user accounts by a username (computer/domain and username) and assigns
it a GUID. Some database administrators even will use GUIDs as primary key values in
databases.
GUIDs can be created in a number of ways, but usually they are a combination of a few
unique settings based on specific point in time (e.g., an IP address, network MAC
address, clock date/time, etc.).
Describe the difference between inline and code behind - which is best in a loosely
coupled solution
ASP.NET supports two modes of page development: Page logic code that is written
inside runat="server"> blocks within an .aspx file and dynamically compiled the first
time the page is requested on the server. Page logic code that is written within an external
class that is compiled prior to deployment on a server and linked ""behind"" the .aspx file
at run time.
Whats MSIL, and why should my developers need an appreciation of it if at all?
When compiling the source code to managed code, the compiler translates the source into
Microsoft intermediate language (MSIL). This is a CPU-independent set of instructions
that can efficiently be converted to native code. Microsoft intermediate language (MSIL)
is a translation used as the output of a number of compilers. It is the input to a just-in-
time (JIT) compiler. The Common Language Runtime includes a JIT compiler for the
conversion of MSIL to native code.
Before Microsoft Intermediate Language (MSIL) can be executed it, must be converted
by the .NET Framework just-in-time (JIT) compiler to native code. This is CPU-specific
code that runs on the same computer architecture as the JIT compiler. Rather than using
time and memory to convert all of the MSIL in a portable executable (PE) file to native
code. It converts the MSIL as needed whilst executing, then caches the resulting native
code so its accessible for any subsequent calls.
How many .NET languages can a single .NET DLL contain?
One
What type of code (server or client) is found in a Code-Behind class?
Server
Whats an assembly?
Assemblies are the building blocks of .NET Framework applications; they form the
fundamental unit of deployment, version control, reuse, activation scoping, and security
permissions. An assembly is a collection of types and resources that are built to work
together and form a logical unit of functionality. An assembly provides the common
language runtime with the information it needs to be aware of type implementations. To
the runtime, a type does not exist outside the context of an assembly.
How many classes can a single .NET DLL contain?
Unlimited.
What is the difference between string and String ?
No difference
What is manifest?
It is the metadata that describes the assemblies.
What is metadata?
Metadata is machine-readable information about a resource, or ""data about data."" Such
information might include details on content, format, size, or other characteristics of a
data
source. In .NET, metadata includes type definitions, version information, external
assembly references, and other standardized information.
What are the types of assemblies?
There are four types of assemblies in .NET:
Static assemblies
These are the .NET PE files that you create at compile time.
Dynamic assemblies
These are PE-formatted, in-memory assemblies that you dynamically create at runtime
using the classes in the System.Reflection.Emit namespace.
Private assemblies
These are static assemblies used by a specific application.
Public or shared assemblies
These are static assemblies that must have a unique shared name and can be used by any
application.
An application uses a private assembly by referring to the assembly using a static path or
through an XML-based application configuration file. While the CLR doesn't enforce
versioning policies-checking whether the correct version is used-for private assemblies, it
ensures that an
application uses the correct shared assemblies with which the application was built. Thus,
an application uses a specific shared assembly by referring to the specific shared
assembly, and the CLR ensures that the correct version is loaded at runtime.
In .NET, an assembly is the smallest unit to which you can associate a version number;
What are delegates?where are they used ?
A delegate defines a reference type that can be used to encapsulate a method with a
specific signature. A delegate instance encapsulates a static or an instance method.
Delegates are roughly similar to function pointers in C++; however, delegates are type-
safe and secure.
When do you use virutal keyword?.
When we need to override a method of the base class in the sub class, then we give the
virtual keyword in the base class method. This makes the method in the base class to be
overridable. Methods, properties, and indexers can be virtual, which means that their
implementation can be overridden in derived classes.
What are class access modifiers ?
Access modifiers are keywords used to specify the declared accessibility of a member or
a type. This section introduces the four access modifiers:
· Public - Access is not restricted.
· Protected - Access is limited to the containing class or types derived from the containing
class.
· Internal - Access is limited to the current assembly.
· Protected inertnal - Access is limited to the current assembly or types derived · from the
containing class.
· Private - Access is limited to the containing type.
What Is Boxing And Unboxing?
Boxing :- Boxing is an implicit conversion of a value type to the type object type
Eg:-
Consider the following declaration of a value-type variable:
int i = 123;
object o = (object) i;
Boxing Conversion
UnBoxing :- Unboxing is an explicit conversion from the type object to a value type
Eg:
int i = 123; // A value type
object box = i; // Boxing
int j = (int)box; // Unboxing
What is Value type and refernce type in .Net?.
Value Type : A variable of a value type always contains a value of that type. The
assignment to a variable of a value type creates a copy of the assigned value, while the
assignment to a variable of a reference type creates a copy of the reference but not of the
referenced object.
The value types consist of two main categories:
* Stuct Type
* Enumeration Type
Reference Type :Variables of reference types, referred to as objects, store references to
the actual data. This section introduces the following keywords used to declare reference
types:
* Class
* Interface
* Delegate
This section also introduces the following built-in reference types:
* object
* string
What is the difference between structures and enumeration?.
Unlike classes, structs are value types and do not require heap allocation. A variable of a
struct type directly contains the data of the struct, whereas a variable of a class type
contains a reference to the data. They are derived from System.ValueType class.
Enum->An enum type is a distinct type that declares a set of named constants.They are
strongly typed constants. They are unique types that allow to declare symbolic names to
integral values. Enums are value types, which means they contain their own value, can't
inherit or be inherited from and assignment copies the value of one enum to another.
public enum Grade
{
A,
B,
C
}
What is namespaces?.
Namespace is a logical naming scheme for group related types.Some class types that
logically belong together they can be put into a common namespace. They prevent
namespace collisions and they provide scoping. They are imported as "using" in C# or
"Imports" in Visual Basic. It seems as if these directives specify a particular assembly, but
they don't. A namespace can span multiple assemblies, and an assembly can define
multiple namespaces. When the compiler needs the definition for a class type, it tracks
through each of the different imported namespaces to the type name and searches each
referenced assembly until it is found.
Namespaces can be nested. This is very similar to packages in Java as far as scoping is
concerned.
What is GUID and why we need to use it and in what condition? How this is created.
A GUID is a 128-bit integer (16 bytes) that can be used across all computers and
networks wherever a unique identifier is required. Such an identifier has a very low
probability of being duplicated. Visual Studio .NET IDE has a utility under the tools
menu to generate GUIDs.
Why do you need to serialize.?
We need to serialize the object,if you want to pass object from one computer/application
domain to another.Process of converting complex objects into stream of bytes that can be
persisted or transported.Namespace for serialization is System.Runtime.Serialization.The
ISerializable interface allows you to make any class Serializable..NET framework
features 2 serializing method.
1.Binary Serialization 2.XML Serialization
What is inline schema, how does it works?
Schemas can be included inside of XML file is called Inline Schemas.This is useful when
it is inconvenient to physically seprate the schema and the XML document.A schema is
an XML document that defines the structure, constraints, data types, and relationships of
the elements that constitute the data contained inside the XML document or in another
XML document.Schema can be an external file which uses the XSD or XDR extension
called external schema. Inline schema can take place even when validation is turned off.
Describe the advantages of writing a managed code application instead of unmanaged
one. What's involved in certain piece of code being managed?
"Advantage includes automatic garbage collection,memory management,security,type
checking,versioning
Managed code is compiled for the .NET run-time environment. It runs in the Common
Language Runtime (CLR), which is the heart of the .NET Framework. The CLR provides
services such as security,
memory management, and cross-language integration. Managed applications written to
take advantage of the features of the CLR perform more efficiently and safely, and take
better advantage of developers existing expertise in languages that support the .NET
Framework.
Unmanaged code includes all code written before the .NET Framework was introduced—
this includes code written to use COM, native Win32, and Visual Basic 6. Because it does
not run inside the .NET environment, unmanaged code cannot make use of any .NET
managed facilities."
What are multicast delegates ? give me an example ?
Delegate that can have more than one element in its invocation List.
using System;
namespace SampleMultiCastDelegate
{
class MultiCast
{
public delegate string strMultiCast(string s);
}
}
}
}
}
Can a nested object be used in Serialization ?
Yes. If a class that is to be serialized contains references to objects of other classes, and if
those classes have been marked as serializable, then their objects are serialized too.
Difference between int and int32 ?
Both are same. System.Int32 is a .NET class. Int is an alias name for System.Int32.
Describe the difference between a Thread and a Process?
A Process is an instance of an running application. And a thread is the Execution stream
of the Process. A process can have multiple Thread.
When a process starts a specific memory area is allocated to it. When there is multiple
thread in a process, each thread gets a memory for storing the variables in it and plus they
can access to the global variables which is common for all the thread. Eg.A Microsoft
Word is a Application. When you open a word file,an instance of the Word starts and a
process is allocated to this instance which has one thread.
What is the difference between an EXE and a DLL?
You can create an objects of Dll but not of the EXE.
Dll is an In-Process Component whereas EXE is an OUt-Process Component.
Exe is for single use whereas you can use Dll for multiple use.
Exe can be started as standalone where dll cannot be.
What is strong-typing versus weak-typing? Which is preferred? Why?
Strong typing implies that the types of variables involved in operations are associated to
the variable, checked at compile-time, and require explicit conversion; weak typing
implies that they are associated to the value, checked at run-time, and are implicitly
converted as required. (Which is preferred is a disputable point, but I personally prefer
strong typing because I like my errors to be found as soon as possible.)
What is a PID? How is it useful when troubleshooting a system?
PID is the process Id of the application in Windows. Whenever a process starts running in
the Windows environment, it is associated with an individual process Id or PID.
The PID (Process ID) a unique number for each item on the Process Tab, Image Name
list. How do you get the PID to appear? In Task Manger, select the View menu, then
select columns and check PID (Process Identifier).
In Linux, PID is used to debug a process explicitly. However we cannot do this in a
windows environment.
Microsoft has launched a SDK called as Microsoft Operations Management (MOM).
This uses the PID to find out which dll’s have been loaded by a process in the memory.
This is essentially helpful in situations where the Process which has a memory leak is to
be traced to a erring dll. Personally I have never used a PID, our Windows debugger does
the things required to find out.
NET FrameWork
<<>>
What is the GAC? What problem does it solve?
Each computer where the common language runtime is installed has a machine-wide
code cache called the global assembly cache. The global assembly cache stores
assemblies that are to be shared by several applications on the computer. This area is
typically the folder under windows or winnt in the machine.
All the assemblies that need to be shared across applications need to be done through the
Global assembly Cache only. However it is not necessary to install assemblies into the
global assembly cache to make them accessible to COM interop or unmanaged code.
There are several ways to deploy an assembly into the global assembly cache:
· Use an installer designed to work with the global assembly cache. This is the preferred
option for installing assemblies into the global assembly cache.
· Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by
the .NET Framework SDK.
· Use Windows Explorer to drag assemblies into the cache.
GAC solves the problem of DLL Hell and DLL versioning. Unlike earlier situations,
GAC can hold two assemblies of the same name but different version. This ensures that
the applications which access a particular assembly continue to access the same assembly
even if another version of that assembly is installed on that machine.
Describe what an Interface is and how it’s different from a Class.
An interface is a structure of code which is similar to a class. An interface is a prototype
for a class and is useful from a logical design perspective. Interfaces provide a means to
define the protocols for a class without worrying about the implementation details. The
syntax for creating interfaces follows:
interface Identifier {
InterfaceBody
}
Identifier is the name of the interface and InterfaceBody refers to the abstract methods
and static final variables that make up the interface. Because it is assumed that all the
methods in an interface are abstract, it isn't necessary to use the abstract keyword
An interface is a description of some of the members available from a class. In practice,
the syntax typically looks similar to a class definition, except that there's no code defined
for the methods — just their name, the arguments passed and the type of the value
returned.
So what good is it? None by itself. But you create an interface so that classes will
implement it.
But what does it mean to implement an interface. The interface acts as a contract or
promise. If a class implements an interface, then it must have the properties and methods
of the interface defined in the class. This is enforced by the compiler.
Broadly the differentiators between classes and interfaces is as follows
• Interface should not have any implementation.
• Interface can not create any instance.
• Interface should provide high level abstraction from the implementation.
• Interface can have multiple inheritances.
• Default access level of the interface is public.
What is the difference between XML Web Services using ASMX and .NET Remoting
using SOAP?
ASP.NET Web services and .NET Remoting provide a full suite of design options for
cross-process and cross-plaform communication in distributed applications. In general,
ASP.NET Web services provide the highest levels of interoperability with full support for
WSDL and SOAP over HTTP, while .NET Remoting is designed for common language
runtime type-system fidelity and supports additional data format and communication
channels. Hence if we looking cross-platform communication than web services is the
choice coz for .NET remoting .Net framework is requried which may or may not present
for the other platform.
Serialization and Metadata
ASP.NET Web services rely on the System.Xml.Serialization.XmlSerializer class to
marshal data to and from SOAP messages at runtime. For metadata, they generate WSDL
and XSD definitions that describe what their messages contain. The reliance on pure
WSDL and XSD makes ASP.NET Web services metadata portable; it expresses data
structures in a way that other Web service toolkits on different platforms and with
different programming models can understand. In some cases, this imposes constraints on
the types you can expose from a Web service—XmlSerializer will only marshal things
that can be expressed in XSD. Specifically, XmlSerializer will not marshal object graphs
and it has limited support for container types.
.NET Remoting relies on the pluggable implementations of the IFormatter interface used
by the System.Runtime.Serialization engine to marshal data to and from messages. There
are two standard formatters,
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter and
System.Runtime.Serialization.Formatters.Soap.SoapFormatter. The BinaryFormatter and
SoapFormatter, as the names suggest, marshal types in binary and SOAP format
respectively. For metadata, .NET Remoting relies on the common language runtime
assemblies, which contain all the relevant information about the data types they
implement, and expose it via reflection. The reliance on the assemblies for metadata
makes it easy to preserve the full runtime type-system fidelity. As a result, when the .NET
Remoting plumbing marshals data, it includes all of a class's public and private members;
handles object graphs correctly; and supports all container types (e.g.,
System.Collections.Hashtable). However, the reliance on runtime metadata also limits the
reach of a .NET Remoting system—a client has to understand .NET constructs in order to
communicate with a .NET Remoting endpoint. In addition to pluggable formatters, the
.NET Remoting layer supports pluggable channels, which abstract away the details of
how messages are sent. There are two standard channels, one for raw TCP and one for
HTTP. Messages can be sent over either channel independent of format.
Distributed Application Design: ASP.NET Web Services vs. .NET Remoting
ASP.NET Web services favor the XML Schema type system, and provide a simple
programming model with broad cross-platform reach. .NET Remoting favors the runtime
type system, and provides a more complex programming model with much more limited
reach. This essential difference is the primary factor in determining which technology to
use. However, there are a wide range of other design factors, including transport
protocols, host processes, security, performance, state management, and support for
transactions to consider as well.
Security
Since ASP.NET Web services rely on HTTP, they integrate with the standard Internet
security infrastructure. ASP.NET leverages the security features available with IIS to
provide strong support for standard HTTP authentication schemes including Basic,
Digest, digital certificates, and even Microsoft® .NET Passport. (You can also use
Windows Integrated authentication, but only for clients in a trusted domain.) One
advantage of using the available HTTP authentication schemes is that no code change is
required in a Web service; IIS performs authentication before the ASP.NET Web services
are called. ASP.NET also provides support for .NET Passport-based authentication and
other custom authentication schemes. ASP.NET supports access control based on target
URLs, and by integrating with the .NET code access security (CAS) infrastructure. SSL
can be used to ensure private communication over the wire.
Although these standard transport-level techniques to secure Web services are quite
effective, they only go so far. In complex scenarios involving multiple Web services in
different trust domains, you have to build custom ad hoc solutions. Microsoft and others
are working on a set of security specifications that build on the extensibility of SOAP
messages to offer message-level security capabilities. One of these is the XML Web
Services Security Language (WS-Security), which defines a framework for message-level
credential transfer, message integrity, and message confidentiality.
As noted in the previous section, the .NET Remoting plumbing does not secure cross-
process invocations in the general case. A .NET Remoting endpoint hosted in IIS with
ASP.NET can leverage all the same security features available to ASP.NET Web services,
including support for secure communication over the wire using SSL. If you are using the
TCP channel or the HTTP channel hosted in processes other than aspnet_wp.exe, you
have to implement authentication, authorization and privacy mechanisms yourself.
One additional security concern is the ability to execute code from a semi-trusted
environment without having to change the default security policy. ASP.NET Web
Services client proxies work in these environments, but .NET Remoting proxies do not.
In order to use a .NET Remoting proxy from a semi-trusted environment, you need a
special serialization permission that is not given to code loaded from your intranet or the
Internet by default. If you want to use a .NET Remoting client from within a semi-trusted
environment, you have to alter the default security policy for code loaded from those
zones. In situations where you are connecting to systems from clients running in a
sandbox—like a downloaded Windows Forms application, for instance—ASP.NET Web
Services are a simpler choice because security policy changes are not required.
Conceptually, what is the difference between early-binding and late-binding?
Early binding – Binding at Compile Time
Late Binding – Binding at Run Time
Early binding implies that the class of the called object is known at compile-time; late-
binding implies that the class is not known until run-time, such as a call through an
interface or via Reflection.
Early binding is the preferred method. It is the best performer because your application
binds directly to the address of the function being called and there is no extra overhead in
doing a run-time lookup. In terms of overall execution speed, it is at least twice as fast as
late binding.
Early binding also provides type safety. When you have a reference set to the
component's type library, Visual Basic provides IntelliSense support to help you code
each function correctly. Visual Basic also warns you if the data type of a parameter or
return value is incorrect, saving a lot of time when writing and debugging code.
Late binding is still useful in situations where the exact interface of an object is not
known at design-time. If your application seeks to talk with multiple unknown servers or
needs to invoke functions by name (using the Visual Basic 6.0 CallByName function for
example) then you need to use late binding. Late binding is also useful to work around
compatibility problems between multiple versions of a component that has improperly
modified or adapted its interface between versions.
What is an Asssembly Qualified Name? Is it a filename? How is it different?
An assembly qualified name isn't the filename of the assembly; it's the internal name of
the assembly combined with the assembly version, culture, and public key, thus making it
unique.
e.g. (""System.Xml.XmlDocument, System.Xml, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"")
How is a strongly-named assembly different from one that isn’t strongly-named?
Strong names are used to enable the stricter naming requirements associated with shared
assemblies. These strong names are created by a .NET utility – sn.exe
Strong names have three goals:
· Name uniqueness. Shared assemblies must have names that are globally unique.
· Prevent name spoofing. Developers don't want someone else releasing a subsequent
version of one of your assemblies and falsely claim it came from you, either by accident
or intentionally.
· Provide identity on reference. When resolving a reference to an assembly, strong names
are used to guarantee the assembly that is loaded came from the expected publisher.
Strong names are implemented using standard public key cryptography. In general, the
process works as follows: The author of an assembly generates a key pair (or uses an
existing one), signs the file containing the manifest with the private key, and makes the
public key available to callers. When references are made to the assembly, the caller
records the public key corresponding to the private key used to generate the strong name.
Weak named assemblies are not suitable to be added in GAC and shared. It is essential
for an assembly to be strong named.
Strong naming prevents tampering and enables assemblies to be placed in the GAC
alongside other assemblies of the same name.
How does the generational garbage collector in the .NET CLR manage object lifetime?
What is non-deterministic finalization?
The hugely simplistic version is that every time it garbage-collects, it starts by assuming
everything to be garbage, then goes through and builds a list of everything reachable.
Those become not-garbage, everything else doesn't, and gets thrown away. What makes it
generational is that every time an object goes through this process and survives, it is
noted as being a member of an older generation (up to 2, right now). When the garbage-
collector is trying to free memory, it starts with the lowest generation (0) and only works
up to higher ones if it can't free up enough space, on the grounds that shorter-lived
objects are more likely to have been freed than longer-lived ones.
Non-deterministic finalization implies that the destructor (if any) of an object will not
necessarily be run (nor its memory cleaned up, but that's a relatively minor issue)
immediately upon its going out of scope. Instead, it will wait until first the garbage
collector gets around to finding it, and then the finalisation queue empties down to it; and
if the process ends before this happens, it may not be finalised at all. (Although the
operating system will usually clean up any process-external resources left open - note the
usually there, especially as the exceptions tend to hurt a lot.)
What is the difference between Finalize() and Dispose()?
Dispose() is called by the user of an object to indicate that he is finished with it, enabling
that object to release any unmanaged resources it holds. Finalize() is called by the run-
time to allow an object which has not had Dispose() called on it to do the same. However,
Dispose() operates determinalistically, whereas there is no guarantee that Finalize() will
be called immediately when an object goes out of scope - or indeed at all, if the program
ends before that object is GCed - and as such Dispose() is generally preferred.
How is the using() pattern useful? What is IDisposable? How does it support
deterministic finalization?
The using() pattern is useful because it ensures that Dispose() will always be called when
a disposable object (defined as one that implements IDisposable, and thus the Dispose()
method) goes out of scope, even if it does so by an exception being thrown, and thus that
resources are always released.
What does this useful command line do? tasklist /m "mscor*"
Lists all the applications and associated tasks/process currently running on the system
with a module whose name begins "mscor" loaded into them; which in nearly all cases
means "all the .NET processes".
What’s wrong with a line like this? DateTime.Parse(myString);
Therez nothing wrong with this declaration.Converts the specified string representation
of a date and time to its DateTime equivalent.But If the string is not a valid DateTime,It
throws an exception.
What are PDBs? Where must they be located for debugging to work?
A program database (PDB) files holds debugging and project state information that
allows incremental linking of debug configuration of your program.There are several
different types of symbolic debugging information. The default type for Microsoft
compiler is the so-called PDB file. The compiler setting for creating this file is /Zi, or /ZI
for C/C++(which creates a PDB file with additional information that enables a feature
called ""Edit and Continue"") or a Visual Basic/C#/JScript .NET program with /debug.
A PDB file is a separate file, placed by default in the Debug project subdirectory, that has
the same name as the executable file with the extension .pdb. Note that the Visual C++
compiler by default creates an additional PDB file called VC60.pdb for VisulaC++6.0
and VC70.PDB file for VisulaC++7.0. The compiler creates this file during compilation
of the source code, when the compiler isn't aware of the final name of the executable. The
linker can merge this temporary PDB file into the main one if you tell it to, but it won't do
it by default. The PDB file can be useful to display the detailed stack trace with source
files and line numbers.
What is FullTrust? Do GAC’ed assemblies have FullTrust?
Before the .NET Framework existed, Windows had two levels of trust for downloaded
code. This old model was a binary trust model. You only had two choices: Full Trust, and
No Trust. The code could either do anything you could do, or it wouldn't run at all.
Sealed: It can be applied on a class and methods. It stops the type from further derivation
i.e no one can derive class
from a sealed class,ie A sealed class cannot be inherited.A sealed class cannot be a
abstract class.A compile time error is thrown if you try to specify sealed class as a base
class.
When an instance method declaration includes a sealed modifier, that method is said to be
a sealed method. If an instance method declaration includes the sealed modifier, it must
also include the override modifier. Use of the sealed modifier prevents a derived class
from further overriding the method For Egs: sealed override public void Sample()
{ Console.WriteLine("Sealed Method"); }
Virtual & Override: Virtual & Override keywords provides runtime polymorphism. A
base class can make some of its methods
as virtual which allows the derived class a chance to override the base class
implementation by using override keyword.
class Rectangle:Shape
{
public override void Display()
{
Console.WriteLine("Derived");
}
}
Explain the importance and use of each, Version, Culture and PublicKeyToken for an
assembly.
This three alongwith name of the assembly provide a strong name or fully qualified name
to the assembly. When a assebly is referenced with all three.
PublicKeyToken: Each assembly can have a public key embedded in its manifest that
identifies the developer. This ensures that once the assembly ships, no one can modify the
code or other resources contained in the assembly.
Public: Allows class, methods, fields to be accessible from anywhere i.e. within and
outside an assembly.
Private: When applied to field and method allows to be accessible within a class.
Protected: Similar to private but can be accessed by members of derived class also.
Internal: They are public within the assembly i.e. they can be accessed by anyone within
an assembly but outside assembly they are not visible.
What is the difference between typeof(foo) and myFoo.GetType()?
Typeof is operator which applied to a object returns System.Type object. Typeof cannot
be overloaded white GetType has lot of overloads.GetType is a method which also
returns System.Type of an object. GetType is used to get the runtime type of the object.
/*
This code produces the following output.
mybase: Type is MyBaseClass
myDerived: Type is MyDerivedClass
object o = myDerived: Type is MyDerivedClass
MyBaseClass b = myDerived: Type is MyDerivedClass
*/
Can "this" be used within a static method?
No 'This' cannot be used in a static method. As only static variables/methods can be used
in a static method.
Next>>
Explain what a diffgram is and its usage ?
A DiffGram is an XML format that is used to identify current and original versions of
data elements. The DataSet uses the DiffGram format to load and persist its contents, and
to serialize its contents for transport across a network connection. When a DataSet is
written as a DiffGram, it populates the DiffGram with all the necessary information to
accurately recreate the contents, though not the schema, of the DataSet, including column
values from both the Original and Current row versions, row error information, and row
order.
When sending and retrieving a DataSet from an XML Web service, the DiffGram format
is implicitly used. Additionally, when loading the contents of a DataSet from XML using
the ReadXml method, or when writing the contents of a DataSet in XML using the
WriteXml method, you can select that the contents be read or written as a DiffGram.
The DiffGram format is divided into three sections: the current data, the original (or
"before") data, and an errors section, as shown in the following example.
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
The name of this element, DataInstance, is used for explanation purposes in this
documentation. A DataInstance element represents a DataSet or a row of a DataTable.
Instead of DataInstance, the element would contain the name of the DataSet or
DataTable. This block of the DiffGram format contains the current data, whether it has
been modified or not. An element, or row, that has been modified is identified with the
diffgr:hasChanges annotation.
This block of the DiffGram format contains the original version of a row. Elements in this
block are matched to elements in the DataInstance block using the diffgr:id annotation.
This block of the DiffGram format contains error information for a particular row in the
DataInstance block. Elements in this block are matched to elements in the DataInstance
block using the diffgr:id annotation.
Which method do you invoke on the DataAdapter control to load your generated dataset
with data?
You have to use the Fill method of the DataAdapter control and pass the dataset object as
an argument to load the generated data.
Can you edit data in the Repeater control?
NO.
Which are the different IsolationLevels ?
Following are the various IsolationLevels:
· Serialized Data read by a current transaction cannot be changed by another transaction
until the current transaction finishes. No new data can be inserted that would affect the
current transaction. This is the safest isolation level and is the default.
5. Firewalls and DCOM and Remoting: Those who have worked with DCOM know that
how difficult it is to marshal a DCOM component across a router. People generally came
up with workarounds to solve this issue. ADO.NET DataSet uses Remoting, through
which a DataSet / DataTable component can be serialized into XML, sent across the wire
to a new AppDomain, and then Desterilized back to a fully functional DataSet. As the
DataSet is completely disconnected, and it has no dependency, we lose absolutely nothing
by serializing and transferring it through Remoting.
I have split the topic of concurrency violation management into two parts. Next time I
will focus on what to do when multiple rows could cause concurrency violations. I will
also discuss how the DataViewRowState enumerators can be used to show what changes
have been made to a DataSet.
How you will set the datarelation between two columns?
ADO.NET provides DataRelation object to set relation between two columns.It helps to
enforce the following constraints,a unique constraint, which guarantees that a column in
the table contains no duplicates and a foreign-key constraint,which can be used to
maintain referential integrity.A unique constraint is implemented either by simply setting
the Unique property of a data column to true, or by adding an instance of the
UniqueConstraint class to the DataRelation object's ParentKeyConstraint. As part of the
foreign-key constraint, you can specify referential integrity rules that are applied at three
points,when a parent record is updated,when a parent record is deleted and when a
change is accepted or rejected.
C# and VB.NET
Next>>
Explain the differences between Server-side and Client-side code?
Server side code executes on the server.For this to occur page has to be submitted or
posted back.Events fired by the controls are executed on the server.Client side code
executes in the browser of the client without submitting the page.
e.g. In ASP.NET for webcontrols like asp:button the click event of the button is executed
on the server hence the event handler for the same in a part of the code-behind (server-
side code). Along the server-side code events one can also attach client side events which
are executed in the clients browser i.e. javascript events.
How does VB.NET/C# achieve polymorphism?
Polymorphism is also achieved through interfaces. Like abstract classes, interfaces also
describe the methods that a class needs to implement. The difference between abstract
classes and interfaces is that abstract classes always act as a base class of the related
classes in the class hierarchy. For example, consider a hierarchy-car and truck classes
derived from four-wheeler class; the classes two-wheeler and four-wheeler derived from
an abstract class vehicle. So, the class 'vehicle' is the base class in the class hierarchy. On
the other hand dissimilar classes can implement one interface. For example, there is an
interface that compares two objects. This interface can be implemented by the classes like
box, person and string, which are unrelated to each other.
C# allows multiple interface inheritance. It means that a class can implement more than
one interface. The methods declared in an interface are implicitly abstract. If a class
implements an interface, it becomes mandatory for the class to override all the methods
declared in the interface, otherwise the derived class would become abstract.
Can you explain what inheritance is and an example of when you might use it?
The savingaccount class has two data members-accno that stores account number, and
trans that keeps track of the number of transactions. We can create an object of
savingaccount class as shown below.
savingaccount s = new savingaccount ( "Amar", 5600.00f ) ;
From the constructor of savingaccount class we have called the two-argument constructor
of the account class using the base keyword and passed the name and balance to this
constructor using which the data member's name and balance are initialised.
We can write our own definition of a method that already exists in a base class. This is
called method overriding. We have overridden the deposit( ) and withdraw( ) methods in
the savingaccount class so that we can make sure that each account maintains a minimum
balance of Rs. 500 and the total number of transactions do not exceed 10. From these
methods we have called the base class's methods to update the balance using the base
keyword. We have also overridden the display( ) method to display additional
information, i.e. account number.
Working of currentaccount class is more or less similar to that of savingaccount class.
Using the derived class's object, if we call a method that is not overridden in the derived
class, the base class method gets executed. Using derived class's object we can call base
class's methods, but the reverse is not allowed.
Unlike C++, C# does not support multiple inheritance. So, in C# every class has exactly
one base class.
Now, suppose we declare reference to the base class and store in it the address of instance
of derived class as shown below.
account a1 = new savingaccount ( "Amar", 5600.00f ) ;
account a2 = new currentaccount ( "MyCompany Pvt. Ltd.", 126000.00f) ;
Such a situation arises when we have to decide at run-time a method of which class in a
class hierarchy should get called. Using a1 and a2, suppose we call the method display( ),
ideally the method of derived class should get called. But it is the method of base class
that gets called. This is because the compiler considers the type of reference (account in
this case) and resolves the method call. So, to call the proper method we must make a
small change in our program. We must use the virtual keyword while defining the
methods in base class as shown below.
public virtual void display( ) { }
We must declare the methods as virtual if they are going to be overridden in derived
class. To override a virtual method in derived classes we must use the override keyword
as given below.
public override void display( ) { }
Now it is ensured that when we call the methods using upcasted reference, it is the
derived class's method that would get called. Actually, when we declare a virtual method,
while calling it, the compiler considers the contents of the reference rather than its type.
If we don't want to override base class's virtual method, we can declare it with new
modifier in derived class. The new modifier indicates that the method is new to this class
and is not an override of a base class method.
How would you implement inheritance using VB.NET/C#?
When we set out to implement a class using inheritance, we must first start with an
existing class from which we will derive our new subclass. This existing class, or base
class, may be part of the .NET system class library framework, it may be part of some
other application or .NET assembly, or we may create it as part of our existing
application. Once we have a base class, we can then implement one or more subclasses
based on that base class. Each of our subclasses will automatically have all of the
methods, properties, and events of that base class ? including the implementation behind
each method, property, and event. Our subclass can add new methods, properties, and
events of its own - extending the original interface with new functionality. Additionally, a
subclass can replace the methods and properties of the base class with its own new
implementation - effectively overriding the original behavior and replacing it with new
behaviors. Essentially inheritance is a way of merging functionality from an existing class
into our new subclass. Inheritance also defines rules for how these methods, properties,
and events can be merged. In VB.NET we can use implements keyword for inheritance,
while in C# we can use the sign ( :: ) between subclass and baseclass.
How is a property designated as read-only?
In VB.NET:
Private mPropertyName as DataType
Public ReadOnly Property PropertyName() As DataType
Get Return mPropertyName
End Get
End Property
In C#
Private DataType mPropertyName;
public returntype PropertyName
{
get{
//property implementation goes here
return mPropertyName;
}
// Do not write the set implementation
}
Why is the XML InfoSet specification different from the Xml DOM? What does the
InfoSet attempt to solve?
"The XML Information Set (Infoset) defines a data model for XML. The Infoset
describes the abstract representation of an XML Document. Infoset is the generalized
representation of the XML Document, which is primarily meant to act as a set of
definitions used by XML technologies to formally describe what parts of an XML
document they operate upon.
The Document Object Model (DOM) is one technology for representing an XML
Document in memory and to programmatically read, modify and manipulate a xml
document.
Infoset helps defining generalized standards on how to use XML that is not dependent or
tied to a particular XML specification or API. The Infoset tells us what part of XML
Document should be considered as significant information.
Contrast DTDs versus XSDs. What are their similarities and differences? Which is
preferred and why?
Document Type Definition (DTD) describes a model or set of rules for an XML
document. XML Schema Definition (XSD) also describes the structure of an XML
document but XSDs are much more powerful.
The disadvantage with the Document Type Definition is it doesn’t support data types
beyond the basic 10 primitive types. It cannot properly define the type of data contained
by the tag.
An Xml Schema provides an Object Oriented approach to defining the format of an xml
document. The Xml schema support most basic programming types like integer, byte,
string, float etc., We can also define complex types of our own which can be used to
define a xml document.
Xml Schemas are always preferred over DTDs as a document can be more precisely
defined using the XML Schemas because of its rich support for data representation.
Speaking of Boolean data types, what's different between C# and C/C++?
There's no conversion between 0 and false, as well as any other number and true, like in
C/C++.
How do you convert a string into an integer in .NET?
Int32.Parse(string)
Can you declare a C++ type destructor in C# like ~MyClass()?
Yes, but what's the point, since it will call Finalize(), and Finalize() has no guarantees
when the memory will be cleaned up, plus, it introduces additional load on the garbage
collector.
What's different about namespace declaration when comparing that to package
declaration in Java?
No semicolon.
What's the difference between const and readonly?
The readonly keyword is different from the const keyword. A const field can only be
initialized at the declaration of the field. A readonly field can be initialized either at the
declaration or in a constructor. Therefore, readonly fields can have different values
depending on the constructor used. Also, while a const field is a compile-time constant,
the readonly field can be used for runtime constants as in the following example:
public static readonly uint l1 = (uint) DateTime.Now.Ticks;
Next>>
Can you give an example of when it would be appropriate to use a web service as
opposed to non-serviced .NET component
Web service is one of main component in Service Oriented Architecture. You could use
web services when your clients and servers are running on different networks and also
different platforms. This provides a loosely coupled system. And also if the client is
behind the firewall it would be easy to use web service since it runs on port 80 (by
default) instead of having some thing else in Service Oriented Architecture applications.
What is the standard you use to wrap up a call to a Web service
"SOAP.
"
What is the transport protocol you use to call a Web service SOAP
HTTP with SOAP
True or False: To test a Web service you must create a windows application or Web
application to consume this service?
False.
2.Synchronous Call
Application has to wait until execution has completed.
xmlns="urn:schemas-dynamicdiscovery:disco.2000-03-17">
How does dynamic discovery work?
ASP.NET maps the file name extension VSDISCO to an HTTP handler that scans the
host directory and subdirectories for ASMX and DISCO files and returns a dynamically
generated DISCO document. A client who requests a VSDISCO file gets back what
appears to be a static DISCO document.
Note that VSDISCO files are disabled in the release version of ASP.NET. You can
reenable them by uncommenting the line in the section of Machine.config that maps
*.vsdisco to System.Web.Services.Discovery.DiscoveryRequestHandler and granting the
ASPNET user account permission to read the IIS metabase. However, Microsoft is
actively discouraging the use of VSDISCO files because they could represent a threat to
Web server security.
Setting AspCompat to true does two things. First, it makes intrinsic ASP objects available
to the COM components by placing unmanaged wrappers around the equivalent
ASP.NET objects. Second, it improves the performance of calls that the page places to
apartment- threaded COM objects by ensuring that the page (actually, the thread that
processes the request for the page) and the COM objects it creates share an apartment.
AspCompat="true" forces ASP.NET request threads into single-threaded apartments
(STAs). If those threads create COM objects marked ThreadingModel=Apartment, then
the objects are created in the same STAs as the threads that created them. Without
AspCompat="true," request threads run in a multithreaded apartment (MTA) and each
call to an STA-based COM object incurs a performance hit when it's marshaled across
apartment boundaries.
Do not set AspCompat to true if your page uses no COM objects or if it uses COM
objects that don't access ASP intrinsic objects and that are registered
ThreadingModel=Free or ThreadingModel=Both.
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://tempuri.org/",
IsNullable=false)]
public class AuthToken : SoapHeader { public string Token; }}
In this case, when you create an instance of the proxy in your main application file, you'll
also create an instance of the AuthToken class and assign the string:
Service1 objSvc = new Service1();
processingobjSvc.AuthTokenValue = new AuthToken();
objSvc.AuthTokenValue.Token = ;
Web Servicestring strResult = objSvc.MyBillableWebMethod();
What is WSDL?
WSDL is the Web Service Description Language, and it is implemented as a specific
XML vocabulary. While it's very much more complex than what can be described here,
there are two important aspects to WSDL with which you should be aware. First, WSDL
provides instructions to consumers of Web Services to describe the layout and contents of
the SOAP packets the Web Service intends to issue. It's an interface description
document, of sorts. And second, it isn't intended that you read and interpret the WSDL.
Rather, WSDL should be processed by machine, typically to generate proxy source code
(.NET) or create dynamic proxies on the fly (the SOAP Toolkit or Web Service
Behavior).
What is a Windows Service and how does its lifecycle differ from a "standard" EXE?
Windows service is a application that runs in the background. It is equivalent to a NT
service.
The executable created is not a Windows application, and hence you can't just click and
run it . it needs to be installed as a service, VB.Net has a facility where we can add an
installer to our program and then use a utility to install the service. Where as this is not
the case with standard exe
Note The tlist.exe file is typically located in the following directory: C:Program
FilesDebugging Tools for Windows
d. At the command prompt, type tlist to list the image names and the process IDs of all
processes that are currently running on your computer.
Note Make a note of the process ID of the process that hosts the service that you want to
debug.
2 At a command prompt, change the directory path to reflect the location of the
windbg.exe file on your computer.
Note If a command prompt is not open, follow steps a and b of Method 1. The
windbg.exe file is typically located in the following directory: C:Program
FilesDebugging Tools for Windows.
3 At the command prompt, type windbg –p ProcessID to attach the WinDbg debugger to
the process that hosts the service that you want to debug.
Note ProcessID is a placeholder for the process ID of the process that hosts the service
that you want to debug.
Use the image name of the process that hosts the service that you want to debug
You can use this method only if there is exactly one running instance of the process that
hosts the service that you want to run. To do this, follow these steps:
1 Click Start, and then click Run. The Run dialog box appears.
2 In the Open box, type cmd, and then click OK to open a command prompt.
3 At the command prompt, change the directory path to reflect the location of the
windbg.exe file on your computer.
Note The windbg.exe file is typically located in the following directory: C:Program
FilesDebugging Tools for Windows.
4 At the command prompt, type windbg –pn ImageName to attach the WinDbg debugger
to the process that hosts the service that you want to debug.
NoteImageName is a placeholder for the image name of the process that hosts the service
that you want to debug. The "-pn" command-line option specifies that the ImageName
command-line argument is the image name of a process.
back to the top
Start the WinDbg debugger and attach to the process that hosts the service that you want
to debug
Note The windbg.exe file is typically located in the following directory: C:Program
FilesDebugging Tools for Windows
3 Run the windbg.exe file to start the WinDbg debugger.
4 On the File menu, click Attach to a Process to display the Attach to Process dialog box.
5 Click to select the node that corresponds to the process that hosts the service that you
want to debug, and then click OK.
6 In the dialog box that appears, click Yes to save base workspace information. Notice
that you can now debug the disassembled code of your service.
Configure a service to start with the WinDbg debugger attached
You can use this method to debug services if you want to troubleshoot service-startup-
related problems.
1 Configure the "Image File Execution" options. To do this, use one of the following
methods:
• Method 1: Use the Global Flags Editor (gflags.exe)
a. Start Windows Explorer.
b. Locate the gflags.exe file on your computer.
Note The gflags.exe file is typically located in the following directory: C:Program
FilesDebugging Tools for Windows.
c. Run the gflags.exe file to start the Global Flags Editor.
d. In the Image File Name text box, type the image name of the process that hosts the
service that you want to debug. For example, if you want to debug a service that is hosted
by a process that has MyService.exe as the image name, type MyService.exe.
e. Under Destination, click to select the Image File Options option.
f. Under Image Debugger Options, click to select the Debugger check box.
g. In the Debugger text box, type the full path of the debugger that you want to use. For
example, if you want to use the WinDbg debugger to debug a service, you can type a full
path that is similar to the following: C:Program FilesDebugging Tools for
Windowswindbg.exe
h. Click Apply, and then click OK to quit the Global Flags Editor.
• Method 2: Use Registry Editor
a. Click Start, and then click Run. The Run dialog box appears.
b. In the Open box, type regedit, and then click OK to start Registry Editor.
c. Warning If you use Registry Editor incorrectly, you may cause serious problems that
may require you to reinstall your operating system. Microsoft cannot guarantee that you
can solve problems that result from using Registry Editor incorrectly. Use Registry Editor
at your own risk.
In Registry Editor, locate, and then right-click the following registry subkey:
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage
File Execution Options
d. Point to New, and then click Key. In the left pane of Registry Editor, notice that New
Key #1 (the name of a new registry subkey) is selected for editing.
e. Type ImageName to replace New Key #1, and then press ENTER.
Note ImageName is a placeholder for the image name of the process that hosts the
service that you want to debug. For example, if you want to debug a service that is hosted
by a process that has MyService.exe as the image name, type MyService.exe.
f. Right-click the registry subkey that you created in step e.
g. Point to New, and then click String Value. In the right pane of Registry Editor, notice
that New Value #1, the name of a new registry entry, is selected for editing.
h. Replace New Value #1 with Debugger, and then press ENTER.
i. Right-click the Debugger registry entry that you created in step h, and then click
Modify. The Edit String dialog box appears.
j. In the Value data text box, type DebuggerPath, and then click OK.
Note DebuggerPath is a placeholder for the full path of the debugger that you want to
use. For example, if you want to use the WinDbg debugger to debug a service, you can
type a full path that is similar to the following: C:Program FilesDebugging Tools for
Windowswindbg.exe
2 For the debugger window to appear on your desktop, and to interact with the debugger,
make your service interactive. If you do not make your service interactive, the debugger
will start but you cannot see it and you cannot issue commands. To make your service
interactive, use one of the following methods:
• Method 1: Use the Services console
a. Click Start, and then point to Programs.
b. On the Programs menu, point to Administrative Tools, and then click Services. The
Services console appears.
c. In the right pane of the Services console, right-click ServiceName, and then click
Properties.
Note ServiceName is a placeholder for the name of the service that you want to debug.
d. On the Log On tab, click to select the Allow service to interact with desktop check box
under Local System account, and then click OK.
• Method 2: Use Registry Editor
a. In Registry Editor, locate, and then click the following registry subkey:
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesServiceName
Note Replace ServiceName with the name of the service that you want to debug. For
example, if you want to debug a service named MyService, locate and then click the
following registry key:
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesMyService
b. Under the Name field in the right pane of Registry Editor, right-click Type, and then
click Modify. The Edit DWORD Value dialog box appears.
c. Change the text in the Value data text box to the result of the binary OR operation with
the binary value of the current text and the binary value, 0x00000100, as the two
operands. The binary value, 0x00000100, corresponds to the
SERVICE_INTERACTIVE_PROCESS constant that is defined in the WinNT.h header
file on your computer. This constant specifies that a service is interactive in nature.
3 When a service starts, the service communicates to the Service Control Manager how
long the service must have to start (the time-out period for the service). If the Service
Control Manager does not receive a "service started" notice from the service within this
time-out period, the Service Control Manager terminates the process that hosts the
service. This time-out period is typically less than 30 seconds. If you do not adjust this
time-out period, the Service Control Manager ends the process and the attached debugger
while you are trying to debug. To adjust this time-out period, follow these steps:
a. In Registry Editor, locate, and then right-click the following registry subkey:
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControl
b. Point to New, and then click DWORD Value. In the right pane of Registry Editor,
notice that New Value #1 (the name of a new registry entry) is selected for editing.
c. Type ServicesPipeTimeout to replace New Value #1, and then press ENTER.
d. Right-click the ServicesPipeTimeout registry entry that you created in step c, and then
click Modify. The Edit DWORD Value dialog box appears.
e. In the Value data text box, type TimeoutPeriod, and then click OK
Note TimeoutPeriod is a placeholder for the value of the time-out period (in milliseconds)
that you want to set for the service. For example, if you want to set the time-out period to
24 hours (86400000 milliseconds), type 86400000.
f. Restart the computer. You must restart the computer for Service Control Manager to
apply this change.
4 Start your Windows service. To do this, follow these steps:
a. Click Start, and then point to Programs.
b. On the Programs menu, point to Administrative Tools, and then click Services. The
Services console appears.
c. In the right pane of the Services console, right-click ServiceName, and then click Start.
Note ServiceName is a placeholder for the name of the service that you want to debug.
Can we use com Components in .net?.How ?.can we use .net components in vb?.Explain
how ?
COM components have different internal architecture from .NET components hence they
are not innately compatible. However .NET framework supports invocation of
unmanaged code from managed code (and vice-versa) through COM/.NET
interoperability. .NET application communicates with a COM component through a
managed wrapper of the component called Runtime Callable Wrapper (RCW); it acts as
managed proxy to the unmanaged COM component. When a method call is made to
COM object, it goes onto RCW and not the object itself. RCW manages the lifetime
management of the COM component. Implementation Steps -
Create Runtime Callable Wrapper out of COM component. Reference the metadata
assembly Dll in the project and use its methods & properties RCW can be created using
Type Library Importer utility or through VS.NET. Using VS.NET, add reference through
COM tab to select the desired DLL. VS.NET automatically generates metadata assembly
putting the classes provided by that component into a namespace with the same name as
COM dll (XYZRCW.dll)
.NET components can be invoked by unmanaged code through COM Callable Wrapper
(CCW) in COM/.NET interop. The unmanaged code will talk to this proxy, which
translates call to managed environment. We can use COM components in .NET through
COM/.NET interoperability. When managed code calls an unmanaged component, behind
the scene, .NET creates proxy called COM Callable wrapper (CCW), which accepts
commands from a COM client, and forwards it to .NET component. There are two
prerequisites to creating .NET component, to be used in unmanaged code:
1. .NET class should be implement its functionality through interface. First define
interface in code, then have the class to imlpement it. This way, it prevents breaking of
COM client, if/when .NET component changes.
2.Secondly, .NET class, which is to be visible to COM clients must be declared public.
The tools that create the CCW only define types based
on public classes. The same rule applies to methods, properties, and events that will be
used by COM clients.
Implementation Steps -
1. Generate type library of .NET component, using TLBExporter utility. A type library is
the COM equivalent of the metadata contained within
a .NET assembly. Type libraries are generally contained in files with the extension .tlb. A
type library contains the necessary information to allow a COM client to determine which
classes are located in a particular server, as well as the methods, properties, and events
supported by those classes.
2. Secondly, use Assembly Registration tool (regasm) to create the type library and
register it.
3. Lastly install .NET assembly in GAC, so it is available as shared assembly.
What is Runtime Callable wrapper?.when it will created?.
The common language runtime exposes COM objects through a proxy called the runtime
callable wrapper (RCW). Although the RCW appears to be an ordinary object to .NET
clients, its primary function is to marshal calls between a .NET client and a COM object.
This wrapper turns the COM interfaces exposed by the COM component into .NET-
compatible interfaces. For oleautomation (attribute indicates that an interface is
compatible with Automation) interfaces, the RCW can be generated automatically from a
type library. For non-oleautomation interfaces, it may be necessary to develop a custom
RCW which manually maps the types exposed by the COM interface to .NET-compatible
types.
What is Com Callable wrapper?when it will created?
.NET components are accessed from COM via a COM Callable Wrapper (CCW). This is
similar to a RCW, but works in the opposite direction. Again, if the wrapper cannot be
automatically generated by the .NET development tools, or if the automatic behaviour is
not desirable, a custom CCW can be developed. Also, for COM to 'see' the .NET
component, the .NET component must be registered in the registry.CCWs also manage
the object identity and object lifetime of the managed objects they wrap.
What is a primary interop ?
A primary interop assembly is a collection of types that are deployed, versioned, and
configured as a single unit. However, unlike other managed assemblies, an interop
assembly contains type definitions (not implementation) of types that have already been
defined in COM. These type definitions allow managed applications to bind to the COM
types at compile time and provide information to the common language runtime
about how the types should be marshaled at run time.
What are tlbimp and tlbexp tools used for ?
The Type Library Exporter generates a type library that describes the types defined in a
common language runtime assembly.
The Type Library Importer converts the type definitions found within a COM type library
into equivalent definitions in a common language runtime assembly. The output of
Tlbimp.exe is a binary file (an assembly) that contains runtime metadata for the types
defined within the original type library.
What benefit do you get from using a Primary Interop Assembly (PIA)?
PIAs are important because they provide unique type identity. The PIA distinguishes the
official type definitions from counterfeit definitions provided by other interop assemblies.
Having a single type identity ensures type compatibility between applications that share
the types defined in the PIA. Because the PIA is signed by its publisher and labeled with
the PrimaryInteropAssembly attribute, it can be differentiated from other interop
assemblies that define the same types.
Remoting FAQ's
When would you use .NET Remoting and when Web services?
Use remoting for more efficient exchange of information when you control both ends of
the application. Use Web services for open-protocol-based information exchange when
you are just a client or a server with the other end belonging to someone else.
What is a formatter?
A formatter is an object that is responsible for encoding and serializing data into
messages on one end, and deserializing and decoding messages into data on the other
end.
Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters,
what are the trade-offs?
Binary over TCP is the most effiecient, SOAP over HTTP is the most interoperable.
How can you automatically generate interface for the remotable object in .NET with
Microsoft tools?
Use the Soapsuds tool.
How can objects in two diff. App Doimains communicate with each other?
.Net framework provides various ways to communicate with objects in different app
domains.
First is XML Web Service on internet, its good method because it is built using HTTP
protocol and SOAP formatting.
If the performance is the main concern then go for second option which is .Net remoting
because it gives you the option of using binary encoding and the default TcpChannel,
which offers the best interprocess communication performance
What is the difference between .Net Remoting and Web Services?
Although we can develop an application using both technologies, each of them has its
distinct advantages. Yes you can look at them in terms of performance but you need to
consider your need first. There are many other factors such authentications, authorizing in
process that need to be considered.
Point Remoting Webservices
If your application needs interoperability with other platforms or operating systems No
Yes, Choose Web Services because it is more flexible in that they are support SOAP.
If performance is the main requirement with security You should use the TCP channel
and the binary formatter No
Complex Programming Yes No
State Management Supports a range of state management, depending on what object
lifetime scheme you choose (single call or singleton call). Its stateless service
management (does not inherently correlate multiple calls from the same user)
Transport Protocol It can access through TCP or HTTP channel. It can be access only
through HTTP channel.
WinForms FAQ :
What is the difference between Debug.Write and Trace.Write? When should each be
used?
The Debug.Write call won't be compiled when the DEBUGsymbol is not defined (when
doing a release build). Trace.Write calls will be compiled. Debug.Write is for information
you want only in debug builds, Trace.Write is for when you want it in release build as
well.
Can you write a class without specifying namespace? Which namespace does it belong to
by default??
Yes, you can, then the class belongs to global namespace which has no name. For
commercial products, naturally, you wouldn't want global namespace.
You are designing a GUI application with a windows and several widgets on it. The user
then resizes the app window and sees a lot of grey space, while the widgets stay in place.
What's the problem?
One should use anchoring for correct resizing. Otherwise the default property of a widget
on a form is top-left, so it stays at the same location when resized.
How can you save the desired properties of Windows Forms application?
.config files in .NET are supported through the API to allow storing and retrieving
information. They are nothing more than simple XML files, sort of like what .ini files
were before for Win32 apps.
So how do you retrieve the customized properties of a .NET application from XML
.config file?
Initialize an instance of AppSettingsReader class. Call the GetValue method of
AppSettingsReader class, passing in the name of the property and the type expected.
Assign the result to the appropriate variable.
Why is it not a good idea to insert code into InitializeComponent method when working
with Visual Studio?
The designer will likely through it away, most of the code inside InitializeComponent is
auto-generated.
What's the difference between Move and LocationChanged? Resize and SizeChanged?
Both methods do the same, Move and Resize are the names adopted from VB to ease
migration to C#.
With these events, why wouldn't Microsoft combine Invalidate and Paint, so that you
wouldn't have to tell it to repaint, and then to force it to repaint?
Painting is the slowest thing the OS does, so usually telling it to repaint, but not forcing it
allows for the process to take place in the background.
Before in my VB app I would just load the icons from DLL. How can I load the icons
provided by .NET dynamically?
By using System.Drawing.SystemIcons class, for example
System.Drawing.SystemIcons.Warning produces an Icon with a warning sign in it.
When displaying fonts, what's the difference between pixels, points and ems?
A pixel is the lowest-resolution dot the computer monitor supports. Its size depends on
user's settings and monitor size. A point is always 1/72 of an inch. An em is the number
of pixels that it takes to display the letter M.
INTERVIEWS that are intended to focus on candidate’s competence are almost always
about personality, too.
There are countless books on interviewing professionals what traits to look for, what
questions to ask and how to interpret the answers. But the role of the interviewer is rarely
taken into account. Do interviewers of different personality types make different
decisions on the same people, given the same criteria?
A candidate may tick all the boxes as regards ability, attitude, experience, personality and
values. So why will one interviewer think he or she is perfect for the post when an other
does not? It may be that the personality of the interviewer has to be included in the
equation.
Extroverts usually enjoy interviewing. They are “People’s people”: sociable, eager to be
amused and entertained and often entertaining themselves. They probably talk too much
and listen too little. They may not do their preparation as thoroughly as they should. They
may be impatient and inattentive in along interviews. And, of course, they are attracted to
vivacious (if vacuous) candidates.
Introverts make very different, and often diffident, interviewers. They pause more,
seeming hesitant when they are processing information. They can find the whole process
tiring and intimidating and feel more for those candidates who are similar to themselves.
They usually take the data gathering seriously and see the whole process as a semi-
scientific exercise. In the same way as their extroverted colleagues, though, they probably
tend to favour people of a similar disposition. The trouble is that introverts rarely
volunteer for interviewing assignments.
And what of the “sensitive” (neurotic) interviewers? They are the fragile flowers of the
world. They are prone to stress and generally don’t like people whom they see as
threatening. They can be bitchy and critical, wary and judgmental.
Neurotic interviewers can easily feel threatened by a “mover and shaker”. They worry
about things: the present, the future, their reputation, their security, their ability and so on.
They listen carefully to the candidates answer to questions about work life balance,
diversity, counselling and other issues. If they don’t like what they hear, in response to
salient as well as less relevant questions, their instinct is to push the reject button.
Stable interviewers, like stable employees, are better news. They are less irritable and
moody and better able to weigh the information. They worry less about what might go
wrong and cope well with all the little dramas at interviews. They tend to be calm,
focused and rational.
Agreeable interviewers are warm, trusting and empathise with the candidate. They
understand that interviews can be stressful. They are concerned about making the
interviewee comfortable and relaxed and believe that they get the best out of others by
giving them a chance.
Less agreeable and likable types believe that you understand people by “putting them on
the spot”. They treat the interviews as a Paxman style grilling. They cross-examine –
often pushing candidates to give details of failures that don’t appear on the CV. They are
hard to please, cynical, tough, and world-weary and care little for the interviewee’s
comfort.
The ambition and achievement needs of interviewers are also relevant. Paradoxically,
interviewers with small or grand ambitions may both be intimidated by the obviously
ambitious candidate.Those with low aspirations can feel intimidated by thrusting MBAs
who want to be on the board at 30 and retired at 40 .
The highly ambitious interviewer sees candidates like these as a threat.
What of the interviewers own abilities? How are bright, educated interviewers different
from the less talented? Here’s another paradox: the clever prefer discriminating questions,
the dim prefer “clever” questions. Brighter people tend to have a bigger vocabulary and
think fast. They ask good questions.
Fourth, where possible, try to encourage greater insights in your interviewers. Fifth,
choose-or train-interviewers who are bright, stable and scientious.
Many people see negotiation as a process of each party trying to get the most for what
they have to give. And that's a reasonable way to look at it when you're buying or selling
a car, a computer, or a carpet. It's tempting to look at job negotiations in the same way—
but not advisable.
There are at least four factors that can increase your perceived worth. All of them fit into
the context of networking and interviewing, and all of them can be turned to your
advantage without alienating potential employers.
This is your opportunity to put the work in a broader context than the company may see.
Instead of talking about providing good customer service, for example, you might discuss
retaining valued customers and increasing business activity. If you present some
convincing illustrations, the job might seem worthy of a higher valuation—including,
perhaps, a bonus for achieving objectives that you help define.
You want to demonstrate that what you've learned and achieved in the past, along with
your understanding of the company's needs, makes you more qualified than other
candidates.
4. How Your Discussion of Compensation and Benefits Plays Out
Your attention to the first three factors should already have raised the company's
estimation of your value. The direct discussion—often thought of as the whole of
negotiation—is where you apply your skills at recapitulation, listening, and politely
asserting the value you have established.
You are one of the fortunate few who have not been downsized. However, your current
job isn’t exactly fulfilling. Perhaps it isn’t what you enjoy doing. Maybe the hours are too
long. Perhaps you are having some conflicts with your supervisor. Your salary may not be
on par with average job salaries for the same type and level of position, or not come close
to what you feel you are worth. Whatever the reason(s), you have decided to enter into a
job search.
So you begin your search. You work hard and spend quite a bit of time searching for your
new job. Your efforts are finally rewarded; you have received an offer. Congratulations!
Now comes the hard part. Wait a minute! Did I just say “now comes the hard part”? What
am I talking about? The hard part is finding your new job, isn’t it?
If you are employed while searching for a job, you must inform your present employer
that you have received an offer of employment elsewhere. When you give notice, two
things can happen. Either your present employer will accept, with regret, your decision,
or they will do whatever they can to persuade you to stay.
Your present employer probably spent a lot of time and money hiring and then training
you. They are accustomed to your work habits and abilities, and know you work in
harmony with your peers. You have achieved a number of accomplishments during your
tenure there. To find your replacement at this juncture would be costly.
Your company will most likely attempt to retain you with a counter-offer.
A counter-offer represents the company’s monetary sense of what it’s going to take to
retain you as an employee. It will be fashioned as an offer difficult to refuse, and include
a substantial increase in your compensation along with whatever other perks are deemed
necessary to win you back. What should you do?
The answer can be found in the reason you went looking elsewhere in the first place. If
you accept the counter-offer, you will make more money, but in every other respect, your
situation will remain the same. You need to ask yourself if the added income and perks
will let you overcome whatever it was that caused your lack of fulfillment. Temporarily,
you may be satiated, but you will most likely reach a point where you eventually seek a
new position.
While it may be difficult to turn down a counter-offer, it may be your best option. The
sooner you find yourself in a more fulfilling position, the more creative and happier you
will be.
You are one of the fortunate few who have not been downsized. However, your current
job isn’t exactly fulfilling. Perhaps it isn’t what you enjoy doing. Maybe the hours are too
long. Perhaps you are having some conflicts with your supervisor. Your salary may not be
on par with average job salaries for the same type and level of position, or not come close
to what you feel you are worth. Whatever the reason(s), you have decided to enter into a
job search.
So you begin your search. You work hard and spend quite a bit of time searching for your
new job. Your efforts are finally rewarded; you have received an offer. Congratulations!
Now comes the hard part. Wait a minute! Did I just say “now comes the hard part”? What
am I talking about? The hard part is finding your new job, isn’t it?
If you are employed while searching for a job, you must inform your present employer
that you have received an offer of employment elsewhere. When you give notice, two
things can happen. Either your present employer will accept, with regret, your decision,
or they will do whatever they can to persuade you to stay.
Your present employer probably spent a lot of time and money hiring and then training
you. They are accustomed to your work habits and abilities, and know you work in
harmony with your peers. You have achieved a number of accomplishments during your
tenure there. To find your replacement at this juncture would be costly.
Your company will most likely attempt to retain you with a counter-offer.
A counter-offer represents the company’s monetary sense of what it’s going to take to
retain you as an employee. It will be fashioned as an offer difficult to refuse, and include
a substantial increase in your compensation along with whatever other perks are deemed
necessary to win you back. What should you do?
The answer can be found in the reason you went looking elsewhere in the first place. If
you accept the counter-offer, you will make more money, but in every other respect, your
situation will remain the same. You need to ask yourself if the added income and perks
will let you overcome whatever it was that caused your lack of fulfillment. Temporarily,
you may be satiated, but you will most likely reach a point where you eventually seek a
new position.
While it may be difficult to turn down a counter-offer, it may be your best option. The
sooner you find yourself in a more fulfilling position, the more creative and happier you
will be.
"Why have you changed so frequently?" - How do you answer this question if asked in
the interview? Want to know few smart answers? wait for my next two messages?
With the wisdom of hindsight, I realize that move was a mistake – it took me just six
months to see that I couldn’t make a contribution there. I have been with my current
company a reasonable length of time. So I have broad experience in different
environments. I didn’t just job-hope, I have been following a path to gain this broad
experience. So you see I have more experience than the average person of my years and a
desire to settle down and make it pay off for me and my employer.’
Alternatively, you can say, ‘Now I want to settle down and make my diverse background
pay off in my contributions to my new employer. I have a strong desire to contribute and
am looking for an employer that will keep me challenged. I think this might be the
company to do that – am I right?
Three essential tips to getting through your tech interview and getting the job.
You might think technical-job interviews are no different from interviews for non-tech
jobs, but in fact, they’re special situations with unique potential pitfalls. The three tips
that follow will help you better prepare for them.
1. Be prepared to prove yourself
Your resume will be examined from top to bottom, taken apart and put back together.
Make sure you know what’s on it, and make sure you’re telling the truth. Edith, a
business analyst at a technology-consulting firm, says “It may be tempting to load up
your resume with experience you wish you had, but as soon as the interviewer asks you
for more information, you’ve blown it.”
David, a systems administrator, is adamant that the biggest mistake you can make in a
technical interview is to try to fake your way through it. “If you don’t know something,
don’t talk about it.” And Johanna, a recruiter, warns that interviewers may even ask you
questions that are impossible to answer, just to see if you’ll admit what you don’t know.
The best way to prepare is to review your resume and practice expounding on each and
every part of it. If you say you know Java, can you prove it? If you say you have network
administration experience, can you talk an interviewer through the process of setting up a
mailbox and giving multiple users access to it? Be prepared to answer questions about
how to build a particular application or tackle a specific problem.
The questions themselves, of course, depend on the specific position. But you can be sure
that your interviewer won’t just take your resume at face value.
2. Watch your attitude
Perhaps the worst mistake you can make in a tech interview (besides lying or trying to
convince an interviewer that you know more than you really do) is to be arrogant. Techies
often get a bad rap for lacking social skills, particularly when they’re dealing with non-
techies. Be confident, yes, but don’t try to talk over your interviewer’s head and don’t be
condescending. “You should come across as knowledgeable, relaxed, and sure of yourself
—never arrogant,” says David, the systems administrator.
Don’t be careless in your dress, either. The rule of thumb for dressing for any interview—
wear a conservative version of what you’d wear for the job one level above the one
you’re seeking—applies to tech jobs, too. Sure, you might wear sweatpants and pocket T-
shirts once you’ve got the job, but the interview is not the time to be casual. Emy, a dot
com recruiter, says “It’s not necessary for a man to wear a tie or for a woman to wear a
suit, but it sure does impress me.”
3. Ask well-informed questions.
At the end of each interview, when the interviewer says, “Well, that’s about it. Do you
have any questions?” don’t say no. (That’s a good rule of thumb for any interview, not
just for tech jobs.) But make sure that you ask questions that show you understand the
business, not just the technology.
Johanna, the recruiter, says “Show you’re not only interested in money, but in what the
position has to offer. Ask questions such as ‘what new markets does this company intend
to go after, now that you’ve conquered this market? Looking to the future, how do you
see me fitting into the company?’ Make a big deal out of the big picture. Don’t be too
narrowly focused.”
It’s also a good idea to ask to meet people in other departments. Talk to members of the
company’s marketing or business-development teams to find out how they represent the
company to potential clients. You’ll show that you’re interested in learning how the entire
company functions and that you’re not planning to hole yourself up in the server room all
day.