cookieChoices = {};

Thursday, 21 August 2014

.NET and SQL FAQ

                              Interview questions

 What’s the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.


 Can you store multiple data types in System.Array? No.


 What’s the difference between the System.Array.CopyTo() and System.Array.Clone()? The first one performs a deep copy of the array, the second one is shallow.


 How can you sort the elements of the array in descending order? By calling Sort() and then Reverse() methods.


 What’s the .NET datatype that allows the retrieval of data by a unique key? HashTable.


 What’s class SortedList underneath? A sorted HashTable.


 Will finally block get executed if the exception had not occurred? Yes.


 What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception? A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.


 Can multiple catch blocks be executed? No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.


 Why is it a bad idea to throw your own exceptions? Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.


 What’s a delegate? A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.
 What’s a multicast delegate? It’s a delegate that points to and eventually fires off several methods.


 How’s the DLL Hell problem solved in .NET? Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly. Vb
 What are the ways to deploy an assembly? An MSI installer, a CAB archive, and XCOPY command.


 What’s a satellite assembly? When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.


 What namespaces are necessary to create a localized application? System.Globalization, System.Resources.
 What’s the difference between // comments, /* */ comments and /// comments? Single-line, multi-line and XML documentation comments.
How do you generate documentation from the C# file commented properly with a command-line compiler? Compile it with a /doc switch.
 What’s the difference between <c> and <code> XML documentation tag? Single line code example and multiple-line code example.
 Is XML case-sensitive? Yes, so <Student> and <student> are different elements.
 What debugging tools come with the .NET SDK? CorDBG - command-line debugger, and DbgCLR - graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.
 What does the This window show in the debugger? It points to the object that’s pointed to by this reference. Object’s instance data is shown.
 What does assert() do? In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
 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.
 Why are there five tracing levels in System.Diagnostics.TraceSwitcher? The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.
 Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor.
 How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger.
 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).
 Can you change the value of a variable while debugging a C# application? Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.
 Explain the three services model (three-tier application). Presentation (UI), business (logic and underlying code) and data (from storage or other sources).
 What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it’s a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines.
 What’s the role of the DataReader class in ADO.NET connections? It returns a read-only dataset from the data source when the command is executed.
 What is the wildcard character in SQL? Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’.
 Explain ACID rule of thumb for transactions. Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after).
 What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords).
Which one is trusted and which one is untrusted? Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.
Why would you use untrusted verificaion? Web Services might use it, as well as non-Windows applications.
What does the parameter Initial Catalog define inside Connection String? The database name to connect to.
What’s the data provider name to connect to Access database? Microsoft.Access.
What does Dispose method do with the connection object? Deletes it from the memory.
What is a pre-requisite for connection pooling? Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.
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.
How do you inherit from a class in C#? Place a colon and then the name of the base class. Notice that it’s double colon in C++.
Does C# support multiple inheritance? No, use interfaces instead.
When you inherit a protected class-level variable, who is it available to? Classes in the same namespace.
Are private class-level variables inherited? Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.
Describe the accessibility modifier protected internal. It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).
C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write? Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.
What’s the top .NET class that everything is derived from? System.Object.
How’s method overriding different from overloading? When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.
What does the keyword virtual mean in the method definition? The method can be over-ridden.
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 override private virtual methods? No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.
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.
What’s an abstract class? A class that cannot be instantiated. A concept in C++ known as pure virtual method. A class that must be inherited and have the methods over-ridden. Essentially, it’s a blueprint for a class without any implementation.
When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)? When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.
What’s an interface class? 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 inherit multiple interfaces? Yes, why not.
And if they have conflicting method names? It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.
What’s the difference between an interface and abstract class? In the interface all methods must be abstract, in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes.
How can you overload a method? Different parameter data types, different number of parameters, different order of parameters.
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 difference between System.String and System.StringBuilder classes? System.String is immutable, System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
Is it namespace class or class namespace? The .NET class library is
 How big is the datatype int in .NET? 32 bits.
 How big is the char? 16 bits (Unicode).
