Friday, November 14, 2008

Error: ASPX page has not been pre-compiled, and cannot be requested

Sometime we find that our web site was working perfectly on our development machine but start displaying error “ Error: ASPX page has not been pre-compiled, and cannot be requested” in many of forums I foud many of our peers are still struggling with same issue.

The simple workaround for that I have found is :

1. If you are using any 3rd party component , remove them from web.config, then using Add Reference add all reference to them again.
2. Instead of setting the WDP's Output Assemblies property to “Merge all outputs to a single assembly” and deploy, use Publish Web Site under the Build menu.
3. Check the "Allow this precompiled site to be updatable" check box in the Publish Web Site options of Visual Studio 05, and deploy.
4. make sure you uploaded all the required assemblies. If anyone is missing upload that manually.

Hope this information will be helpful to my peer community.

Saturday, October 4, 2008

for all game lovers

Hi all,

today while browsing i got interacted with a new site mazefrenzy here i found a realy exciting maze game on the internet, in that you have to click on the tiny red dot and guide it through the white part of the maze. Watch out for the moving objects. If you go off the path you will have to start all over from the beginning. it seems quite simple but is really great.

once you cleared it there is another version of it is also available at mazefrenzy2

try it once, its really good.

good luck.

Monday, September 15, 2008

General network error. Check your network documentation.

There is a lot of people out there complaining about SQL Server returning a General network error while executing a command form ADO.NET version 1.1 or 1.0. Since it is a General network error, it seems to me that there are as many reasons for this error as there are people having it. one fine day I too experienced the same so I googled it but saveral posts in several blogs leads to various solutions like append max pool size = 7500, to your connection string will solve the issue or setting the command timeout to anything but zero totally fixes it.

I tried all of them but still i experienced the same error intermittently. Finally i found that The calling asp.net page creates an ojbect which opens the connection over and over and relies on the destruct method of the database object to do the closing so I am assuming our problem is related to this but I have not been able to reproduce it reliably so I can't be sure this is the cause of the problem.

then i found this microsoft KB article

it says that In the current design, after an application role is enabled on a client connection to SQL Server, you cannot reset the security context of that connection. Therefore, when the user ends the SQL Server session and disconnects from the server, the session is not reusable. However, OLE DB resource pooling returns the closed connection to the pool, and the error occurs when that connection is reused and the client application tries to reset the connection's security context by calling sp_setapprole again.

WORKAROUND

The only available workaround is to disable OLE DB Resource Pooling, which ADO uses by default. You can do this by adding "OLE DB Services = -2" to the ADO Connection string, as shown here: 'For SQLOLEDB provider
'strConnect = "Provider=SQLOLEDB;server=SQL7Web;OLE DB Services = -2;uid=AppUser;pwd=AppUser;initial catalog=northwind"

' For MSDASQL provider
'strConnect = "DSN=SQLNWind;UID=Test;PWD=Test; OLE DB Services= -2"


Pooling can be disabled for the SQL Server .Net Data Provider by adding "Pooling=False" to the connection string.

although that solves my issue but what if the connection pooling is needed ????

Thursday, August 28, 2008

Cross Tab queries , Converting Rows to Columns

Hi all,

While browsing on the net I got a really good article by Jeff Moden on Cross Tab queries , Converting Rows to Columns . Hats off to jeff for this beautiful article. Some part of it that I feel was really very helpful for me I am reproducing it here for my future reference and I recommend you guys to read the complete series
here

Cross Tab queries , Converting Rows to Columns
Sometimes it is necessary to rotate results so that [the data in] columns are presented horizontally and [the data in] rows are presented vertically. This is known as creating a cross-tab report, or rotating data.

In other words, you can use a Cross Tab or Pivot to convert or transpose information from rows to columns.
A simple introduction to Cross Tabs:

The Cross Tab Report example from Books Online is very simple and easy to understand. I've shamelessly borrowed from it to explain this first shot at a Cross Tab

The Test Data

Basically, the table and data looks like this...



--===== Sample data #1 (#SomeTable1)
--===== Create a test table and some data
CREATE TABLE #SomeTable1
(
Year SMALLINT,
Quarter TINYINT,
Amount DECIMAL(2,1)
)
GO
INSERT INTO #SomeTable1
(Year, Quarter, Amount)
SELECT 2006, 1, 1.1 UNION ALL
SELECT 2006, 2, 1.2 UNION ALL
SELECT 2006, 3, 1.3 UNION ALL
SELECT 2006, 4, 1.4 UNION ALL
SELECT 2007, 1, 2.1 UNION ALL
SELECT 2007, 2, 2.2 UNION ALL
SELECT 2007, 3, 2.3 UNION ALL
SELECT 2007, 4, 2.4 UNION ALL
SELECT 2008, 1, 1.5 UNION ALL
SELECT 2008, 3, 2.3 UNION ALL
SELECT 2008, 4, 1.9
GO

Every row in the code above is unique in that each row contains ALL the information for a given quarter of a given year. Unique data is NOT a requirement for doing Cross Tabs... it just happens to be the condition that the data is in. Also, notice that the 2nd quarter for 2008 is missing.
The goal is to make the data look more like what you would find in a spreadsheet... 1 row for each year with the amounts laid out in columns for each quarter with a grand total for the year. Kind of like this...

... and, notice, we've plugged in a "0" for the missing 2nd quarter of 2008.

Year 1st Qtr 2nd Qtr 3rd Qtr 4th Qtr Total
------ ------- ------- ------- ------- -----
2006 1.1 1.2 1.3 1.4 5.0
2007 2.1 2.2 2.3 2.4 9.0
2008 1.5 0.0 2.3 1.9 5.7

The KEY to Cross Tabs!
Let's start out with the most obvious... we want a Total for each year. This isn't required for Cross Tabs, but it will help demonstrate what the key to making a Cross Tab is.
To make the Total, we need to use the SUM aggregate and a GROUP BY

... like this...




--===== Simple sum/total for each year
SELECT Year,
SUM(Amount) AS Total
FROM #SomeTable1
GROUP BY Year
ORDER BY Year


And, that returns the following...

Year Total
------ ----------------------------------------
2006 5.0
2007 9.0
2008 5.7


Not so difficult and really nothing new there. So, how do we "pivot" the data for the Quarter?
Let's do this by the numbers...
1. How many quarters are there per year? Correct, 4.
2. How many columns do we need to show the 4 quarters per year? Correct, 4.
3. How many times do we need the Quarter column to appear in the SELECT list to make it show up 4 times per year? Correct, 4.
4. Now, look at the total column... it gives the GRAND total for each year. What would we have to do to get it to give us, say, the total just for the first quarter for each year? Correct... we need a CASE statement inside the SUM.
Number 4 above is the KEY to doing this Cross Tab... It should be a SUM and it MUST have a CASE to identify the quarter even though each quarter only has 1 value. Yes, if each quarter had more than 1 value, this would still work! If any given quarter is missing, a zero will be substituted.


To emphasize, each column for each quarter is just like the Total column, but it has a CASE statement to trap info only for the correct data for each quarter's column. Here's the code...




--===== Each quarter is just like the total except it has a CASE
-- statement to isolate the amount for each quarter.
SELECT Year,
SUM(CASE WHEN Quarter = 1 THEN Amount ELSE 0 END) AS [1st Qtr],
SUM(CASE WHEN Quarter = 2 THEN Amount ELSE 0 END) AS [2nd Qtr],
SUM(CASE WHEN Quarter = 3 THEN Amount ELSE 0 END) AS [3rd Qtr],
SUM(CASE WHEN Quarter = 4 THEN Amount ELSE 0 END) AS [4th Qtr],
SUM(Amount) AS Total
FROM #SomeTable1
GROUP BY Year

... and that gives us the following result in the text mode (modified so it will fit here)...
Year 1st Qtr 2nd Qtr 3rd Qtr 4th Qtr Total
------ ------- ------- ------- ------- -----
2006 1.1 1.2 1.3 1.4 5.0
2007 2.1 2.2 2.3 2.4 9.0
2008 1.5 .0 2.3 1.9 5.7


Also notice... because there is only one value for each quarter, we could have gotten away with using MAX instead of SUM.
For most applications, that's good enough. If it's supposed to represent the final output, we might want to make it a little prettier. The STR function inherently right justifies, so we can use that to make the output a little prettier.




--===== We can use the STR function to right justify data and make it prettier.
-- Note that this should really be done by the GUI or Reporting Tool and
-- not in T-SQL
SELECT Year,
STR(SUM(CASE WHEN Quarter = 1 THEN Amount ELSE 0 END),5,1) AS [1st Qtr],
STR(SUM(CASE WHEN Quarter = 2 THEN Amount ELSE 0 END),5,1) AS [2nd Qtr],
STR(SUM(CASE WHEN Quarter = 3 THEN Amount ELSE 0 END),5,1) AS [3rd Qtr],
STR(SUM(CASE WHEN Quarter = 4 THEN Amount ELSE 0 END),5,1) AS [4th Qtr],
STR(SUM(Amount),5,1) AS Total
FROM #SomeTable1
GROUP BY Year


