Index

.NET FRAMEWORK tagged Questions - Page 1

visual studio default browser


Please follow the below steps to change the visual studio default browser:

1. Open a webform ( like default.aspx ).
2. Select "Browse With..." in the "File" menu
3. Set "Internet Explorer" the "Default" browser

Hope this helps!

.net 4.5 interview questions and answers


.NET Framework 4.5 was released on 15 August 2012., a set of new or improved features were added into this version. The .NET Framework 4.5 is only supported on Windows Vista or later. The .NET Framework 4.5 uses Common Language Runtime 4.0, with some additional runtime features.



1. .NET for Metro style apps

Metro-style apps are designed for specific form factors and leverage the power of the Windows operating system. A subset of the .NET Framework is available for building Metro style apps for Windows 8 using C# or Visual Basic. This subset is called .NET APIs for apps. The version of .NET Framework, runtime and libraries, used for Metro style apps is a part of the new Windows Runtime, which is the new platform and application model for Metro style apps. It is an ecosystem that houses many platforms and languages, including .NET Framework, Cplusplus and HTML5/JavaScript.




2. Core Features

- Ability to limit how long the regular expression engine will attempt to resolve a regular expression before it times out.

- Ability to define the culture for an application domain.

- Console support for Unicode (UTF-16) encoding.

- Support for versioning of cultural string ordering and comparison data.

- Better performance when retrieving resources.

- Zip compression improvements to reduce the size of a compressed file.

- Ability to customize a reflection context to override default reflection behavior through the CustomReflectionContext class.




3. Managed Extensibility Framework (MEF)

- Support for generic types.

- Convention-based programming model that enables you to create parts based on naming conventions rather than attributes.

- Multiple scopes.




4. Asynchronous operations

In the .NET Framework 4.5, new asynchronous features were added to the C# and Visual Basic languages. These features add a task-based model for performing asynchronous operations.




5. ASP.NET

- Support for new HTML5 form types.

- Support for model binders in Web Forms. These let you bind data controls directly to data-access methods, and automatically convert user input to and from .NET Framework data types.

- Support for unobtrusive JavaScript in client-side validation scripts.

- Improved handling of client script through bundling and minification for improved page performance.

- Integrated encoding routines from the AntiXSS library (previously an external library) to protect from cross-site scripting attacks.

- Support for WebSocket protocol.

- Support for reading and writing HTTP requests and responses asynchronously.

- Support for asynchronous modules and handlers.

- Support for content distribution network (CDN) fallback in the ScriptManager control.




6. Networking

- Provides a new programming interface for HTTP applications: System.Net.Http namespace and System.Net.Http.Headers namespaces are added.

- Other improvements: Improved internationalization and IPv6 support. RFC-compliant URI support. Support for Internationalized Domain Name (IDN) parsing. Support for Email Address Internationalization (EAI).




7. Windows Presentation Foundation (WPF)

- The new Ribbon control, which enables you to implement a ribbon user interface that hosts a Quick Access Toolbar, Application Menu, and tabs.

- The new INotifyDataErrorInfo interface, which supports synchronous and asynchronous data validation.

- New features for the VirtualizingPanel and Dispatcher classes.

- Improved performance when displaying large sets of grouped data, and by accessing collections on non-UI threads.
- Data binding to static properties, data binding to custom types that implement the ICustomTypeProvider interface and retrieval of data binding information from a binding expression.

- Repositioning of data as the values change (live shaping).

- Better integration between WPF and Win32 user interface components.

- Ability to check whether the data context for an item container is disconnected.

- Ability to set the amount of time that should elapse between property changes and data source updates.

- Improved support for implementing weak event patterns. Also, events can now accept markup extensions.




8. Windows Communication Foundation (WCF)

In the .NET Framework 4.5, the following features have been added to make it simpler to write and maintain Windows Communication Foundation (WCF) applications:

- Simplification of generated configuration files.

- Support for contract-first development.

- Ability to configure ASP.NET compatibility mode more easily.

