Thursday, 8 October 2015

Service Bus

A service namespace provides a scoping container for addressing Service bus resources within your
application. is useful to communicate decoupled applications

Note :Microsoft azure service bus install from nugetpackage

namespace : microsoft.ServiceBus

NamespaceManager class can be used to manage messaging entities in the service bus.

creation of queue :
String strcon = ConfigurationManager.Appsettings["Microsoft.ServiceBus.ConnectionString"].tostring();

NamespaceManager nsMgr=NamespaceManager.CreateFromConnectionString(strcon);

add message to queue  and send:
String strcon = ConfigurationManager.Appsettings["Microsoft.ServiceBus.ConnectionString"].tostring();

QueueClient qclint=QueueClient.CreateFromConnectionString(strcon,"TestQueue123");
BrokeredMessage message=new BorkeredMessage("My message to queue123");

Receive Message :
BrokeredMessage message=null;
String strcon = ConfigurationManager.Appsettings["Microsoft.ServiceBus.ConnectionString"].tostring();

QueueClient qclint = QueueClient.CreateFromConnectionString(strcon,"TestQueue123");
 message= qclint.Receive(TimeSpan.FromSeconds(5));


Wednesday, 7 October 2015

dot net questions

1.what is an assembly ?

A precompiled code that can be executed by the .net runtime environment.
it can  be an .exe or dll.
A .net program consist of one or more assemblies.

There are three types of assembiles.

1.public Assembly / Shared Assembly:

it is a dll which can be used by multiple applications at a time.A shared assembly is stored in GAC i.e. Global Assembly Cache.

2.Private Assembly :

The dll or exe which is used by only one application  and generally stored in the Application specific floder.

3.Satellite Assembly :

A Satellite assembly contains only static objects such as images and other non-executable files such as resource - only files that are required  by the application.

2.What is the prerequisite to delpoy an  assembly in GAC?

The assembly must be strong named.A 'Strongly named' assembly is an assembly that is signed with a key to ensure its uniqueness.

3.What is strong Name?

A strong name is a combination of it's name,version number,culture information,public key and a digital signature.this ensure that the dll is unique.

Strong names provides an integrity check that ensures that the contents of the assembly have
not been changed since it was built.

4.What are generics ? how do you increase performance using generics ?

Generics allows you to define type-safe data structures,without specifying the actual data
types.This increases the performance of the code and code resuse. Thus generics allows you
to write a class or method that can work with any datatype.since generics is type safe it
avoids boxing and unboxing which increases the performance of the code because you no need
convert an object to specific datatype and vicevera.

Have you heared about IComparable? How does it works?

A class can implement IComparable interface if you want to compare the objects of that class.then in that class we have to implement the 'CompareTo' method and provide the implementation to compare two class objects.

What is managed code ?

Managed code is the code whose execution is managed by the .net framework common language
runtime(CLR).The CLR ensures managed execution environment that ensures type safety,exception
handling,garbage collection and array bound & index checking.

What is unmanaged code ?

Application that do not run under the control of the CLR are said to be unmanaged. This is
the code that is directly executed by the operating system.

What is dispose and finalize ?

The Dispose method is generally called by the code that created your class so that we clean up and release any resources we have acquired(database connection/file handles) once the code is done with the object.The finalize method is called when the object is garbage collected and its not guaranteed when this will happen.

Difference between ReadOnly and Const?

1.A Const can be initialized only once whereas   ReadOnly can be initialized at runtime in
 the constructor.
2. Constants are static by default that is they  are compile time constants whereas Readonly are
  runtime constants.
3.Constants must a have at compilation-time and  they are copied into every assembly that uses them.
 Readonly instance fields must be set before the  constructor exits because they are evaluted
 when object is created.

What is the difference between abstract classes and interfaces?

Interface must have only methods without implementation whereas abstract classes can have methods with and without implementation that is you can define a behaviour in an abstract class.

An interface cannot contain access modifiers whereas an abstract class can contain access modifiers.

A class can implement multiple interfaces whereas a class can inherit only one abstract class.

An interface cannot have variables whereas  an abstract class can have variables and constants defined.

when we add a new method to an interface,we have to track all the classes which implement
this interface and add the functionality to this method whereas in case of abstract class we can
add default behavior for the newly added method and thus the class which inherit this class
works properly.

Interfaces are for when you want to say "I don't care how you do it, but here's what you need to get done"

Abstract classes are for when you want to say  "I know what you should do, and I know how you
 should do it in some/many of the cases."

Differnce Between ASMX webservice and wcf webservice ?

ASMX Webservice :
 1. it supports only http protocols an be hosted in iis only

wcf Service :
 1. it supports HTTP (Rest and soap),tcp/ip,msmq   and many more portocols
2. it can be hosted in iis,self,windows service and windows   activation service(was).

Explain the different types of triggers in  SQL Server?
There are three types of tiggers :

1. DML Trigger
2.DDL Trigger
3.Logon Trigger

Instead of trigger are fired in place of the
triggering action such as insert,update,delete

After trigger execute following the
triggering action,such as an insert,update,or

1.DML Trigger :(Insert,Update,Delete)
  DML Triggers again divided into two types
 1.For Triggers\After Triggers
 2.Instead of triggers

2.DDL Triggers :(Create ,alter,drop)
   The DDl Triggers are always after triggers
3.logon triggers :
 This type of trigger is fired against a LOGON
event before a user session is established to
the sql server.

Jquery library comes in 2 different versions production and deployment.
The deployment version is also known as minified version.
So .min.js is basically the minified version of jquery library file.
Both the files are same as far as functionality is concerned.
But .min.js is quite small size so it loads
quickly and saves bandwidth.

1.The starting point of jquery code execution
is $(document).ready() function which is
executed when DOM is loaded.

2.The Same page can have any number of
  document.ready() function.