How do you initiate a string without escaping each backslash? Put
an @ sign in front of the double-quoted string.
an @ sign in front of the double-quoted string. an @ sign in front of the double-quoted string.What are valid signatures for the Main function?·         public static void Main()
·         public static int Main()
·         public static void Main( string[] args )
·         public static int Main(string[] args )
How do you initialize a two-dimensional array that you don’t know the dimensions of?·         int [, ] myArray; //declaration
·         myArray= new int [5, 8]; //actualinitialization
What’s the access level of the visibility type internal? Current
assembly.
assembly. assembly.What’s the difference between struct and class in C#?·         Structscannot be inherited.
·         Structsare passed by value, not by reference.
·         Structis stored on the stack, not the heap.
Explain encapsulation. The implementation is hidden, the interface
is exposed.
is exposed. is exposed.What data type should you use if you want an 8-bit value that’s signed? sbyte.
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++.
other number and true, like in C/C++. other number and true, like in C/C++.Where are the value-type variables allocated in the computer RAM? Stack.Where do the reference-type variables go in the RAM? The references
go on the stack, while the objects themselves go on the heap.
go on the stack, while the objects themselves go on the heap. go on the stack, while the objects themselves go on the heap.What is the difference between the value-type variables and reference-type variables in terms of garbage collection? The value-type variables are
not garbage-collected, they just fall off the stack when they fall out of
scope, the reference-type objects are picked up by GC when their references
go null.
not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects are picked up by GC when their references go null. not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects are picked up by GC when their references go null.How do you convert a string into an integer in .NET? Int32.Parse(string)
How do you box a primitive data type variable? Assign it to the object,
pass an object.
pass an object. pass an object.Why do you need to box a primitive variable? To pass it by reference.
What’s the difference between Java and .NET garbage collectors?Sun left the implementation of a specific garbage collector up to the JRE developer, so their performance varies widely, depending on whose JRE you’re using. Microsoft standardized on their garbage collection.How do you enforce garbage collection in .NET? System.GC.Collect();
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.
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. 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? You can initialize
readonly variables to some runtime values. Let’s say your program uses
current date and time as one of the values that won’t change. This way
you declare public readonly string DateT = new DateTime().ToString().
readonly variables to some runtime values. Let’s say your program uses current date and time as one of the values that won’t change. This way you declare public readonly string DateT = new DateTime().ToString(). readonly variables to some runtime values. Let’s say your program uses current date and time as one of the values that won’t change. This way you declare public readonly string DateT = new DateTime().ToString().What does \a character do? On most systems, produces a rather annoying
beep.
beep. beep.Can you create enumerated data types in C#? Yes.
What’s different about switch statements in C#? No fall-throughs
allowed.
allowed. allowed.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.Is goto statement supported in C#? How about Java? Gotos are supported
in C#to the fullest. In Java goto is a reserved keyword that provides absolutely
no functionality.
in C#to the fullest. In Java goto is a reserved keyword that provides absolutely no functionality. in C#to the fullest. In Java goto is a reserved keyword that provides absolutely no functionality.Describe the compilation process for .NET code? Source code is compiled
and run in the .NET Framework using a two-stage process. First, source code
is compiled to Microsoft intermediate language (MSIL) code using a .NET Framework-compatible
compiler, such as that for Visual Basic .NET or Visual C#. Second, MSIL code
is compiled to native code.
and run in the .NET Framework using a two-stage process. First, source code is compiled to Microsoft intermediate language (MSIL) code using a .NET Framework-compatible compiler, such as that for Visual Basic .NET or Visual C#. Second, MSIL code is compiled to native code. and run in the .NET Framework using a two-stage process. First, source code is compiled to Microsoft intermediate language (MSIL) code using a .NET Framework-compatible compiler, such as that for Visual Basic .NET or Visual C#. Second, MSIL code is compiled to native code. Name any 2 of the 4 .NET authentification methods. ASP.NET, in conjunction
with Microsoft Internet Information Services (IIS), can authenticate user
credentials such as names and passwords using any of the following authentication
methods:
with Microsoft Internet Information Services (IIS), can authenticate user credentials such as names and passwords using any of the following authentication methods: with Microsoft Internet Information Services (IIS), can authenticate user credentials such as names and passwords using any of the following authentication methods:·         Windows: Basic, digest, or Integrated Windows Authentication (NTLM or
Kerberos).
Kerberos). Kerberos).·         Microsoft Passport authentication
·         Forms authentication
·         Client Certificate authentication
   .NET and COM interop questions <index.php?p=77&more=1&c=1> .NET