- Changes in default transport property values to reduce the likelihood that you will have to set them.

- Updates to the XmlDictionaryReaderQuotas class to reduce the likelihood that you will have to manually configure quotas for XML dictionary readers.

- Validation of WCF configuration files by Visual Studio as part of the build process, so you can detect configuration errors before you run your application.

- New asynchronous streaming support.

- New HTTPS protocol mapping to make it easier to expose an endpoint over HTTPS with Internet Information Services (IIS).

- Ability to generate metadata in a single WSDL document by appending ?singleWSDL to the service URL.

- Websockets support to enable true bidirectional communication over ports 80 and 443 with performance characteristics similar to the TCP transport.

- Support for configuring services in code.

- XML Editor tooltips.

- ChannelFactory caching support.

- Binary encoder compression support.

- Support for a UDP transport that enables developers to write services that use "fire and forget" messaging. A client sends a message to a service and expects no response from the service.

- Ability to support multiple authentication modes on a single WCF endpoint when using the HTTP transport and transport security.

- Support for WCF services that use internationalized domain names (IDNs).




9. Tools

- Resource File Generator (Resgen.exe) enables you to create a .resw file for use in Windows Store apps from a .resources file embedded in a .NET Framework assembly.

- Managed Profile Guided Optimization (Mpgo.exe) enables you to improve application startup time, memory utilization (working set size), and throughput by optimizing native image assemblies. The command-line tool generates profile data for native image application assemblies.

What is IL?


IL is an acronym of Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code (of any language) is compiled to IL. The IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler.

.Net Framework 4.5 features



.NET Framework 4.5 was
released on 15 August 2012., a set of new or improved features were
added into this version. The .NET Framework 4.5 is only supported on
Windows Vista or later. The .NET Framework 4.5 uses Common Language
Runtime 4.0, with some additional runtime features.





1. .NET for Metro style apps

Metro-style apps are designed for specific form factors and leverage
the power of the Windows operating system. A subset of the .NET
Framework is available for building Metro style apps for Windows 8 using
C# or Visual Basic. This subset is called .NET APIs for apps. The
version of .NET Framework, runtime and libraries, used for Metro style
apps is a part of the new Windows Runtime, which is the new platform and
application model for Metro style apps. It is an ecosystem that houses
many platforms and languages, including .NET Framework, Cplusplus and
HTML5/JavaScript.





2. Core Features

- Ability to limit how long the regular expression engine will attempt to resolve a regular expression before it times out.

- Ability to define the culture for an application domain.

- Console support for Unicode (UTF-16) encoding.

- Support for versioning of cultural string ordering and comparison data.

- Better performance when retrieving resources.

- Zip compression improvements to reduce the size of a compressed file.

- Ability to customize a reflection context to override default reflection behavior through the CustomReflectionContext class.





3. Managed Extensibility Framework (MEF)

- Support for generic types.

- Convention-based programming model that enables you to create parts based on naming conventions rather than attributes.

- Multiple scopes.





4. Asynchronous operations

In the .NET Framework 4.5, new asynchronous features were added to
the C# and Visual Basic languages. These features add a task-based model
for performing asynchronous operations.





5. ASP.NET

- Support for new HTML5 form types.

- Support for model binders in Web Forms. These let you bind data
controls directly to data-access methods, and automatically convert user
input to and from .NET Framework data types.

- Support for unobtrusive JavaScript in client-side validation scripts.

- Improved handling of client script through bundling and minification for improved page performance.

- Integrated encoding routines from the AntiXSS library (previously
an external library) to protect from cross-site scripting attacks.

- Support for WebSocket protocol.

- Support for reading and writing HTTP requests and responses asynchronously.

- Support for asynchronous modules and handlers.

- Support for content distribution network (CDN) fallback in the ScriptManager control.





6. Networking

- Provides a new programming interface for HTTP applications:
System.Net.Http namespace and System.Net.Http.Headers namespaces are
added.