The code above gives us the final result we were looking for...
Year 1st Qtr 2nd Qtr 3rd Qtr 4th Qtr Total
------ ------- ------- ------- ------- -----
2006 1.1 1.2 1.3 1.4 5.0
2007 2.1 2.2 2.3 2.4 9.0
2008 1.5 0.0 2.3 1.9 5.7


Just to emphasize what the very simple KEY to making a Cross Tab is... it's just like making a Total using SUM and Group By, but we've added a CASE statement to isolate the data for each Quarter.

Tuesday, August 26, 2008

Using REPLACE in an UPDATE statement

hi all ,

Many times we need to update the records in our SQL tables in a way like
1. Removing unwanted spaces
2. Replacing some required text pattern from our existing records.

the easiest way to do that is by using REPLACE in an UPDATE statement :

for example :

if a record is " its a simple script" and we need to update it as " its a really simple script"

all we need to do is


update table_name set column = Replace(column ,'simple', 'really simple')


and that's it ... now where ever in the column in question holds 'Simple' in any record is now updated to 'really simple'

enjoy :-)

Friday, August 22, 2008

Ms Sql Server Create Table From Another Table

For the purpose we will use the method SELECT INTO :

This method is used when table is not created earlier and needs to be created when data from one table is to be inserted into newly created table from another table. New table is created with same data types as selected columns.



---- Create new table and insert into table using SELECT INSERT

SELECT Column1, Column2 INTO NewTable FROM oldTable WHERE 1 = 2


Th sql above will copy the structure only

To copy selected data too we need to do the same as :


---- Create new table and insert into table using SELECT INSERT

SELECT Column1, Column2 INTO NewTable FROM oldTable WHERE

Wednesday, August 20, 2008

Download Vishalswami Toolbar

Hi all ,

Now you all can always stay in touch with the new developments of this site, by having the new vishalswami toolbar in your browser.
With that you will get :

1. The Best of Our Site
Get our freshest content delivered directly to your browser,no matter where you are on the Web.

2. Hand-picked Links
Check out all of our favorite places on the Web.

3. Google-Powered Search Box
Search the Web, our site, and other useful engines.

4. Alerts to Your Desktop
Receive our most important news and announcements instantly.

download and install the browser toolbar from here.

Monday, July 14, 2008

SQL Server Update table with inner join : update one table based on the contents of another table

Many times we need to update the contents of one table based on the contents of another table.

Have you ever found yourself in such situation ?

Well the simplest approach for that is by using the aliases.

For example if we wish to update a table tableA based on the contents of the table tableB then by using aliases we can do it in the following way:




Update a set a.field = b.field from tableA a inner join tableB b on a.primaryKey=b.foreignkey

And that’s it.

Wednesday, July 2, 2008

What is equivalent for regsvr32 exe in .NET?

Regasm

What are types of compatibility inVB6?

There are three possible project compatibility settings: - No compatibility - Project compatibility - Binary compatibility No Compatibility With this setting, new class ID’s, new interface ID’s and a new type library ID will be generated by VB each time the ActiveX component project is compiled. This will cause any compiled client components to fail(with error 429!) and report a missing reference to the `VB ActiveX Test component’ when a client project is loaded in the VB IDE. Note: Use this setting to compile the initial release of a component to other developers. Project Compatibility With this setting, VB will generate new interface ID’s for classes whose interfaces have changed, but will not change the class ID’s or the type library ID. This will still cause any compiled client components to fail(with error 429!)but will not report a missing reference to the `VB ActiveX Test component’ when a client project is loaded in the VB IDE. Recompilation of client components will restore them to working order again. Note: Use this setting during the initial development and testing of a component within the IDE and before the component is released to other developers. Binary Compatibility VB makes it possible to extend an existing class or interface by adding new methods and properties etc. And yet still retain binary compatibility. It can do this, because it silently creates a new interface ID for the extended interface and adds registration code to register the original interface ID but with a new forward key containing the value of the new interface ID.COM will then substitute calls having the old ID with the new ID and hence applications built against the old interface will continue to work(assuming the inner workings of the component remain backward compatible!). With this settings, VB will not change any of the existing class, interface or type library ID’s, however in order that it can do so, VB requires the project to specify an existing compiled version that it can compare against to ensure that existing interfaces have not been broken.

How do you do object pooling in .NET?

COM+ reduces overhead by creating object from scratch. So in COM+ when object is activated from its pool and when it’s deactivated it’s pushed back to the pool. Objects pooling is configured by using the “ObjectPoolingAttribute” to the class.

How many types of Transaction are there in COM+ .NET?

There are 5 transaction types that can be used with COM+. Whenever an object is registered with COM+ it has no abide either to these 5 transaction types. Disabled: There is no transaction. COM+ does not provide transaction support for this component. Not Supported: Components does not support transactions. Hence even if the calling component in the hierarchy is transaction enabled this component will not participate in the transaction. Supported: Components with transaction type support will be a part of the transaction. This will be only if the calling component has an active transaction. If the calling component is not transaction enabled this component will not start a new transaction. Required: Components with this attribute require a transaction i.e. either the calling should have a transaction in place else this component will start a new transaction. Required New: Components enabled with this transaction type always require a new transaction. Components with required new transaction type instantiate a new transaction for themselves every time.

How to implement DTC in .NET?

DTC is implemented using COM+. Following are the steps to implement COM+ in .NET: - “EnterpriseService” namespace has all the classes by which we can implement DTC in .NET. You have to add reference “EnterpriseService” namespace. - Your class must derive from “Service Component” object. - Then you have to define your class with the transaction attribute - After the class level transaction type is defined, its time to define at the method level the AutoComplete attribute. AutoComplete attribute says that if no exception is thrown then mark its part of the transaction as being okay. This helps cut down on the amount of code required. If the implementation sets AutoComplete to false, or omits it all together, then we would need to manage the transaction manually. To manually control the transaction you will need to use the ContextUtil class and its static members.

How do we create DCOM objects in VB6?

Using the Create Object method you can create a DCOM object. You have to put the server name in the registry.

Can you explain what DCOM is?

DCOM differs from COM in that it allows for creating objects distributed across a network, a protocol for invoking that object’s methods, and secures access to the object. DCOM provides a wrapper around COM, hence it is a backwards compatible extension. DCOM uses Remote Procedural calls (RPC) using Open Software Foundation’s Distributed Computing Environment. These RPC are implemented over TCP/IP and names pipes. The protocol which is actually being used is registered just prior to use, as opposed to being registered at initialization time. The reason for this is that is that if a protocol is not being used, it will not be loaded. In order to inform an object that the client is still alive, periodic pinging is used. Hence, when the client has died and no ping has been received (to refresh it) before the expiration time, the serverobject will perform some clean up tasks (including decrementing its reference count). Since RPC across a network are typically slow (compared to processes residing on the same machine), DCOM sends multiple requests in the same call.

Can you describe IUKNOWN interface in short?

Every COM object supports at least one interface, the IUnknown interface. All interfaces are classes derived from the base class IUnknown. Each interface supports methods access data and performs operations transparently to the programmer. For example, IUnknown supports three methods, AddRef, Release (), and QueryInterface(). Suppose that printerf is a pointer to an IUnknown. Printerf->;AddRef() increments the reference count. Printerf->;Release() decrements the reference count, deleting the object when the reference count reaches zero. Printerf->;QueryInterface(IDesired, pDesired) checks to see if the current interface (IUnknown) supports snother interface, IDesired, creates an instance (via a call to CoCreateInstance()) of the object if the reference count is zero (the object does not yet exist), and then calls pDesired->;AddRef() to increment the reference count (where pDesired is a pointer to IDesired) and returns the pointer to the caller.

What is Reference counting in COM?

Reference counting is a memory management technique used to count how many times an object has a pointer referring to it. The first time is it created; the reference count is set to one. When the last reference to the object is nulled, the reference count is set to zero and the object is deleted. Care must be exercised to prevent a context switch from changing the reference count at the time of deletion.

How can we use .NET components in COM?Twist: What is CCW (COM callable wrapper)? Twist: How do we ensure that .NET component is compatible with COM?