Describe the advantages of writing a managed code application instead of unmanaged one. What’s involved in certain piece of code being managed? The advantages include automatic garbage collection, memory management, support for versioning and security. These advantages are provided through .NET FCL and CLR, while with the unmanaged code similar capabilities had to be implemented through third-party libraries or as a part of the application itself.
Are COM objects managed or unmanaged? Since COM objects were written before .NET, apparently they are unmanaged.
So can a COM object talk to a .NET object? Yes, through Runtime Callable Wrapper (RCW) or PInvoke.
How do you generate an RCW from a COM object? Use the Type Library Import utility shipped with SDK. tlbimp COMobject.dll /out:.NETobject.dll or reference the COM library from Visual Studio in your project.
I can’t import the COM object that I have on my machine. Did you write that object? You can only import your own objects. If you need to use a COM component from another developer, you should obtain a Primary Interop Assembly (PIA) from whoever authored the original object.
How do you call unmanaged methods from your .NET code through PInvoke? Supply a DllImport attribute. Declare the methods in your .NET code as static extern. Do not implement the methods as they are implemented in your unmanaged code, you’re just providing declarations for method signatures.
Can you retrieve complex data types like structs from the PInvoke calls? Yes, just make sure you re-declare that struct, so that managed code knows what to do with it.
I want to expose my .NET objects to COM objects. Is that possible? Yes, but few things should be considered first. Classes should implement interfaces explicitly. Managed types must be public. Methods, properties, fields, and events that are exposed to COM must be public. Types must have a public default constructor with no arguments to be activated from COM. Types cannot be abstract.
Can you inherit a COM class in a .NET application? The .NET Framework extends the COM model for reusability by adding implementation inheritance. Managed types can derive directly or indirectly from a COM coclass; more specifically, they can derive from the runtime callable wrapper generated by the runtime. The derived type can expose all the method and properties of the COM object as well as methods and properties implemented in managed code. The resulting object is partly implemented in managed code and partly implemented in unmanaged code.
Suppose I call a COM object from a .NET applicaiton, but COM object throws an error. What happens on the .NET end? COM methods report errors by returning HRESULTs; .NET methods report them by throwing exceptions. The runtime handles the transition between the two. Each exception class in the .NET Framework maps to an HRESULT.
 ASP.NET interview questionsDescribe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process. inetinfo.exe is theMicrosoft IIS server running,