- Other improvements: Improved internationalization and IPv6
support. RFC-compliant URI support. Support for Internationalized Domain
Name (IDN) parsing. Support for Email Address Internationalization
(EAI).





7. Windows Presentation Foundation (WPF)

- The new Ribbon control, which enables you to implement a ribbon
user interface that hosts a Quick Access Toolbar, Application Menu, and
tabs.

- The new INotifyDataErrorInfo interface, which supports synchronous and asynchronous data validation.

- New features for the VirtualizingPanel and Dispatcher classes.

- Improved performance when displaying large sets of grouped data, and by accessing collections on non-UI threads.

- Data binding to static properties, data binding to custom types
that implement the ICustomTypeProvider interface and retrieval of data
binding information from a binding expression.

- Repositioning of data as the values change (live shaping).

- Better integration between WPF and Win32 user interface components.

- Ability to check whether the data context for an item container is disconnected.

- Ability to set the amount of time that should elapse between property changes and data source updates.

- Improved support for implementing weak event patterns. Also, events can now accept markup extensions.





8. Windows Communication Foundation (WCF)

In the .NET Framework 4.5, the following features have been added to
make it simpler to write and maintain Windows Communication Foundation
(WCF) applications:

- Simplification of generated configuration files.

- Support for contract-first development.

- Ability to configure ASP.NET compatibility mode more easily.

- Changes in default transport property values to reduce the likelihood that you will have to set them.

- Updates to the XmlDictionaryReaderQuotas class to reduce the
likelihood that you will have to manually configure quotas for XML
dictionary readers.

- Validation of WCF configuration files by Visual Studio as part of
the build process, so you can detect configuration errors before you run
your application.

- New asynchronous streaming support.

- New HTTPS protocol mapping to make it easier to expose an endpoint over HTTPS with Internet Information Services (IIS).

- Ability to generate metadata in a single WSDL document by appending ?singleWSDL to the service URL.

- Websockets support to enable true bidirectional communication over
ports 80 and 443 with performance characteristics similar to the TCP
transport.

- Support for configuring services in code.

- XML Editor tooltips.

- ChannelFactory caching support.

- Binary encoder compression support.

- Support for a UDP transport that enables developers to write
services that use "fire and forget" messaging. A client sends a message
to a service and expects no response from the service.

- Ability to support multiple authentication modes on a single WCF
endpoint when using the HTTP transport and transport security.

- Support for WCF services that use internationalized domain names (IDNs).





9. Tools

- Resource File Generator (Resgen.exe) enables you to create a .resw
file for use in Windows Store apps from a .resources file embedded in a
.NET Framework assembly.

- Managed Profile Guided Optimization (Mpgo.exe) enables you to
improve application startup time, memory utilization (working set size),
and throughput by optimizing native image assemblies. The command-line
tool generates profile data for native image application assemblies.

Covariance and Contra-variance in .Net


Covariance and contra-variance are the new features added with the .net 4.0. They are basically used for the implicit reference conversion for different .net types like array, delegate, and generic etc

You can go to the below link for more details with the examples that how we can use the covariance and contra-variance to implicit reference conversion:
http://blogs.msdn.com/b/csharpfaq/archive/2010/02/16/covariance-and-contravariance-faq.aspx

What are Extension methods in .Net


Extension methods are special types of methods which are static methods but called as the instance methods.  The extension methods are added with the .Net framework 3.5 and with the Visual Studio 2008.

These methods won’t affect the existing class and the label. These methods are used for the extra behavior which the calls can provide. There is no need to build the class again if we add any extension method to the class.

There are various inbuilt methods added in .Net 3.5 with the introduction of LINQ. We can see the extension methods like Order By when we use the Linq as:

Example:

int[] numbers = { 10, 45, 15, 39, 21, 26 };
var orderedNumbers = numbers.OrderBy(a => a);

What are Anonymous methods and Lambda Expression


Anonymous methods are those methods which does not have the name. As they don’t have the name, so there is no way to call these methods.