.NET components can not be used in straight forward way with COM. You will need to create CCW in order that COM components communicate with .NET assemblies. Other way to create CCW is by using InteropServices attributes. Here interfaces are created automatically. Following are different types of attributes: -None: No class interface is generated for the class. This is default setting when you do not specify anything. -AutoDispatch: Interface that supports IDispatch is created for the class. However, no type information is produced. -AutoDual: A dual interface is created for the class. Type information is produced and made available in the type library. Below in the source code we have used the third attribute. Imports System.Runtime.InteropServices _ Public Class ClsCompliant End Class Other than class attributes defined up there are other attributes with which you can govern other part of assembly. Example “GuidAttribute” allows you to specify the GUID, “ComVisibleAttribute” can be used to hide .NET types from COM etc. -Once .NET assembly is created using either interface or using Interopservices method we need to create a COM type library using Type library export tool [Tlbexp (AssemblyName)] -The final thing is registering the CCW in registry using regasm tool. Regasm AssemblyName[Options] and that's it.

How can we use COM Components in .NET? Twist: What is RCW?

Dot NET components communicate with COM using RCW (Runtime Callable Wrapper). Following are the ways with which you can generate RCW: -Adding reference in Visual Studio.net -Using Type library import tool. Tlbimp.exe yourname.dll -Using interopservices.System.runtime. Interopservices namespace contains class TypeLib Converter which provides methods to convert COM classes and interface in to assembly metadata. -Make your custom wrappers. If your COM component does not have type library then the only way to communicate is writing custom wrappers. That means communicating directly with COM components.

What is CODE Access security?

To help protect computer systems from malicious mobile code, to allow code from unknown origins to run with protection, and to help prevent trusted code from intentionally or accidentally compromising security, the .NET Framework provides a security mechanism called code access security. Code access security allows code to be trusted to varying degrees depending on where the code originates and on other aspects of the code's identity. Code access security also enforces the varying levels of trust on code, which minimizes the amount of code that must be fully trusted in order to run. Using code access security can reduce the likelihood that your code can be misused by malicious or error-filled code. It can reduce your liability because you can specify the set of operations your code should be allowed to perform as well as the operations your code should never be allowed to perform. Code access security can also help minimize the damage that can result from security vulnerabilities in your code.

All managed code that targets the common language runtime receives the benefits of code access security, even if that code does not make a single code access security call.

What'is difference between System exceptions and Application exceptions?

From the System.SystemException documentation:

This class is provided as a means to differentiate between exceptions defined by the system versus exceptions defined by applications.

So, consider it the opposite of ApplicationException. All Exceptions that are defined by the .NET Framework inherit from SystemException. All Exceptions that are defined by code that you write should derive from ApplicationException. Exception is the root class of ALL exceptions.

Friday, June 27, 2008

What is the difference between VB.NET and C# ?

Well this is the most debatable issue in .NET community and people treat these languages like religion. It’s a subjective matter which language is best. Some like VB.NET’s natural style and some like professional and terse C# syntaxes. Both use the same framework and speed is also very much equivalents.
But still let’s list down some major differences between them
:-Advantages VB.NET :-Has support for optional parameters which makes COM interoperability much easy. With Option Strict off late binding is supported. Legacy VB functionalities can be used by using Microsoft.VisualBasic namespace. Has the WITH construct which is not in C#. The VB.NET part of Visual Studio .NET compiles your code in the background. While this is considered an advantage for small projects, people creating very large projects have found that the IDE slows down considerably as the project gets larger. Advantages of C# XML documentation is generated from source code but this is now been incorporated in Whidbey. Operator overloading which is not in current VB.NET but is been introduced in Whidbey. Use of this statement makes unmanaged resource disposal simple. Access to Unsafe code. This allows pointer arithmetic etc, and can improve performance in some situations. However, it is not to be used lightly, as a lot of the normal safety of C# is lost (as the name implies).
This is the major difference that you can access unmanaged code in C# and not in VB.NET.

What is concept of Boxing and Unboxing ?

Boxing permits any value type to be implicitly converted to type object or to any interface type implemented by value type. Boxing is a process in which object instances are created and copy values in to that instance. Unboxing is vice versa of boxing operation where the value is copied from the instance in to appropriate storage location. Below is sample code of boxing and unboxing where integer data type is converted in to object and then vice versa.

Dim x As IntegerDim y As Object x = 10‘ boxing process y = x‘ unboxing process x = y

What are Value types and Reference types ?

Value types directly contain their data which are either allocated on the stack or allocated in-line in a structure. Reference types store a reference to the value's memory address, and are allocated on the heap. Reference types can be self-describing types, pointer types, or interface types. Variables that are value types each have their own copy of the data, and therefore operations on one variable do not affect other variables. Variables that are reference types can refer to the same object; therefore, operations on one variable can affect the same object referred to by another variable. All types are derived from the System.Object base type.

What are different types of JIT ?

JIT compiler is a part of the runtime execution environment. In Microsoft .NET there are three types of JIT compilers

1)Pre-JIT :- Pre-JIT compiles complete source code into native code in a single compilation cycle. This is done at the time of deployment of the application.

2)Econo-JIT :- Econo-JIT compiles only those methods that are called at runtime. However, these compiled methods are removed when they are not required.

3)Normal-JIT :- Normal-JIT compiles only those methods that are called at runtime. These methods are compiled the first time they are called, and then they are stored in cache. When the same methods are called again, the compiled code from cache issued for execution.

What is reflection?

All .NET assemblies have metadata information stored about the types defined in modules. This metadata information can be accessed by mechanism called as “Reflection”. System. Reflection can be used to browse through the metadata information. Using reflection you can also dynamically invoke methods using System.Type.Invokemember.

Can we force garbage collector to run ?

System.GC.Collect() forces garbage collector to run. This is not recommended but can be used if situations arises.

What is garbage collection?

Garbage collection is a CLR feature which automatically manages memory.
Programmers usually forget to release the objects while coding ..... Laziness (Remember in VB6 where one of the good practices is to set object to nothing).
CLR automatically releases objects when they are no longer inuse and refernced.
CLR runs on non-deterministic to see the unused objects and cleans them. One side effect of this non-deterministic feature is that we cannot assume an object is destroyed when it goes out of the scope of a function. we should avoid using destructors because before GCdestroys the object it first executes destructor in that case it will have to wait for code to release the umanaged resource. resultin in additional delays in GC.
So its recommended to implement IDisposable interface and write cleanup code in Dispose method and call GC.SuppressFinalizemethod so instructing GC not to call your constructor.

What is Delay signing ?

During development process you will need strong name keys to be exposed to developer which is not a good practice from security aspect point of view. In such situations you can assign the key later on and during development you can use delay signing
Following is process to delay sign an assembly:

First obtain your string name keys using SN.EXE. Annotate the source code for the assembly with two custom attributes from System.Reflection: AssemblyKeyFileAttribute, which passes the name of the file containing the public key as a parameter to its constructor. AssemblyDelaySignAttribute, which indicates that delay signing, is being used by passing true as a parameter to its constructor. For example as shown below:[Visual Basic] [C#] [assembly:AssemblyKeyFileAttribute("myKey.snk")] [assembly:AssemblyDelaySignAttribute(true)]The compiler inserts the public key into the assembly manifest and reserves space in the PE file forthe full strong name signature. The real public key must be stored while the assembly is built so that other assemblies that reference this assembly can obtain the key to store in their own assemblyreference. Because the assembly does not have a valid strong name signature, the verification ofthat signature must be turned off. You can do this by using the –r option with the Strong Name tool. The following example turns off verification for an assembly called myAssembly.dll.Sn –r myAssembly.dll80vJust before shipping, you submit the assembly to your organization's signing authority for the actual strong name signing using the –R option with the Strong Name tool. The following example signs an assembly called myAssembly.dll with a strong name usingthe sgKey.snk key pair.

Sn -R myAssembly.dll sgKey.snk

What is concept of strong names (Twist :- How do we generate strong names or what is the process of generating strong names , What is use of SN.EXE , How do we apply strong names to assembly ?

Strong name is similar to GUID(It is supposed to be unique in space and time) in COM components. Strong Name is only needed when we need to deploy assembly in GAC. Strong Names helps GAC to differentiate between two versions. Strong names use public key cryptography (PKC) to ensure that no one can spoof it. PKC use public key and private key concept. Following are the step to generate a strong name and sign a assembly :-

Go to “Visual Studio Command Prompt”. See below figure “Visual studio Command Prompt”. Note the samples are compiled in 2005 but 2003 users do not have to worry about it. Same type of command prompt will be seen in2003 also.

After you are in command prompt type sn.exe -k “c:\test.snk”.

After generation of the file you can view the SNK file in a simple notepad.

After the SNK file is generated it’s time to sign the project with this SNK file

Click on project -- properties and the browse the SNK file to the respective folder and compile the project.

Click on Use a key file to sign the assembly with strong name. and that’s it.

What is GAC (Twist :- What are situations when you register .NET assembly in GAC ?) ?

GAC (Global Assembly Cache) is used where shared .NET assembly reside. GAC is used in the following situations :-

· If the application has to be shared among several application.

· If the assembly has some special security requirements like only administrator scan remove the assembly. If the assembly is private then a simple delete of assembly the assembly file will remove the assembly. Note :- Registering .NET assembly in GAC can lead to the old problem of DLL hell, where COM version was stored in central registry. So GAC should be used when absolutely necessary.

what is Manifest? what is strongname?

An assembly manifest contains all the metadata needed to specify the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes. The assembly manifest can be stored in either a PE (Portable Executable) file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a standalone PE (Portable Executable) file that contains only assembly manifest information.

The following table shows the information contained in the assembly manifest. The first four items — the assembly name, version number, culture, and strong name information — make up the assembly's identity.

Assembly name: A text string specifying the assembly's name.

Version number: A major and minor version number, and a revision and build number. The common language runtime uses these numbers to enforce version policy.

Culture: Information on the culture or language the assembly supports. This information should be used only to designate an assembly as a satellite assembly containing culture- or language-specific information. (An assembly with culture information is automatically assumed to be a satellite assembly.)

Strong name information: The public key from the publisher if the assembly has been given a strong name.

List of all files in the assembly: A hash of each file contained in the assembly and a file name. Note that all files that make up the assembly must be in the same directory as the file containing the assembly manifest.

Type reference information: Information used by the runtime to map a type reference to the file that contains its declaration and implementation. This is used for types that are exported from the assembly.

Information on referenced assemblies: A list of other assemblies that are statically referenced by the assembly. Each reference includes the dependent assembly's name, assembly metadata (version, culture, operating system, and so on), and public key, if the assembly is strong named.

If you want to view a Assembly how to you go about it (Twist : What is ILDASM ?) ?

When it comes to understanding of internals nothing can beat ILDASM. ILDASM basically converts the whole exe or dll in to IL code.
To run ILDASM you have to go to "C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin".
Note: this applies if you had v1.1 you have to probably change it depending on the type of framework version you have.
If you run IDASM.EXE from the path you will be popped with the IDASM exe program as shown in figure ILDASM. Click on file and browse to the respective directory for the DLL whose assembly you want to view. After you select the DLL you will be popped with a tree view details of the DLL as shown in figure ILDASM.
On double clicking on manifest you will be able to view details of assembly, internal IL code etc.

What is Difference between NameSpace and Assembly?

This is one of the important question asked in most of the .NET technical interviews,

A namespace is a logical naming scheme for types in which a simple type name, such as MyType, is preceded with a dot-separated hierarchical name. Such a naming scheme is completely under control of the developers. For example, types MyCompany.FileAccess.A and MyCompany.FileAccess.B might be logically expected to have functionality related to file access. The .NET Framework uses a hierarchical naming scheme for grouping types into logical categories of related functionality, such as the ASP.NET application framework, or remoting functionality. Design tools can make use of namespaces to make it easier for developers to browse and reference types in their code.

The concept of a namespace is not related to that of an assembly. A single assembly may contain many types whose hierarchical names have different namespace roots, and a logical namespace root may span multiple assemblies. In the .NET Framework, a namespace is a logical design-time naming convention, whereas an assembly establishes the name scope for types at run time.

Namespace: It is a Collection of names wherein each name is Unique.

They form the logical boundary for a Group of classes.

Namespace must be specified in Project-Properties.

Assembly: It is an Output Unit. It is a unit of Deployment & a unit of versioning. Assemblies contain MSIL code.

Assemblies are Self-Describing. [e.g. metadata,manifest]

An assembly is the primary building block of a .NET Framework 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 by code outside that unit.

What is NameSpace?

Namespace is a group of classes, structures, interfaces, enumerations, and delegates, organized in a logical hierarchy by function, that enable you to access the core functionality you need in your applications.

Namespaces are the way that .NET avoids name clashes between classes. A namespace is no more than a grouping of data types, but it has the effect that the names of all data types within a namespace automatically get prefixed with the name of the namespace. It is also possible to nest namespaces within each other.

Or in general we can sya that a namespace uniquely identifies a set of names so that there is no ambiguity when objects having different origins but the same names are mixed together.

What are different types of Assembly?

There are 3 types of Assemblies

1) Private :- Used by only one application and stored in its own folder

2) Public :- Used by more than one application and store in GAC (Global Assembly Cache)

3) Satellite :- It is used during localization and Globalization

What is Assembly ?

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. Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions.

What Is Managed Code?

Managed code is code written in one of over twenty high-level programming languages that are available for use with the Microsoft .NET Framework, including C#, J#, Microsoft Visual Basic .NET, Microsoft JScript .NET, and C++. All of these languages share a unified set of class libraries and can be encoded into an Intermediate Language (IL). A runtime-aware compiler compiles the IL into native executable code within a managed execution environment that ensures type safety, array bound and index checking, exception handling, and garbage collection.

By using managed code and compiling in this managed execution environment, you can avoid many typical programming mistakes that lead to security holes and unstable applications. Also, many unproductive programming tasks are automatically taken care of, such as type safety checking, memory management, and destruction of unneeded objects. You can therefore focus on the business logic of your applications and write them using fewer lines of code. The result is shorter development time and more secure and stable applications.

What is the CTS?What is CLS(Common Language Specification)?

CTS = Common Type System. This is the full range of types that the .NET runtime understands. Not all .NET languages support all the types in the CTS.

CLS = Common Language Specification. This is a subset of the CTS which all .NET languages are expected to support. The idea is that any program which uses CLS-compliant types can interoperate with any .NET program written in any language. This interop is very fine-grained - for example a VB.NET class can inherit from a C# class.

what is CLR

The Common Language Runtime (CLR) is the virtual machine component of Microsoft's .NET initiative. It is Microsoft's implementation of the Common Language Infrastructure (CLI) standard, which defines an execution environment for program code. The CLR runs a form of bytecode called the Common Intermediate Language (CIL, previously known as MSIL -- Microsoft Intermediate Language).

Developers using the CLR write code in a language such as C# or VB.Net. At compile time, a .NET compiler converts such code into CIL code. At runtime, the CLR's just-in-time compiler (JIT compiler) converts the CIL code into code native to the operating system. Alternatively, the CIL code can be compiled to native code in a separate step prior to runtime. This speeds up all later runs of the software as the CIL-to-native compilation is no longer necessary.

Although some other implementations of the Common Language Infrastructure run on non-Windows operating systems, Microsoft's implementation runs only on Microsoft Windows operating systems.

The virtual machine aspect of the CLR allows programmers to ignore many details of the specific CPU that will execute the program. The CLR also provides other important services, including the following:

Memory management

Thread management

Exception handling

Garbage collection

Security

Wednesday, June 25, 2008

What is IL

IL or MSIL

IL is a intermediate language, which is created when you compile the .net program. This is also a object oriented language. This makes cross language inheritance easier.

or in other words we can say it’s a language used as the output of a number of compilers and as the input to a just-in-time (JIT) compiler. The common language runtime includes a JIT compiler for converting MSIL to native code.

Where is version information stored of a assembly ?

All versioning of assemblies that use the common language runtime is done at the assembly level. The specific version of an assembly and the versions of dependent assemblies are recorded in the assembly's manifest. The default version policy for the runtime is that applications run only with the versions they were built and tested with, unless overridden by explicit version policy in configuration files (the application configuration file, the publisher policy file, and the computer's administrator configuration file).

The runtime performs several steps to resolve an assembly binding request:

1. Checks the original assembly reference to determine the version of the assembly to be bound.

2. Checks for all applicable configuration files to apply version policy.

3. Determines the correct assembly from the original assembly reference and any redirection specified in the configuration files, and determines the version that should be bound to the calling assembly.

4. Checks the global assembly cache, codebases specified in configuration files, and then checks the application’s directory and subdirectories

Version Information
Each assembly has two distinct ways of expressing version information:

The assembly's version number, which, together with the assembly name and culture information, is part of the assembly's identity. This number is used by the runtime to enforce version policy and plays a key part in the type resolution process at run time.

An informational version, which is a string that represents additional version information included for informational purposes only. Assembly manifest stored this information.

Tuesday, June 24, 2008

Methods to generate random number in SQL Server

There are many methods to generate random number in SQL Server.


--Method 1 : Generate Random Numbers (Int) between Range
-- Create the variables for the random number generation
DECLARE @Random INT
DECLARE @Upper INT
DECLARE @Lower INT
-- This will create a random number between 1 and 999
SET @Lower = 1 -- The lowest random number
SET @Upper = 999 -- The highest random number
SELECT @Random = ROUND(((@Upper - @Lower -1) * RAND() + @Lower), 0)
SELECT @Random