handling ASP.NET requests among other things.When an ASP.NET request is received
(usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes
care of it by passing the request tothe actual worker process aspnet_wp.exe.
handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.
handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.What’s the difference between Response.Write() andResponse.Output.Write()? The latter one allows you to write formattedoutput.What methods are fired during the page load? Init() - when the pageis
instantiated, Load() - when the page is loaded into server memory,PreRender()
- the brief moment before the page is displayed to the user asHTML, Unload()
- when page finishes loading.
instantiated, Load() - when the page is loaded into server memory,PreRender() - the brief moment before the page is displayed to the user asHTML, Unload() - when page finishes loading. instantiated, Load() - when the page is loaded into server memory,PreRender() - the brief moment before the page is displayed to the user asHTML, Unload() - when page finishes loading.Where does the Web page belong in the .NET Framework class hierarchy?System.Web.UI.Page
Where do you store the information about the user’s locale? System.Web.UI.Page.Culture
What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"? CodeBehind is relevant to Visual Studio.NET only.What’s a bubbled event? When you have a complex control, likeDataGrid,
writing an event processing routine for each object (cell, button,row, etc.)
is quite tedious. The controls can bubble up their eventhandlers, allowing
the main DataGrid event handler to take care of itsconstituents.
writing an event processing routine for each object (cell, button,row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of itsconstituents. writing an event processing routine for each object (cell, button,row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of itsconstituents.Suppose you want a certain ASP.NET function executed on MouseOver overa certain button. Where do you add an event handler? It’s the Attributesproperty,
the Add function inside that property. So
the Add function inside that property. So the Add function inside that property. SobtnSubmit.Attributes.Add("onMouseOver","someClientCode();")A simple"Javascript:ClientCode();” in the button control of the .aspx page will attach the handler (javascript function)to the onmouseover event.What data type does the RangeValidator control support? Integer,String
and Date.
and Date. and Date.Where would you use an iHTTPModule, and what are the limitations of any approach you might take in implementing one? One of ASP.NET’s most useful
features is the
extensibilityof the HTTP pipeline <http://www.dotnet247.com/247reference/articles/1/8066.aspx>, the path that data takes between client and server.
You can use them to extend your ASP.NET applications by adding pre- and post-processing
to each HTTP request coming into your application. For example, if you wanted
custom authentication facilities for your application, the best technique
would be to intercept the request when it comes in and process the request
in a custom HTTP module.
features is the
extensibilityof the HTTP pipeline <http://www.dotnet247.com/247reference/articles/1/8066.aspx>, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre- and post-processing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a custom HTTP module. features is theextensibilityof the HTTP pipeline <http://www.dotnet247.com/247reference/articles/1/8066.aspx>, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre- and post-processing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a custom HTTP module.Explain what a diffgram is, and a good use for one? 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.
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. 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. ASP.NET questions, part 1Explain the differences between Server-side and Client-side code? Server side scripting means that all the script will be executed by the server and interpreted as needed. ASP doesn’t have some of the functionality like sockets, uploading, etc. For these you have to make a custom components usually in VB or VC++. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Download time, browser compatibility, and visible code - since JavaScript and VBScript code is included in the HTML page, then anyone can see the code by viewing the page source. Also a possible security hazards for the client computer.
What type of code (server or client) is found in a Code-Behind class? C#
Should validation (did the user enter a real date) occur server-side or client-side? Why? Client-side validation because there is no need to request a server side date when you could obtain a date from the client machine.
What does the "EnableViewState" property do? Why would I want it on or off? Enable ViewState turns on the automatic state management feature that enables server controls to re-populate their values on a round trip without requiring you to write any code. This feature is not free however, since the state of a control is passed to and from the server in a hidden form field. You should be aware of when ViewState is helping you and when it is not. For example, if you are binding a control to data on every round trip (as in the datagrid example in tip #4), then you do not need the control to maintain it’s view state, since you will wipe out any re-populated data in any case. ViewState is enabled for all server controls by default. To disable it, set the EnableViewState property of the control to false.
What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other? 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 accros 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 know the physical loation (page name and query string as well). Context.Items loses the persisitance when nevigate 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.
Can you give an example of when it would be appropriate to use a web service as opposed to a non-serviced .NET component? When to Use Web Services:
·         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.
Let’s say I have an existing application written using Visual Studio (VBInterDevand this application utilizes WindowsCOM+ transaction services. How would you approach migrating this application to .NET?Can you explain the difference between an ADO.NET Dataset and an ADO Recordset? In ADO, the in-memory representation of data is the recordset. In ADO.NET, it is the dataset. There are important differences between them.
·         A recordset looks like a single table. If a recordset is to contain data from multiple database tables, it must use a JOIN query, which assembles the data from the various database tables into a single result table. In contrast, a dataset is a collection of one or more tables. The tables within a dataset are called data tables; specifically, they are DataTable objects. If a dataset contains data from multiple database tables, it will typically contain multiple DataTable objects. That is, each DataTable object typically corresponds to a single database table or view. In this way, a dataset can mimic the structure of the underlying database. A dataset usually also contains relationships. A relationship within a dataset is analogous to a foreign-key relationship in a database —that is, it associates rows of the tables with each other. For example, if a dataset contains a table about investors and another table about each investor’s stock purchases, it could also contain a relationship connecting each row of the investor table with the corresponding rows of the purchase table. Because the dataset can hold multiple, separate tables and maintain information about relationships between them, it can hold much richer data structures than a recordset, including self-relating tables and tables with many-to-many relationships.
·         In ADO you scan sequentially through the rows of the recordset using the ADO MoveNext method. In ADO.NET, rows are represented as collections, so you can loop through a table as you would through any collection, or access particular rows via ordinal or primary key index. DataRelation objects maintain information about master and detail records and provide a method that allows you to get records related to the one you are working with. For example, starting from the row of the Investor table for "Nate Sun," you can navigate to the set of rows of the Purchase table describing his purchases. A cursor is a database element that controls record navigation, the ability to update data, and the visibility of changes made to the database by other users. ADO.NET does not have an inherent cursor object, but instead includes data classes that provide the functionality of a traditional cursor. For example, the functionality of a forward-only, read-only cursor is available in the ADO.NET DataReader object. For more information about cursor functionality, see Data Access Technologies.
·         Minimized Open Connections: In ADO.NET you open connections only long enough to perform a database operation, such as a Select or Update. You can read rows into a dataset and then work with them without staying connected to the data source. In ADO the recordset can provide disconnected access, but ADO is designed primarily for connected access. There is one significant difference between disconnected processing in ADO and ADO.NET. In ADO you communicate with the database by making calls to an OLE DB provider. In ADO.NET you communicate with the database through a data adapter (an OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapter object), which makes calls to an OLE DB provider or the APIs provided by the underlying data source. The important difference is that in ADO.NET the data adapter allows you to control how the changes to the dataset are transmitted to the database — by optimizing for performance, performing data validation checks, or adding any other extra processing. Data adapters, data connections, data commands, and data readers are the components that make up a .NET Framework data provider. Microsoft and third-party providers can make available other .NET Framework data providers that can be integrated into Visual Studio.
·         Sharing Data Between Applications. Transmitting an ADO.NET dataset between applications is much easier than transmitting an ADO disconnected recordset. To transmit an ADO disconnected recordset from one component to another, you use COM marshalling. To transmit data in ADO.NET, you use a dataset, which can transmit an XML stream.
·         Richer data types.COM marshalling provides a limited set of data types — those defined by the COM standard. Because the transmission of datasets in ADO.NET is based on an XML format, there is no restriction on data types. Thus, the components sharing the dataset can use whatever rich set of data types they would ordinarily use.
·         Performance. Transmitting a large ADO recordset or a large ADO.NET dataset can consume network resources; as the amount of data grows, the stress placed on the network also rises. Both ADO and ADO.NET let you minimize which data is transmitted. But ADO.NET offers another performance advantage, in that ADO.NET does not require data-type conversions. ADO, which requires COM marshalling to transmit records sets among components, does require that ADO data types be converted to COM data types.
·         Penetrating Firewalls.A firewall can interfere with two components trying to transmit disconnected ADO recordsets. Remember, firewalls are typically configured to allow HTML text to pass, but to prevent system-level requests (such as COM marshalling) from passing.
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.
If I’m developing an application that must accomodate multiple security levels though secure login and my ASP.NET web appplication is spanned across three web-servers (using round-robbin load balancing) what would be the best approach to maintain login-in state for the users?What are ASP.NET Web Forms? How is this technology different than what is available though ASP? Web Forms are the heart and soul of ASP.NET <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/introwebforms.asp>. Web Forms are the User Interface (UI) elements that give your Web applications their look and feel. Web Forms are similar to Windows Forms in that they provide properties, methods, and events for the controls that are placed onto them. However, these UI elements render themselves in the appropriate markup language required by the request, e.g. HTML. If you use Microsoft Visual Studio .NET, you will also get the familiar drag-and-drop interface used to create your UI for your Web application.
How does VB.NET/C# achieve polymorphism? By using Abstract classes/functions.
Can you explain what inheritance is and an example of when you might use it? Inheritance is a fundamental feature of an object oriented system and it is simply the ability to inherit data and functionality from a parent object. Rather than developing new objects from scratch, new code can be based on the work of other programmers, adding only new features that are needed.
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.
  ASP.NET questions, part 2 ASP.NET interview questions, part 1 <http://www.techinterviews.com/index.php?p=5&more=1&c=1>Whats an assembly? Assemblies are the building blocks of .NET Framework applications <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconassemblies.asp>; 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.
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 <script 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.
Explain what a diffgram is, and a good use for one? 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.
Where would you use an iHTTPModule, and what are the limitations of anyapproach you might take in implementing one? One of ASP.NET’s most useful features is the extensibility of the HTTP pipeline, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre- and post-processing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a custom HTTP module.
What are the disadvantages of viewstate/what are the benefits?Describe session handling in a webfarm, how does it work and what are the limits?How would you get ASP.NET running in Apache web servers - why would you even do this?Whats MSIL, and why should my developers need an appreciation of it if at all?In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events? Every Page object (which your .aspx page is) has nine events, most of which you will not have to worry about in your day to day dealings with ASP.NET. The three that you will deal with the most are: Page_Init, Page_Load, Page_PreRender.
Which method do you invoke on the DataAdapter control to load your generated dataset with data?System.Data.Common.DataAdapter.Fill(System.Data.DataSet);If my DataAdapter is sqlDataAdapter and my DataSet is dsUsers then it is called this way:sqlDataAdapter.Fill(dsUsers);Can you edit data in the Repeater control?Which template must you provide, in order to display data in a Repeater control? ItemTemplate
How can you provide an alternating color scheme in a Repeater control? AlternatingItemTemplate Like the ItemTemplate element, but rendered for every other row (alternating items) in the Repeater control. You can specify a different appearance for the AlternatingItemTemplate element by setting its style properties.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? You must set the DataMember property which Gets or sets the specific table in the DataSource to bind to the control and the DataBind 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 base class do all Web Forms inherit from? System.Web.UI.Page
What method do you use to explicitly kill a user’s session? The Abandon method destroys all the objects stored in a Session object and releases their resources. If you do not call the Abandon method explicitly, the server destroys these objects when the session times out. Syntax: Session.AbandonHow do you turn off cookies for one page in your site? Use the Cookie.Discard Property which 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? ControlToValidate & ErrorMessage properties
What tags do you need to add within the asp:datagrid tags to bind columns manually?How do you create a permanent cookie? Setting the Expires property to MinValue means that the Cookie never expires.
What tag do you use to add a hyperlink column to the DataGrid?What is the standard you use to wrap up a call to a Web service?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. Transport Protocols: It is essential for the acceptance of Web Services that they are based on established Internet infrastructure. This in fact imposes the usage of of the HTTP, SMTP and FTP protocols based on the TCP/IP family of transports. Messaging Protocol: The format of messages exchanged between Web Services clients and Web Services should be vendor neutral and should not carry details about the technology used to implement the service. Also, the message format should allow for extensions and different bindings to specific transport protocols. SOAP and ebXML Transport are specifications which fulfill these requirements. We expect that the W3C XML Protocol Working Group defines a successor standard.
True or False: A Web service can only be written in .NET. False.
What does WSDL stand for? Web Services Description Language
What property do you have to set to tell the grid which page to go to when using the Pager object?Where on the Internet would you look for Web services? UDDI repositaries like uddi.microsoft.com <http://uddi.microsoft.com/>, IBM UDDI node <http://www-3.ibm.com/services/uddi/>, UDDI Registries in Google Directory <http://directory.google.com/Top/Computers/Programming/Internet/Web_Services/UDDI/Registries/>, enthusiast sites like XMethods.net <http://xmethods.net/>.
What tags do you need to add within the asp:datagrid tags to bind columns manually? Column tag and an ASP:databound tag.
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?How is a property designated as read-only? In VB.NET:
Public ReadOnly Property PropertyName As ReturnType              Get                            ‘Your Property Implementation goes in here              End GetEnd Propertyin C#public returntype PropertyName{              get{                              //property implementation goes here              }              // Do not write the set implementation}Which control would you use if you needed to make sure the values in two different controls matched? Use the CompareValidator control to compare the values
of 2 different controls.
of 2 different controls. of 2 different controls.True or False: To test a Web service you must create a windows application or Web application to consume this service? False.
How many classes can a single .NET DLL contain? Unlimited.
  .NET Remoting questions To satisfy popular demand, here’s some basics of the .NET Remoting.What’s a Windows process? It’s an application that’s running and had been allocated memory.
What’s typical about a Windows process in regards to memory allocation? Each process is allocated its own block of available RAM space, no process can access another process’ code or data. If the process crashes, it dies alone without taking the entire OS or a bunch of other applications down.
Why do you call it a process? What’s different between process and application in .NET, not common computer usage, terminology? A process is an instance of a running application. An application is an executable on the hard drive or network. There can be numerous processes launched of the same application (5 copies of Word running), but 1 process can run just 1 application.
What distributed process frameworks outside .NET do you know? Distributed Computing Environment/Remote Procedure Calls (DEC/RPC), Microsoft Distributed Component Object Model (DCOM), Common Object Request Broker Architecture (CORBA), and Java Remote Method Invocation (RMI).
What are possible implementations of distributed applications in .NET? .NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in System.Runtime.Remoting and System.Web.Services.
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’s a proxy of the server object in .NET Remoting? It’s a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as marshaling.
What are remotable objects in .NET Remoting? Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.
What are channels in .NET Remoting? Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred.
What security measures exist for .NET Remoting in System.Runtime.Remoting? None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.
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.
What’s SingleCall activation mode used for? If the server object is instantiated for responding to just one single request, the request should be made in SingleCall mode.
What’s Singleton activation mode? A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by lifetime lease.
How do you define the lease of the object? By implementing ILease interface when writing the class code.
Can you configure a .NET Remoting object via XML file? Yes, via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config.
How can you automatically generate interface for the remotable object in .NET with Microsoft tools? Use the Soapsuds tool.
  .NET Windows services development questions  Explain Windows service. You often need programs that run continuously in the background. For example, an email server is expected to listen continuously on a network port for incoming email messages, a print spooler is expected to listen continuously to print requests, and so on.
What’s the Unix name for a Windows service equivalent? Daemon.
So basically a Windows service application is just another executable? What’s different about a Windows service as compared to a regular application? Windows services must support the interface of the Service Control Manager (SCM). A Windows service must be installed in the Windows service database before it can be launched.
How is development of a Windows service different from a Windows Forms application? A Windows service typically does not have a user interface, it supports a set of commands and can have a GUI that’s built later to allow for easier access to those commands.
How do you give a Windows service specific permissions? Windows service always runs under someone’s identity. Can be System or Administrator account, but if you want to restrict the behavior of a Windows service, the best bet is to create a new user account, assign and deny necessary privileges to that account, and then associate the Windows service with that new account.
Can you share processes between Windows services? Yes.
Where’s Windows service database located? HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
What does SCM do? SCM is Windows Service Control Manager. Its responsibilities are as follows:
·         Accepts requests to install and uninstall Windows services from the Windows service database.
·         To start Windows services either on system startup or requested by the user.
·         To enumerate installed Windows services.
·         To maintain status information for currently running Windows services.
·         To transmits control messages (such as Start, Stop, Pause, and Continue) to available Windows services.
·         To lock/unlock Windows service database.
vice on a box? Use Windows Service Installer, do not go through Add/Remove Programs or MSI file, as you would normally go with applications.
When developing a Windows service for .NET, which namespace do you typically look in for required classes? System.ServiceProcess. The classes are ServiceBase, ServiceProcessInstaller, ServiceInstaller and ServiceController.
How do you handle Start, Pause, Continue and Stop calls from SCM within your application? By implementing OnStart, OnPause, OnContinue and OnStop methods.
Describe the start-up process for a Windows service. Main() is executed to create an instance of a Web service, then Run() to launch it, then OnStart() from within the instance is executed.
I want to write a Windows service that cannot be paused, only started and stopped. How do I accomplish that? Set CanPauseAndContinue attribute to false.
What application do you use to install a Windows service? installutil.exe
I am trying to install my Windows service under NetworkService account, but keep getting an error. The LocalService and NetworkService accounts are only available on Windows XP and Windows Server 2003. These accounts do not exist on Windows 2000 or older operating systems.
How can you see which services are running on a Windows box? Admin Tools -> Computer Management -> Services and Application -> Services. You can also open the Computer Management tool by right-clicking on My Computer and selecting Manage from the popup menu.
How do you start, pause, continue or stop a Windows service off the command line? net start ServiceName, net pause ServiceName and so on. Also sc.exe provides a command-line interface for Windows services. View the OS documentation or proper book chapters on using sc.exe.
Can I write an MMC snap-in for my Windows service? Yes, use classes from the System.Management.Instrumentation namespace.