These methods are created by using the work delegate as below:

button1.Click += delegate{listBox1.Items.Add(textBox1.Text)};

Lambda Expression: It’s an easy way to create anonymous functions. It is also an anonymous function which has the capability to contain expressions and statements. We can create the delegate and expression tree types using the lambda expression.

Difference between CLR and DLR in .Net



The Common Language Runtime (CLR) is the core set of services offered by .NET – a type system, JIT, a garbage collector, &c. Those are available to all .NET languages, hence the "Common" part.

The Dynamic Language Runtime (DLR) builds atop of this and offers services for dynamic languages: dynamic types, dynamic method dispatch, code generation, &c. The idea is to make those things uniform and share them among dynamic languages so that they work predictably and similar, just like things on the CLR are across all languages too.

In a way those are comparable, a "normal" language on .NET uses the CLR, a dynamic language should use the DLR, but will use the CLR as well. They are basic sets of functionality that the designers considered to be good when they are common across languages. IronPython and IronRuby were implemented on top of the DLR, as is C# 4's dynamic feature.

Explain Garbage Collection in .NET


The .NET garbage collector is optimized for the following assumptions

  1. Objects that were recently allocated are most likely to be freed.
  2. Objects that have lived the longest are least likely to be become free.
  3. Objects allocated together are often used together.

The .NET garbage collector is known as generational garbage collector. The objects allocated are categorized into three generations. Most recently allocated objects are placed in generation 0.
Objects in generation 0, that survive a garbage collection pass are moved to generation 1.
generation 2 contains long-lived objects, that survive after the two collection passes.

A garbage collection pass for generation 0 is the most common type of collection. Generation 1 collection pass is performed if generation 0 collection pass is not sufficient to reclaim memory.
At last, generation 2 collection pass is performed if collection pass on generation 0 and 1 are not sufficient to reclaim memory. If no memory is available, after all the collection passes, an
OutOfMemoryException is thrown.

what is the difference between singleton and static class in .net


It is not possible to pass static class between two layers or tiers as
we can neither pass static class as parameter to any method nor return
from any method.



Here are some examples where we go with singleton implementation as they can’t be achieved using static classes



Controlled/lazy initialization - Create the instance
explicitly or only when it is needed (which is sometimes necessary
because construction may depend on other information).


Destruction - Deterministically free the resources acquired by the instance.


Type - Define the contract by an interface or base class and create the singleton via a factory.


Testing - Unit testing the singleton class (e.g. recreate a clean instance for each test) as well as replacing it by a mock object.


Scope - Static classes are limited to "1 instance per app
domain". Singletons can have different scopes, e.g. instance per thread,
per request, per whatever.


Code artifacts - Singletons allow for events and properties.

Decorator pattern in .net framework


The decorator pattern is a way of providing alternative representations,
or forms, of behavior through a single base type. Quite often, a common
set of functionality is required, but the actual implementation of that
functionality needs to change. An excellent example of this in the .NET
framework is the Stream class and its derivatives. All streams in .NET
provide the same basic functionality, however each stream functions
differently.



- Stream


- MemoryStream

- BufferedStream

- FileStream

- IsolatedStorageFileStream

- PipeStream

- AnonymousPipeClientStream

- AnonymousPipeServerStream

- NamedPipeClientStream

- NamedPipeServerStream

- CryptoStream

- GZipStream


Many, many other design patterns are used within the .NET framework.
Almost every aspect of .NET, from language to framework to fundamental
run-time concepts, are based on common design patterns. Significant
portions of the .NET framework, such as ASP.NET, are in and of
themselves patterns. Take, for example, the ASP.NET MVC framework, which
is an implementation of the web variant of MVC, or
Model-View-Controller. The WPF and Silverlight UI frameworks directly
support a pattern called MVVM, or Model-View-ViewModel. The ASP.NET
pipeline itself is a collection of patterns, including intercepting
filter, page controller, router, etc. Finally, one of the most commonly
used patterns, composition, is used so extensively in the .NET framework
that it is probably one of the most fundamental patterns of the entire
framework.