--Method 2 : Generate Random Float Numbers
SELECT RAND( (DATEPART(mm, GETDATE()) * 100000 )+ (DATEPART(ss, GETDATE()) * 1000 )+ DATEPART(ms, GETDATE()) )

--Method 3 : Random Numbers Quick Scripts

-- random float from 0 up to 20 - [0, 20]
SELECT 20*RAND()
-- random float from 10 up to 30 - [10, 30]
SELECT 10 + (30-10)*RAND()
--random integer BETWEEN 0 AND 20 - [0, 20]
SELECT CONVERT(INT, (20+1)*RAND())
--random integer BETWEEN 10 AND 30 - [10, 30]
SELECT 10 + CONVERT(INT, (30-10+1)*RAND())

--Method 4 : Random Numbers (Float, Int) Tables Based with Time

DECLARE @t TABLE( randnum float )
DECLARE @cnt INT
SET @cnt = 0
WHILE @cnt <=10000
BEGIN
SET @cnt = @cnt + 1
INSERT INTO @tSELECT RAND( (DATEPART(mm, GETDATE()) * 100000 )+ (DATEPART(ss, GETDATE()) * 1000 )+ DATEPART(ms, GETDATE()) )
END

SELECT randnum, COUNT(*)FROM @t GROUP BY randnum

--Method 5 : Random number on a per row basis
--The distribution is pretty good however there are the occasional peaks.
--If you want to change the range of values just change the 1000 to the maximum
--value you want. Use this as the source of a report server report and chart the
--results to see the distribution

SELECT randomNumber, COUNT(1) countOfRandomNumber FROM (SELECT ABS(CAST(NEWID() AS binary(6)) %1000) + 1 randomNumberFROM sysobjects) sample GROUP BY randomNumber ORDER BY randomNumber

How to select records randomely from the SQL Server table.

There are many times when we need to select some records randomely from the SQL Server table.

For that purpose there are many ways that can be utilized for the same. they're especially effective when you wish to add dynamism to a site. For instance, you could randomly select a product to present as Today's Featured Product, or QA could generate a random call list to gauge customer satisfaction levels.

But the snag is that SQL doesn't permit the selection of random rows. then howe to do that ?
But you don't need to worry becaues the good news is that there's a simple trick to getting this functionality to work in SQL.

The solution is based on the uniqueidentifier data type. Unique identifiers, popularily known as Guaranteed Unique Identifiers (GUIDs), look something like this:

4C34AA46-2A5A-4F8C-897F-02354728C7B0

SQL Server uses GUIDs in many contexts, perhaps most notably in replication. You can use them when normal incrementing identity columns won't provide a sufficient range of keys. To do this, you create a column of type uniqueidentifier whose default value is NewID(), something like this:

CREATE TABLE MyNewTable
(
PK uniqueidentifier NOT NULL DEFAULT NewID(),
AnotherColumn varchar(50) NOT NULL,
. . .

This function is just the ticket to solve our random rows problem. We can simply call NewID() as a virtual column in our query, like this:

Select top , NEWID() AS RANDOM from TABLE order by RANDOM

you can now get the number of records selected randomly.

and that's what we want .

so cheers ....

Tuesday, June 10, 2008

How do we can format money or decimal with commas?

Sometimes we want to have our money fields properly formatted with commas like this: 12,345,678.9999

For the same purpose we can use the CONVERT function and give a value between 0 and 2 to the style and the format will be displayed based on that style selection

Here is an example:

DECLARE @value MONEYSELECT @v = 12345678.6666
SELECT CONVERT(VARCHAR,@value ,0) --12345678.67 value is Rounded but no formatting is done
SELECT CONVERT(VARCHAR,@value ,1) --12,345,678.67 Formatted with commas
SELECT CONVERT(VARCHAR,@value ,2) --12345678.6666 No formatting

Now If we have a decimal field it doesn't work with the convert function. The work around in this case is to convert it to money and then follow the above method.

For example:

DECLARE @TargetValue DECIMAL (36,10)
SELECT @TargetValue = 12345678.6666
SELECT CONVERT(VARCHAR,CONVERT(MONEY,@TargetValue ),1) --12,345,678.67 Formatted with commas

how to remove time component from a datetime value

What if I want to remove the time component from a datetime value ?

That is to say I want 2008-04-18 00:00:00.000 intead of 2008-04-18 13:46:57.983

Now since values with the datetime data type are stored internally by the SQL Server 2005 Database Engine as two 4-byte integers. The first 4 bytes store the number of days before or after the base date: January 1, 1900. The base date is the system reference date. The other 4 bytes store the time of day represented as the number of 1/300-second units after midnight.
reference : http://msdn2.microsoft.com/en-us/library/ms187819.aspx

so the simplest way of doing this I found is :

SELECT CONVERT(DATETIME,CONVERT(INT,datetimevalue))

Wednesday, April 9, 2008

How to find all the stored procedures that reference a specific object ?

Usually, people tries to find all the stored procedures that reference a specific object. This object could be any table, view or even any text that is placed in the procedure, In all such cases this post will be really of much help to all of them.

SQL SERVER 2000

Let's say you are searching for 'objectName' in all your stored procedures then all you have to do is :

SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM

INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%objectName%'
AND ROUTINE_TYPE='PROCEDURE'

Another way to perform a search is through the system table syscomments:

SELECT OBJECT_NAME(id) FROM syscomments
WHERE [text] LIKE '%objectName%'
AND OBJECTPROPERTY(id, 'IsProcedure') = 1
GROUP BY OBJECT_NAME(id)

Now, why to use GROUP BY? Well, there is a curious distribution of the procedure text in system tables if the procedure is greater than 8KB. So, the above makes sure that any procedure name is only returned once, even if multiple rows in or syscomments draw a match. But, that begs the question, what happens when the text you are looking for crosses the boundary between rows? Here is a method to create a simple stored procedure that will do this, by placing the search term (in this case, 'objectName') at around character 7997 in the procedure. This will force the procedure to span more than one row in syscomments, and will break the word 'objectName' up across rows.

Run the following query in Query Analyzer, with results to text (CTRL+T):

SET NOCOUNT ON
SELECT 'SELECT '''+REPLICATE('x', 7936)+'objectName' SELECT REPLICATE('x', 500)+''''

This will yield two results. Copy them and inject them here:

CREATE PROCEDURE dbo.x
AS
BEGIN
SET NOCOUNT ON
<<>>
END
GO

Now, try and find this stored procedure in INFORMATION_SCHEMA.ROUTINES or syscomments using the same search filter as above. The former will be useless, since only the first 8000 characters are stored here. The latter will be a little more useful, but initially, will return 0 results because the word 'objectName' is broken up across rows, and does not appear in a way that LIKE can easily find it. So, we will have to take a slightly more aggressive approach to make sure we find this procedure. Your need to do this, by the way, will depend partly on your desire for thoroughness, but more so on the ratio of stored procedures you have that are greater than 8KB. In all the systems that I manage, I don't have more than a handful that approach this size, so this isn't something I reach for very often. Maybe for you it will be more useful. First off, to demonstrate a little better (e.g. by having more than one procedure that exceeds 8KB), let's create a second procedure just like above. Let's call it dbo.y, but this time remove the word 'objectName' from the middle of the SELECT line.

CREATE PROCEDURE dbo.y
AS
BEGIN
SET NOCOUNT ON
<<>>
END
GO

Basically, what we're going to do next is loop through a cursor, for all procedures that exceed 8KB. We can get this list as follows:

SELECT OBJECT_NAME(id)
FROM syscomments
WHERE OBJECTPROPERTY(id, 'IsProcedure') = 1
GROUP BY OBJECT_NAME(id)
HAVING COUNT(*) > 1

We'll need to create a work table to hold the results as we loop through the procedure, and we'll need to use UPDATETEXT to append each row with the new 8000-or-less chunk of the stored procedure code.

-- create temp table
CREATE TABLE #temp ( Proc_id INT, Proc_Name SYSNAME, Definition NTEXT )
-- get the names of the procedures that meet our criteria
INSERT #temp(Proc_id, Proc_Name)
SELECT id, OBJECT_NAME(id)
FROM syscomments
WHERE OBJECTPROPERTY(id, 'IsProcedure') = 1
GROUP BY id, OBJECT_NAME(id)
HAVING COUNT(*) > 1

-- initialize the NTEXT column so there is a pointer
UPDATE #temp SET Definition = ' '
-- declare local variables
DECLARE @txtPval binary(16), @txtPidx INT, @curName SYSNAME, @curtext NVARCHAR(4000)

-- set up a cursor, we need to be sure this is in the correct order
-- from syscomments (which orders the 8KB chunks by colid)

DECLARE c CURSOR
LOCAL FORWARD_ONLY STATIC READ_ONLY FOR
SELECT OBJECT_NAME(id), text
FROM syscomments s
INNER JOIN #temp t
ON s.id = t.Proc_id
ORDER BY id, colid OPEN c FETCH NEXT FROM c INTO @curName, @curtext

-- start the loop
WHILE (@@FETCH_STATUS = 0)
BEGIN
-- get the pointer for the current procedure name / colid

SELECT @txtPval = TEXTPTR(Definition)
FROM #temp
WHERE Proc_Name = @curName

-- find out where to append the #temp table's value

SELECT @txtPidx = DATALENGTH(Definition)/2
FROM #temp
WHERE Proc_Name = @curName
-- apply the append of the current 8KB chunk
UPDATETEXT #temp.definition @txtPval @txtPidx 0 @curtext
FETCH NEXT FROM c INTO @curName, @curtext
END
-- check what was produced
SELECT Proc_Name, Definition, DATALENGTH(Definition)/2
FROM #temp
-- check our filter
SELECT Proc_Name, Definition
FROM #temp
WHERE definition LIKE '%objectName%'
-- clean up
DROP TABLE #temp
CLOSE c
DEALLOCATE c

SQL SERVER 2005
In SQL Server 2005 there are new functions like OBJECT_DEFINITION, which returns the whole text of the procedure. Also, there is a new catalog view, sys.sql_modules, which also holds the entire text, and INFORMATION_SCHEMA.ROUTINES has been updated so that the ROUTINE_DEFINITION column also contains the full text of the procedure. So, any of the following queries will work to perform this search in SQL Server 2005:


SELECT Name FROM sys.procedures
WHERE OBJECT_DEFINITION(object_id)
LIKE '%objectName%'

SELECT OBJECT_NAME(object_id) FROM sys.sql_modules
WHERE Definition LIKE '%objectName%'
AND OBJECTPROPERTY(object_id, 'IsProcedure') = 1

SELECT ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%objectName%'
AND ROUTINE_TYPE = 'PROCEDURE'


Hats off for the beautifully explained and really useful article at Aspfaq.

Saturday, April 5, 2008

custom paging with Datalist, Repeater or Datagrid

hi all,

I was just browsing on the net and look what i found :-)

this is a really very simple article for explaining the implementation of custom paging in Datalist, Repeater or Datagrid...........

go through it .

Tuesday, March 25, 2008

important interview questions -II

Basic .NET Framework questions
what is IL? (Twist :- What is MSIL or CIL , What is JIT?)
What is the CLR?
What is the CTS?What is CLS(Common Language Specification)?
What is Managed Code?
What is Assembly ?
What are different types of Assembly?
What is NameSpace?
What is Difference between NameSpace and Assembly?
If you want to view a Assembly how to you go about it (Twist : What is ILDASM ?) ?
What is Manifest?
Where is version information stored of a assembly ?
Is versioning applicable to private assemblies?
What is GAC (Twist :- What are situations when you register .NET assembly in GAC ?) ?
What is concept of strong names (Twist :- How do we generate strong names or what is the process of generating string names , What is use of SN.EXE , How do we apply strong names to assembly ?
How do you sign an assembly ?
How to add and remove a assembly from GAC?
What is Delay signing ?
What is garbage collection?
Can we force garbage collector to run ?
What is reflection?
What are different type of JIT ?
What are Value types and Reference types ?
What is concept of Boxing and Unboxing ?
What’s difference between VB.NET and C# ?
What’s difference between System exceptions and Application exceptions?
What is CODE Access security?
NET Interoperability
How can we use COM Components in .NET (Twist : What is RCW ?)?
Once i have developed the COM wrapper do i have to still register the COM in registry?
How can we use .NET components in COM (Twist :- What is CCW (COM callable wrapper) ?,
what caution needs to be taken in order that .NET components is compatible with COM ?) ?
How can we make Windows API calls in .NET?
When we use windows API in .NET is it managed or unmanaged code ?
What is COM ?
What is Reference counting in COM ?
Can you describe IUKNOWN interface in short ?
Can you explain what is DCOM ?
How do we create DCOM object in VB6?
How to implement DTC in .NET ?
How many types of Transactions are there in COM + .NET ?
How do you do object pooling in .NET ?
What are types of compatibility in VB6?
Threading
What is Multi-tasking ?
What is Multi-threading ?
What is a Thread ?
Did VB6 support multi-threading ?
Can we have multiple threads in one App domain ?
Which namespace has threading ?
Can you explain in brief how can we implement threading ?
How can we change priority and what the levels of priority are provided by .NET ?
What does Addressof operator do in background ?
How can you reference current thread of the method ?
What's Thread.Sleep() in threading ?
How can we make a thread sleep for infinite period ?
What is Suspend and Resume in Threading ?
What the way to stop a long running thread ?
How do i debug thread ?
What's Thread.Join() in threading ?
What are Daemon thread's and how can a thread be created as Daemon?
When working with shared data in threading how do you implement synchronization ?
Can we use events with threading ?
How can we know a state of a thread?
what is a monitor object?
what are wait handles ?(Twist :- What is a mutex object ?)
what is ManualResetEvent and AutoResetEvent ?
What is ReaderWriter Locks ?
How can you avoid deadlock in threading ?
What’s difference between thread and process?
Remoting and Webservices
What is an application domain?
What is .NET Remoting ?
Which class does the remote object has to inherit ?
What are two different types of remote object creation mode in .NET ?
Describe in detail Basic of SAO architecture of Remoting?
What is the situation you will use singleton architecture in remoting ?
What is fundamental of published or precreated objects in Remoting ?
What are the ways client can create object on server in CAO model ?
Are CAO stateful in nature ?
In CAO model when we want client objects to be created by “NEW” keyword is there any precautions to be taken ?
Is it a good design practice to distribute the implementation to Remoting Client ?
What is LeaseTime,SponsorshipTime ,RenewonCallTime and LeaseManagerPollTime?
Which config file has all the supported channels/protocol ?
How can you specify remoting parameters using Config files ?
Can Non-Default constructors be used with Single Call SAO?(Twist :- What are the limitation of constructors for Single call SAO ?)
How can we call methods in remoting Asynchronously ?
What is Asynchronous One-Way Calls ?
What is marshalling and what are different kinds of marshalling ?
What is ObjRef object in remoting ?
What is a WebService ?
What is UDDI ?
What is DISCO ?
What is WSDL?
What the different phase of acquiring a proxy object in Webservice ?
What is file extension of Webservices ?
Which attribute is used in order that the method can be used as WebService ?
What are the steps to create a webservice and consume it ?
Do webservice have state ?
Caching Concepts
What is application object ?
What’s the difference between Cache object and application object ?
How can get access to cache object ?
What are dependencies in cache and types of dependencies ?
Can you show a simple code showing file dependency in cache ?
What is Cache Callback in Cache ?
What is scavenging ?
What are different types of caching using cache object of ASP.NET?
How can you cache different version of same page using ASP.NET cache object ?
How will implement Page Fragment Caching ?
What are ASP.NET session and compare ASP.NET session with classic ASP session variables?
Which various modes of storing ASP.NET session ?
Is Session_End event supported in all session modes ?
What are the precautions you will take in order that StateServer Mode work properly ?
What are the precautions you will take in order that SQLSERVER Mode work properly ?
Where do you specify session state mode in ASP.NET ?
What are the other ways you can maintain state ?
What are benefits and Limitation of using Hidden fields ?
What is ViewState ?
Do performance vary for viewstate according to User controls ?
What are benefits and Limitation of using Viewstate for state management?
How an you use Hidden frames to cache client data ?
What are benefits and Limitation of using Hidden frames?
What are benefits and Limitation of using Cookies?
What is Query String and What are benefits and Limitation of using Query Strings?
OOPS
What is Object Oriented Programming ?
What’s a Class ?
What’s a Object ?
What’s the relation between Classes and Objects ?
What are different properties provided by Object-oriented systems ?(Twist :- Can you explain different properties of Object Oriented Systems?)(Twist :- What’s difference between Association , Aggregation and Inheritance relationships?)
How can we acheive inheritance in VB.NET ?
What are abstract classes ?
What’s a Interface ?
What is difference between abstract classes and interfaces?
What is a delegate ?
What are event’s ?
Do events have return type ?
Can event’s have access modifiers ?
Can we have shared events ?
What is shadowing ?
What’s difference between Shadowing and Overriding ?
What’s difference between delegate and events?
If we inherit a class do the private variables also get inherited ?
What are different accessibility levels defined in .NET ?
Can you prevent a class from overriding ?
What’s the use of “MustInherit” keyword in VB.NET ?
Why can not you specify accessibility modifier in Interface ?
What are similarities between Class and structure ?
What’s a difference between Class and structure’s ?
What does virtual keyword mean ?
What are shared (VB.NET)/Static(C#) variables?
What is Dispose method in .NET ?
Whats the use of “OverRides” and “Overridable” keywords ?
Where are all .NET Collection classes located ?
What is ArrayList ?
What’s a HashTable ?(Twist :- What’s difference between HashTable and ArrayList ? )
What are queues and stacks ?
What is ENUM ?
What is nested Classes ?
What’s Operator Overloading in .NET?
In below sample code if we create a object of class2 which constructor will fire first ?
What’s the significance of Finalize method in .NET?
Why is it preferred to not use finalize for clean up?
How can we suppress a finalize method?
What’s the use of DISPOSE method?
How do I force the Dispose method to be called automatically, as clients can forget to call Dispose method?
In what instances you will declare a constructor to be private?
ASP.NET
What’s the sequence in which ASP.NET events are processed ?
In which event are the controls fully loaded ?
How can we identify that the Page is PostBack ?
How does ASP.NET maintain state in between subsequent request ?
What is event bubbling ?
How do we assign page specific attributes ?
Administrator wants to make a security check that no one has tampered with ViewState , how can we ensure this ?
What’s the use of @ Register directives ?
What’s the use of SmartNavigation property ?
What is AppSetting Section in “Web.Config” file ?
Where is ViewState information stored ?
What’s the use of @ OutputCache directive in ASP.NET?
How can we create custom controls in ASP.NET ?
How many types of validation controls are provided by ASP.NET ?
Can you explain what is “AutoPostBack” feature in ASP.NET ?
How can you enable automatic paging in DataGrid ?
What’s the use of “GLOBAL.ASAX” file ?
What’s the difference between “Web.config” and “Machine.Config” ?
What’s a SESSION and APPLICATION object ?
What’s difference between Server.Transfer and response.Redirect ?
What’s difference between Authentication and authorization?
What is impersonation in ASP.NET ?
Can you explain in brief how the ASP.NET authentication process works?
What are the various ways of authentication techniques in ASP.NET?
How does authorization work in ASP.NET?
What’s difference between Datagrid , Datalist and repeater ?
From performance point of view how do they rate ?
What’s the method to customize columns in DataGrid?
How can we format data inside DataGrid?
How will decide the design consideration to take a Datagrid , datalist or repeater ?
Difference between ASP and ASP.NET?
What are major events in GLOBAL.ASAX file ?
What order they are triggered ?
Do session use cookies ?
How can we force all the validation control to run ?
How can we check if all the validation control are valid and proper ?
If you have client side validation is enabled in your Web page , Does that mean server side code is not run?
Which JavaScript file is referenced for validating the validators at the client side ?
How to disable client side script in validators?
I want to show the entire validation error message in a message box on the client side?
You find that one of your validation is very complicated and does not fit in any of the validators , so what will you do ?
What is Tracing in ASP.NET ?
How do we enable tracing ?
What exactly happens when ASPX page is requested from Browser?
How can we kill a user session ?
How do you upload a file in ASP.NET ?
How do I send email message from ASP.NET ?
What are different IIS isolation levels?
.NET Architecture
What are design patterns ?
What’s difference between Factory and Abstract Factory Pattern’s?
What’s MVC pattern? (Twist: - How can you implement MVC pattern in ASP.NET? )
How can we implement singleton pattern in .NET?
How do you implement prototype pattern in .NET?(Twist: - How to implement cloning in .NET ? , What is shallow copy and deep copy ?)
What are the situations you will use a Web Service and Remoting in projects?
Can you give a practical implementation of FAÇADE patterns?
How can we implement observer pattern in .NET?
What is three tier architecture?
Have you ever worked with Microsoft Application Blocks, if yes then which?
What is Service Oriented architecture?
ADO.NET
What is the namespace in which .NET has the data functionality classes ?
Can you give a overview of ADO.NET architecture ?
What are the two fundamental objects in ADO.NET ?
What is difference between dataset and datareader ?
What are major difference between classic ADO and ADO.NET ?
What is the use of connection object ?
What is the use of command objects and what are the methods provided by the command object ?
What is the use of dataadapter ?
What are basic methods of Dataadapter ?
What is Dataset object?
What are the various objects in Dataset ?
How can we connect to Microsoft Access , Foxpro , Oracle etc ?
How do we connect to SQL SERVER , which namespace do we use ?
How do we use stored procedure in ADO.NET and how do we provide parameters to the stored procedures?
how can we force the connection object to close after my datareader is closed ?
I want to force the datareader to return only schema of the datastore rather than data ?
How can we fine tune the command object when we are expecting a single row or a single value ? Which is the best place to store connectionstring in .NET projects ?
What are steps involved to fill a dataset ?(Twist :- How can we use dataadapter to fill a dataset ?)
What are the various methods provided by the dataset object to generate XML?
How can we save all data from dataset ?
How can we check that some changes have been made to dataset since it was loaded ?(Twist :- How can cancel all changes done in dataset ? ,How do we get changed value dataset ? )
How add/remove row’s in “DataTable” object of “DataSet” ?
What’s basic use of “DataView” ?
What’s difference between “DataSet” and “DataReader” ?
How can we load multiple tables in a DataSet ?
How can we add relation’s between table in a DataSet ?
What’s the use of CommandBuilder ?
What’s difference between “Optimistic” and “Pessimistic” locking ?
How many way’s are there to implement locking in ADO.NET ?
How can we perform transactions in .NET?
What’s difference between Dataset. clone and Dataset. copy ?
UML
What is UML?
How many types of diagrams are there in UML ?(Twist :- Explain in short all types of diagrams in UML ?)
What are advantages of using UML?(Twist: - What is Modeling and why UML ?)
What’s the sequence of UML diagrams in project?(Twist: - How did you implement UML in your project?)
Just a small Twist: - Do I need all UML diagrams in a project?
Give a small brief explanation of all Elements in activity diagrams?
Explain Different elements of a collaboration diagram ?
Explain Component diagrams ?
Explain all parts of a deployment diagram?
Describe various components in sequence diagrams?
What are the element in State Chart diagrams ?
Describe different elements in Static Chart diagrams ?
Explain different elements of a Use Case ?(Twist: - What’s difference between Activity and sequence diagrams)
Project Management
What is project management?
Is spending in IT project’s constant through out the project?
Who is a stakeholder ?
Can you explain project life cycle ?(Twist :- How many phases are there in software project ?)
Are risk constant through out the project ?
Can you explain different software development life cycles ?
What is triple constraint triangle in project management ?
What is a project baselines ?
What is effort variance?
How is normally a project management plan document organized ?
How do you estimate a project?
What is CAR (Causal Analysis and Resolution)?
How do you handle change request?
What is internal change request?
What is difference between SITP and UTP in testing ?
What are the software you have used for project management?
What are the metrics followed in project management?(Twist: - What metrics will you look at in order to see the project is moving successfully?)
You have people in your team who do not meet there deadlines or do not perform what are the actions you will take ? (Twist :- Two of your resources have conflict’s between them how would you sort it out ?)
How do you start a project?
How did you do resource allocations?
How do you do code reviews ?

Important interview questions

ADO.NET
Which are namespaces for ADO.NET?
Can you give a overview of ADO.NET architecture ?
What are the two fundamental objects in ADO.NET ?
What is difference between dataset and datareader ?
What are major difference between classic ADO and ADO.NET ?
What is the use of connection object ?
What are the methods provided by the command object ?
What is the use of dataadapter ?
What are basic methods of Dataadapter ?
What is Dataset object?
What are the various objects in Dataset ?
How can we connect to Microsoft Access , Foxpro , Oracle etc ?
What’s the namespace to connect to SQL Server?
How do we use stored procedure in ADO.NET?
How can we force the connection object to close?
I want to force the datareader to return only schema?
Can we optimize command object when there is only one row?
Which is the best place to store connectionstring ?
What are steps involved to fill a dataset ?
What are the methods provided by the dataset for XML?
How can we save all data from dataset ?
How can we check for changes made to dataset?
How can we add/remove row’s in “DataTable” object of “DataSet” ?
What’s basic use of “DataView” ?
What’s difference between “DataSet” and “DataReader” ?
How can we load multiple tables in a DataSet ?
How can we add relation’s between table in a DataSet ?
What’s the use of CommandBuilder ?
What’s difference between “Optimistic” and “Pessimistic” locking ?
How many way’s are there to implement locking in ADO.NET ?
How can we perform transactions in .NET?
What’s difference between Dataset. clone and Dataset. copy ?
Whats the difference between Dataset and ADO Recordset?
Notification Services
What are notification services?
What are basic components of Notification services?
Can you explain architecture of Notification Services?
Which are the two XML files needed for notification services?
What is Nscontrols command?
What are the situations you will use “Notification” Services?
Service Broker
What do we need Queues?
What is “Asynchronous” communication?
What is SQL Server Service broker?
What are the essential components of SQL Server Service broker?
What is the main purpose of having Conversation Group?
How to implement Service Broker?
How do we encrypt data between Dialogs?
XML Integration
What is XML?
What is the version information in XML?
What is ROOT element in XML?
If XML does not have closing tag will it work?
Is XML case sensitive?
What’s the difference between XML and HTML?
Is XML meant to replace HTML?
Can you explain why your project needed XML?
What is DTD (Document Type definition)?
What is well formed XML?
What is a valid XML?
What is CDATA section in XML?
What is CSS?
What is XSL?
What is Element and attributes in XML?
Can we define a column as XML?
How do we specify the XML data type as typed or untyped?
How can we create the XSD schema?
How do I insert in to a table which has XSD schema attached to it?
What is maximum size for XML datatype?
What is Xquery?
What are XML indexes?
What are secondary XML indexes?
What is FOR XML in SQL Server?
Can I use FOR XML to generate SCHEMA of a table and how?
What is the OPENXML statement in SQL Server?
I have huge XML file which we want to load in database?
How to call stored procedure using HTTP SOAP?
What is XMLA ?
Data Warehousing/Data Mining
What is “Data Warehousing”?
What are Data Marts?
What are Fact tables and Dimension Tables?
What is Snow Flake Schema design in database?
How can we do ETL process in SQL Server?
What is “Data mining”?
Compare “Data mining” and “Data Warehousing”?
What is BCP?
How can we import and export using BCP utility?
What is Bulk Insert?
What is DTS ?
Can you brief about the Data warehouse project you worked on?
What is an OLTP (Online Transaction Processing) System?
What is an OLAP (On-line Analytical processing) system?
What is Conceptual, Logical and Physical model?
What is Data purging?
What is Analysis Services?
What are CUBES?
What are the primary ways to store data in OLAP?
What is META DATA information in Data warehousing projects?
What is multi-dimensional analysis?
What is MDX?
How did you plan your Data ware house project?
What are different deliverables according to phases?
Can you explain how analysis service works?
What are the different problems that “Data mining” can solve?
What are different stages of “Data mining”?
What is Discrete and Continuous data in Data mining world?
What is MODEL is Data mining world?
How are models actually derived?
What is a Decision Tree Algorithm?
Can decision tree be implemented using SQL?
What is Naïve Bayes Algorithm?
Explain clustering algorithm?
Explain in detail Neural Networks?
What is Back propagation in Neural Networks?
What is Time Series algorithm in data mining?
Explain Association algorithm in Data mining?
What is Sequence clustering algorithm?
What are algorithms provided by Microsoft in SQL Server?
How does data mining and data warehousing work together?
What is XMLA ?
What is Discover and Execute in XMLA?
Integration Services/DTS
What is Integration Services import / export wizard?
What are prime components in Integration Services?
How can we develop a DTS project in Integration Services?
Replication
Whats the best way to update data between SQL Servers?
What are the scenarios you will need multiple databases with schema?
How will you plan your replication?
What is a publisher, distributor and subscriber in “Replication”?
What is “Push” and “Pull” subscription?
Can a publication support push and pull at one time?
What are different models / types of replication?
What is Snapshot replication?
What are the advantages and disadvantages of using Snapshot replication?
What type of data will qualify for “Snapshot replication”?
What’s the actual location where the distributor runs?
Can you explain in detail how exactly “Snapshot Replication” works?
What is merge replication?
How does merge replication works?
What are advantages and disadvantages of Merge replication?
What is conflict resolution in Merge replication?
What is a transactional replication?
Can you explain in detail how transactional replication works?
What are data type concerns during replications?
Reporting Services
Can you explain how can we make a simple report in reporting services?
How do I specify stored procedures in Reporting Services?
What is the architecture for “Reporting Services “?
Database Optimization
What are indexes?
What are B-Trees?
I have a table which has lot of inserts, is it a good database design to create indexes on that table?
What are “Table Scan’s” and “Index Scan’s”?
What are the two types of indexes and explain them in detail?
What is “FillFactor” concept in indexes?
What is the best value for “FillFactor”?
What are “Index statistics”?
How can we see statistics of an index?
How do you reorganize your index, once you find the problem?
What is Fragmentation?
How can we measure Fragmentation?
How can we remove the Fragmented spaces?
What are the criteria you will look in to while selecting an index?
What is “Index Tuning Wizard”?
What is an Execution plan?
How do you see the SQL plan in textual format?
What is nested join, hash join and merge join in SQL Query plan?
What joins are good in what situations?
Transaction and Locks
What is a “Database Transactions “?
What is ACID?
What is “Begin Trans”, “Commit Tran”, “Rollback Tran” and “Save Tran”?
What are “Checkpoint’s” in SQL Server?
What are “Implicit Transactions”?
Is it good to use “Implicit Transactions”?
What is Concurrency?
What kind of problems occurs if we do not implement proper locking strategy?
What are “Dirty reads”?
What are “Unrepeatable reads”?
What are “Phantom rows”?
What are “Lost Updates”?
What are different levels of granularity of locking resources?
What are different types of Locks in SQL Server?
What are different Isolation levels in SQL Server?
If you are using COM+ what “Isolation” level is set by default?
What are “Lock” hints?
What is a “Deadlock” ?
What are the steps you can take to avoid “Deadlocks” ?
How can I know what locks are running on which resource?

SQL SERVER interview questions

What is normalization? What are different type of normalization?
What is denormalization ?
What is a candidate key ?
What are different types of joins and whats the difference between them ?
What are indexes and What is the difference between clustered and nonclustered indexes?
How can you increase SQL performance ?
What is the use of OLAP ?
What's a measure in OLAP ?
What are dimensions in OLAP ?
What are levels in dimensions ?
What are fact tables and dimension tables in OLAP ? (Twist :- can you explain the star schema for OLAP ? )
What is DTS?
What is fillfactor ? (Twist :- When does plage split occurs ?)
What is RAID and how does it work ?
What's the difference between DELETE TABLE and TRUNCATE TABLE commands?
What are the problems that can occur if you do not implement locking properly in SQL SERVER ?
What are different transaction levels in SQL SERVER ?(Twist :- what are different types of locks in SQL SERVER ?)
What are different locks in SQL SERVER ?
Can we suggest locking hints to SQL SERVER ?
What is LOCK escalation?
What are the different ways of moving data/databases between servers and databases in SQL Server?
What are advantages of SQL 2000 over SQl 7.0 ?
What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?
What is difference between UNION and UNION ALL SQL syntax ?
How can you raise custom errors from stored procedure ?
What is ACID fundamental and what are transactions in SQL SERVER ?
What is DBCC?
What is purpose of Replication ?
What are different type of replication supported by SQL SERVER ?
What is BCP utility in SQL SERVER ?
What are different types of triggers in SQl SERVER 2000 ?
If we have multiple AFTER Triggers on table how can we define the sequence of the triggers ? What is SQl injection ?
Revisiting basic syntax of SQL?
What are “GRANT” and “REVOKE’ statements?
What is Cascade and Restrict in DROP table SQL?
What is a DDL, DML and DCL concept in RDBMS world?
What are different types of joins in SQL?
What is “CROSS JOIN”?
You want to select the first record in a given set of rows?
How do you sort in SQL?
How do you select unique rows using SQL?
Can you name some aggregate function is SQL Server?
What is the default “SORT” order for a SQL?
What is a self-join?
What's the difference between DELETE and TRUNCATE ?
Select addresses which are between ‘1/1/2004’ and ‘1/4/2004’?
What are Wildcard operators in SQL Server?
What’s the difference between “UNION” and “UNION ALL” ?
What are cursors and what are the situations you will use them?
What are the steps to create a cursor?
What are the different Cursor Types?
What are “Global” and “Local” cursors?
What is “Group by” clause?
What is ROLLUP?
What is CUBE?
What is the difference between “HAVING” and “WHERE” clause?
What is “COMPUTE” clause in SQL?
What is “WITH TIES” clause in SQL?
What does “SET ROWCOUNT” syntax achieves?
What is a Sub-Query?
What is “Correlated Subqueries”?
What is “ALL” and “ANY” operator?
What is a “CASE” statement in SQL?
What does COLLATE Keyword in SQL signify?

Saturday, March 15, 2008

ASP 2.0 : Failed to execute request because the App-Domain could not be created. Error: 0x80070005 Access is denied :

Give the IIS_WPG group (which contains ASPNET, IWAM_MachineName, LOCAL SERVICE, NETWORK SERVICE & SYSTEM) read/write access to the web root directory & everything beneath. This will fix the issue.