Value Type and Reference Type in .Net


A variable is value type or reference type is solely determined by its data type.

Example: int, float, char, decimal, bool, decimal, struct, etc are value types, while object type such as class, String, Array, etc are reference type.


Value Type:

As name suggest Value Type stores “value” directly.

For example:

//x and y are both of type int
x = 20;
y = x;
int is a value type, which means that the above statements will results in two locations in memory.
For each instance of value type separate memory is allocated.
Stored in a Stack.
It Provides Quick Access, because of value located on stack.


Reference Type
As name suggest Reference Type stores “reference” to the value.

For example:

Vector X, Y; //Object is defined. (No memory is allocated.)
X = new Vector(); //Memory is allocated to Object. //(new is responsible for allocating memory.)
X.value = 30; //Initialising value field in a vector class.
Y = X; //Both X and Y points to same memory location. //No memory is created for Y.
Console.writeline(Y.value); //displays 30, as both points to same memory
Y.value = 50;
Console.writeline(X.value); //displays 50.
If a variable is reference it is possible to indicate that it does not refer to any object by setting its value to null;
Reference type are stored on Heap.
It provides comparatively slower access, as value located on heap.


Note:
The behavior of strings is different, strings are immutable (unchangeable) if we alter a strings value, we create an entirely new string), so strings don’t display the typical reference-type behavior. Any changes made to a string within a method call won’t affect the original string.

Generics in .Net Framework


Generics allow classes, structs, interfaces, delegates, and methods to be parameterized by the types of data they store and manipulate. We can refer to a class, where we don't force it to be related to any specific Type, except we can perform work with it in a Type-Safe approach. We can create a generic collection than can handle any Type in a generic and Type-Safe approach. For example, we can have a single array class to store a list of Employees or yet a list of Items, and as we actually use it, we will be able to access the items in the collection directly as a list of Employees or Items, and not as objects.

Why Generics?

  1. Generics let us to specify our Type at runtime. you can create a collection that is type-safe at compile-time.
  2. Gives no boxing, no casting advantage.
  3. Both the casting and the boxing and unboxing operations degrade performance.
  4. Use of list collection as their new type not as objects.
  5. Binary code reuse
  6. Code clearness with generics is another advantage.

.Net Generics


Generics allow classes, structs, interfaces,
delegates, and methods to be parameterized by the types of data they
store and manipulate. We can refer to a class, where we don't force it
to be related to any specific Type, except we can perform work with it
in a Type-Safe approach. We can create a generic collection than can
handle any Type in a generic and Type-Safe approach. For example, we can
have a single array class to store a list of Employees or yet a list of
Items, and as we actually use it, we will be able to access the items
in the collection directly as a list of Employees or Items, and not as
objects.

Why Generics?

  1. Generics let us to specify our Type at runtime. you can create a collection that is type-safe at compile-time.
  2. Gives no boxing, no casting advantage.
  3. Both the casting and the boxing and unboxing operations degrade performance.
  4. Use of list collection as their new type not as objects.
  5. Binary code reuse
  6. Code clearness with generics is another advantage.

Extension methods in C#


Extension methods are static methods that can be invoked using instance
method syntax. In effect, extension methods make it possible to extend
existing types and constructed types with additional methods

Declaring extension methods

Extension
methods are declared by specifying the keyword this as a modifier on
the first parameter of the methods. Extension methods can only be
declared in static classes. The following is an example of a static
class that declares two extension methods:

namespace Acme.Utilities
{
public static class Extensions
{
public static int ToInt32(this string s) {
return Int32.Parse(s);
}
public static T[] Slice(this T[] source, int index, int count) {
if (index < 0 || count < 0 || source.Length – index < count)
throw new ArgumentException();
T[] result = new T[count];
Array.Copy(source, index, result, 0, count);
return result;
}
}
}
Extension
methods have all the capabilities of regular static methods. In
addition, once imported, extension methods can be invoked using instance
method syntax.

What is an Assembly?


  1. Assembly is unit of deployment like EXE or a DLL.
  2. An assembly consists of one or more files (dlls, exe’s, html files etc.), and represents a group of resources, type definitions, and implementations of those types. An assembly may also contain references to other assemblies. These resources, types and references are described in a block of data called a manifest. The manifest is part of the assembly, thus making the assembly self-describing.
  3. An assembly is completely self-describing.An assembly contains metadata information, which is used by the CLR for everything from type checking and security to actually invoking the components methods. As all information is in the assembly itself, it is independent of registry. This is the basic advantage as compared to COM where the version was stored in registry.
  4. Multiple versions can be deployed side by side in different folders. These different versions can execute at the same time without interfering with each other. Assemblies can be private or shared. For private assembly deployment, the assembly is copied to the same directory as the client program that references it. No registration is needed, and no fancy installation program is required. When the component is removed, no registry cleanup is needed, and no uninstall program is required. Just delete it from the hard drive.
  5. In shared assembly deployment, an assembly is installed in the Global Assembly Cache (or GAC). The GAC contains shared assemblies that are globally accessible to all .NET applications on the machine.

ADO.Net connection pooling


Connection pooling is a technique for sharing a set of predefined connection objects among clients. Each object in the pool is instantiated upon startup and remains idle waiting for a request to serve. Just like firing up the pizza oven, the creation of the connection object is the most expensive part; pooling a set of similar objects reduces the total cost and guarantees better performance to the application.

ADO.NET and .NET data providers make connection pooling mostly transparent to developers. However, the benefits of connection pooling can be dramatically cut down, or even cancelled out, by poorly chosen connection string parameters or poor Data Access Layer (DAL) design.

Connection Model:

The connection represents an open and unique link to a data source. In a distributed system, this often involves a network connection. Depending on the underlying data source, the programming interface of the various connection objects may differ quite a bit. A connection object is specific to a particular type of data source, such as SQL Server and Oracle. Connection objects can't be used interchangeably across different data sources, but all share a common set of methods andproperties grouped in the IDbConnection interface.

In ADO.NET, connection objects are implemented within data providers as sealed classes (that is, they are not further inheritable). This means that the behavior of a connection class can never be modified or overridden, just configured through properties and attributes.

In ADO.NET, all connection classes support connection pooling, although each class may implement it differently. Connection pooling is implicit, meaning that you don't need to enable it because the provider manages this automatically.

The connection object is much simpler in ADO.NET than it was in earlier versions like ADO 2.x. It drops some of the functions like the capability of executing commands (method Execute) and reading schema information (method OpenSchema).

ADO.NET Connection Classes :

ADO.NET comes with four data providers: SQL Server 7.0 and beyond, Oracle, ODBC data sources, and OLE DB data sources. Each of these has its own connection class with a common layer of functions plus specific features. The SqlConnection class represents a connection to a SQL Server database, version 7.0 or higher. In ADO.NET 2.0, this class also represents a connection to the newest version-SQL Server 2005.

The OracleConnection class connects to an Oracle database, while OdbcConnection represents an open connection to a data source set through an ODBC driver. Finally, OledbConnection establishes a link with a data source via an OLE DB provider.

All connection classes use the ConnectionString property to specify the data source of choice and configure the runtime environment. The connection string can be set either through the aforementioned string property or passed on to the class constructor. Each connection class supplies a bunch of read-only properties to extract details out of the connection string. The Database property gets the name of the database to be used after the connection is opened. The DataSource property indicates the database server through any of the following: file name, server name, or network path. It is important to notice that these detail properties are read-only; their value can only be set through the connection string.

The property ConnectionTimeout gets the timeout value for the physical connection to take place. The default timeout is 15 seconds. A value of 0 means that the application never times out and will indefinitely wait for the connection to open; while acceptable, this setting should be avoided in practice to prevent the application from hanging. The connection timeout can be set through the ConnectionString property. The Oracle connection class doesn't support any timeout and always returns 0-meaning that no maximum wait time is set on an attempt of connection before an error is generated.

Likewise, the Oracle connection class doesn't support the ChangeDatabase method, which other classes use to dynamically change the database for open connections.

In addition to the properties and methods defined by the IDbConnection interface-all classes must implement it-each connection class can provide custom members exposing functionalities specific to the underlying DBMS. The SQL Server provider has three properties: Packet Size, Workstation Id, and ServerVersion.

ServerVersion gets the major.minor.build version number of the current instance of SQL Server. WorkstationId contains the network name of the client accessing SQL Server. PacketSize gets the size in bytes of the network packets used to communicate with an instance of SQL Server. The default size is 8192 bytes. A different value can be set through the connection string using the Packet Size attribute. Feasible values range from 512 to 32767 bytes.

The SQL Server .NET data provider manages pooling using internal classes, as does the Oracle data provider. As you'd expect, OLE DB and ODBC data providers implement connection pooling using the ODBC and OLE DB infrastructure.

Managing a Connection:

Each connection pool is associated with one distinct connection string; the connection string is parsed using an exact-match algorithm. This means that an additional white space, or even a different order of the same attributes, leads to distinct pools. The following code creates two distinct pools.

Upon creation, the pool is filled until the maximum size is reached. Connections are created and opened sequentially. To open a connection, you use the Open method. It takes no arguments and draws a connection object from the pool that matches the connection string, if any. (If not, a new pool is created.) The Open method looks for a usable connection. A connection is reckoned usable if it is currently unused, has a matching transaction context or is not associated with any transaction context, and has a valid link to the server.

If no usable connection is found, the request is queued and served as soon as a valid connection is returned to the pool. Connections return to the pool only if explicitly closed. To close a connection, you can either use the Close or Dispose method. (Dispose ends up calling Close to cancel pending commands and roll transactions back.) The Close method releases the connection object to the pool. If connection pooling is disabled, any call to Close terminates the connection instead.

Connections are removed from the pool in case of a timeout or if a severe error occurs. You should never rely on the garbage collector to return a connection to the pool. If the connection object goes out of scope, the underlying connection to the server is not automatically closed, meaning that any connection must always be explicitly closed Returning a connection to the pool makes the object reusable for another call; the underlying connection to the database is not severed, though. As mentioned, this happens only if a severe error occurs. With SQL Server, if an exception is thrown while a command is being executed, the connection remains open only if the severity level is low (less than 20). Beyond level 20, the connection gets automatically closed. Next, the user can reopen the connection and continue with the application.

As mentioned, connections are assigned also based on the transaction context. The context of the requesting thread and the assigned connection must match. Each pool is subdivided
nto connections with no associated transaction context, and into various groups each filled with connections with a particular transaction context. When a connection is closed, it returns into the appropriate group based on its transaction context. This mechanism allows you to close the connection even though a d

What are the different data types in .Net framework?


There are two different types of data supported by .Net Framework. They are

Value types:
They directly contain data. When you declare an int variable, the system allocates memory to store the value.

Reference type:
The reference types do not maintain data but they contain a reference to the variables, which are stored in memory. This means that if the value in the memory location is modified by one of the variables, the other variables automatically reflect the changes value.

Hope this helps!!!

What is Hashing in C#.Net?


Hashing is a process of converting string of characters into a
shorter fixed-length value or key which represents the original string.
It has many uses like encryption (MD5 , SHA1 etc) or creating a key by
which the original values can be retrieved easily ( Hash tables
collections in .NET).

does entity framework 6 work with net 4


Yes, it is supported with .Net 4.0.

Entity Framework 6 does support .NET 4.0. You should update your
version of NuGet then try again. You can find the download at http://www.nuget.org/. I successfully downloaded EntityFramework 6.0.0-rc1 from the main nuget.org feed from an application targeting .NET 4.0

Similar Tags