Search

A lazy port scanner written in c#

This is a legacy port scanner to scan all the open ports over an IP address written in c#
void Main()
{
string IpAddress = "127.0.0.1";
for (int CurrPort = 79; CurrPort <= 85; CurrPort++)
{
TcpClient TcpScan = new TcpClient();
try
{
TcpScan.Connect(IpAddress, CurrPort);
Console.WriteLine("Port " + CurrPort + " open");
}
catch
{
// An exception occured, thus the port is probably closed
//Console.Write("Port " + CurrPort + " closed");
}
}
}

Fing system user by name in MSCRM4

This is a code sample to find and return a system user by running a query over the name:
// find system user by name
private systemuser GetUser(string name)
{
QueryByAttribute query = new QueryByAttribute();
ColumnSet column = new ColumnSet();
column.EntityName = EntityName.systemuser.ToString();
//column.Attributes = new String[] { "name", "systemuserid" };
query.EntityName = EntityName.systemuser.ToString();

systemuser sysUser = new systemuser();
return sysUser; //returns system user
}


Get all roles assigned to a user in MSCRM 4.0

Hi this is a small function to get all the roles assigned to a particular user in Dynamics CRM 4.0 using the CRM SDK.
// Get all roles  assigned to a user 
private BusinessEntityCollection CurrentUserRoles(ICrmService service, Guid userId)
{
var queryForUserRole = new QueryExpression { 
EntityName = "role", 
ColumnSet = new AllColumns()
};

// Create the link entity from role to systemuserroles.
var linkEntityRole = new LinkEntity{
LinkFromEntityName = "role",
LinkFromAttributeName = "roleid",
LinkToEntityName = "systemuserroles",
LinkToAttributeName = "roleid"
};

var linkEntityUserRoles = new LinkEntity{
LinkFromEntityName = "systemuserroles",
LinkFromAttributeName = "systemuserid",
LinkToEntityName = "systemuser",
LinkToAttributeName = "systemuserid"
};

// Create the condition to test the user ID.
var conditionForUserRole = new ConditionExpression{
AttributeName = "systemuserid",
Operator = ConditionOperator.Equal,
Values = new object[] { userId }
};

// Add the condition to the link entity.
linkEntityUserRoles.LinkCriteria = new FilterExpression();
linkEntityUserRoles.LinkCriteria.Conditions.Add(conditionForUserRole);

// Add the from and to links to the query.
linkEntityRole.LinkEntities.Add(linkEntityUserRoles);
queryForUserRole.LinkEntities.Add(linkEntityRole);

// Retrieve the roles and write each one to the console.
BusinessEntityCollection currentUserRoles = service.RetrieveMultiple(queryForUserRole);
return currentUserRoles;
}


Grant/Revoke Security principles in CRM 4

Here are some list of function that works together to share/unshare and assign security priviledges over an entity.
/* Grant/Revoke Security principles in CRM 4 */

// Get Target owner dynamic
private TargetOwnedDynamic GetTargetOwned(string entityName, Guid entityGuid)
{
return new TargetOwnedDynamic()
{
EntityId = entityGuid,
EntityName = entityName
};
}

//Retrieve shared principle access
private PrincipalAccess[] GetPrincipals(TargetOwnedDynamic target)
{
//Describe the target for entity instances that are owned by a security principal.
RetrieveSharedPrincipalsAndAccessRequest retrieve = new RetrieveSharedPrincipalsAndAccessRequest();
retrieve.Target = target;
RetrieveSharedPrincipalsAndAccessResponse retrieved = (RetrieveSharedPrincipalsAndAccessResponse)_crmService.Execute(retrieve);
return retrieved.PrincipalAccesses;
}

//Retrieve team shared principle access
private PrincipalAccess[] GetTeamPrincipals(TargetOwnedDynamic target)
{
//Describe the target for entity instances that are owned by a security principal.
RetrieveSharedPrincipalsAndAccessRequest retrieve = new RetrieveSharedPrincipalsAndAccessRequest();
retrieve.Target = target;
RetrieveSharedPrincipalsAndAccessResponse retrieved = (RetrieveSharedPrincipalsAndAccessResponse)_crmService.Execute(retrieve);
return retrieved.PrincipalAccesses.TakeWhile(tm=>tm.Principal.Type==SecurityPrincipalType.Team).ToArray();
}

// Remove principle access over target
private void RemovePrincipals(TargetOwnedDynamic target, PrincipalAccess[] principals)
{
RevokeAccessRequest request = new RevokeAccessRequest();
request.Target = target;
foreach (PrincipalAccess principal in principals)
{ 
request.Revokee = principal.Principal;
RevokeAccessResponse response = (RevokeAccessResponse)_crmService.Execute(request);
}
}

// Removes all team access over target
private bool RevokeAllTeamAccess(TargetOwnedDynamic target)
{
PrincipalAccess[] allPrinciples = GetPrincipals(target);
PrincipalAccess[] teamPrincipals =
allPrinciples.Where(tp => tp.Principal.Type.Equals(SecurityPrincipalType.Team)).Select(tp => tp).ToArray();
RemovePrincipals(target, teamPrincipals);
return true;
}

// Revoke unknown team access 
private bool RevokeUnknownTeamAccess(TargetOwnedDynamic target)
{
Guid unknownTeamGuid = GetTeamGuid(_configUnknownSalesTeam);

PrincipalAccess unknownTeamPrincipal = GetPrincipals(target).Where(
up => up.Principal.PrincipalId.Equals(unknownTeamGuid) && 
up.Principal.Type.Equals(SecurityPrincipalType.Team))
.Select(up => up).SingleOrDefault();

if (unknownTeamPrincipal != null)
{
RevokeAccessRequest request = new RevokeAccessRequest();
request.Target = target;
request.Revokee = unknownTeamPrincipal.Principal;
RevokeAccessResponse response = (RevokeAccessResponse)_crmService.Execute(request);
return true;
}
else
return false;
}

// Get Team GUID
private Guid GetTeamGuid(string teamName)
{
QueryExpression query = new QueryExpression("team")
{
ColumnSet = new AllColumns(),
Criteria = new FilterExpression {FilterOperator = LogicalOperator.And}
};

ConditionExpression condition1 = new ConditionExpression
{
AttributeName = "name",
Operator = ConditionOperator.Equal,
Values = new object[] {teamName}
};
query.Criteria.Conditions.Add(condition1);

var teamRequest = new RetrieveMultipleRequest { Query = query, ReturnDynamicEntities = true };
var teamResponse = (RetrieveMultipleResponse)_crmService.Execute(teamRequest);
if (teamResponse.BusinessEntityCollection.BusinessEntities.Count == 1)
{
DynamicEntity teamRetrived = (DynamicEntity)teamResponse.BusinessEntityCollection.BusinessEntities[0];
//Key teamKey = ((Key)teamRetrived.Properties["teamid"]).Value;
return ((Key)teamRetrived.Properties["teamid"]).Value;
}
else
{
return Guid.Empty;
}
} 

// Share with unknown team
private bool UnknownTeamShare(TargetOwnedDynamic target)
{
bool alreadySharedToUnknown = false;
Guid unknownTeamGuid = GetTeamGuid(_configUnknownSalesTeam);

//PrincipalAccess[] allPrinciples = GetPrincipals(target);
PrincipalAccess[] teamPrincipals =
GetPrincipals(target).Where(tp => tp.Principal.Type.Equals(SecurityPrincipalType.Team)).Select(tp => tp).ToArray();
alreadySharedToUnknown = teamPrincipals.Any(p => p.Principal.PrincipalId.Equals(unknownTeamGuid));

if (target != null && alreadySharedToUnknown == false)
{
SecurityPrincipal principal = new SecurityPrincipal();
principal.Type = SecurityPrincipalType.Team;
principal.PrincipalId = GetTeamGuid(_configUnknownSalesTeam);

UInt32 mask = 0;
if (_configUnknownSalesTeamPermission.Count >= 1)
mask = _configUnknownSalesTeamPermission.Aggregate(mask, (current, item) => current | UInt32.Parse(item.Value));

//Grant Access
GrantAccessRequest request = new GrantAccessRequest();
request.Target = target;

request.PrincipalAccess = new PrincipalAccess();
request.PrincipalAccess.AccessMask = (AccessRights)mask;
request.PrincipalAccess.Principal = principal;
GrantAccessResponse response = (GrantAccessResponse)_crmService.Execute(request);
Log("The "+target.EntityName + " {" + target.EntityId +"} is shared with the sales team " + _configUnknownSalesTeam,false);
return true;
}
else
{
return false;
}
}




How to reference Assemblies in the GAC

If you install assemblies in the GAC and then wonder why you don't see them enumerated in the Add Reference dialogs, or, if you are complaining that if you browse the assembly folder in the Windows directory, you can't see the assembly in order to add a reference to it, read on.

The Add Reference dialog box is path-based and does not enumerate the components from the GAC. The assembly folder under windows is a special folder view and so you cannot browse to an assembly from this folder and expect to be able to Add a reference to it in the normal way.

If you want to use an assembly from the GAC, you should drop your assemblies into a local folder, and then add a reference to the assembly from this folder. You may want to set the "Copy Local" property to False for that assembly if you do not want the assembly to be copied locally to your project folders. At runtime, the application will automatically use the assembly from the GAC.

How to make your custom assemblies appear in the Add Reference dialog:

To display your assembly in the Add Reference dialog box, you can add a registry key, such as the following, which points to the location of the assembly
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\MyAssemblies]@="C:\\MyAssemblies" 
-- where "MyAssemblies" is the name of the folder in which the assemblies reside.


NOTE: You can create the this registry entry under the HKEY_LOCAL_MACHINE hive. This will change the setting for all of the users on the system. If you create this registry entry under HKEY_CURRENT_USER, this entry will affect the setting for only the current user.

For more information about assemblies and the GAC, vist the following MSDN Web Page: http://msdn.microsoft.com/library/en-us/cpguide/html/cpconglobalassemblycache.asp

shellcodetest.c


/*shellcodetest.c*/
char code[] = "bytecode will go here!";
int main(int argc, char **argv)
{
int (*func)();
func = (int (*)()) code;
(int)(*func)();
}

odfhex - objdump hex extractor

//**************************************
odfhex - objdump hex extractor
by steve hanna v.01
   vividmachines.com
   shanna@uiuc.edu
you are free to modify this code
but please attribute me if you
change the code. bugfixes & additions
are welcome please email me!
to compile:
g++ odfhex.cpp -o odfhex


note: the XOR option works
perfectly, but i haven't implemented
the full x86 payload decoder yet.
so that option is mostly useless.

this program extracts the hex values
from an "objdump -d <binaryname>".
after doing this, it converts the
hex into escaped hex for use in
a c/c++ program.
happy shellcoding!
***************************************/


#include <stdio.h>
#include <unistd.h>
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define HEX_PER_LINE 17
char symbols[37] = "0123456789abcdefghijklmnopqrstuvwxyz";
const int MAX_BASE = 36;
int GetIndex(char * pString, char search);
int BaseToDec(char* number, int base)
{
       if( base < 2 || base > MAX_BASE)
          return 0; //Failed
       int NumLength = strlen(number);
       int PlaceValue, total = 0;

       PlaceValue = (int)pow(base,NumLength-1);


      for(int i=0;i<numlength br="" i="">      {
          total += GetIndex(symbols,*number)*PlaceValue;
          number++;
          PlaceValue /= base; //Next digit's place value (previous/base)
      }
     return total;
}

int GetIndex(char * pString, char search)
{
     int index = 0;
     while(*pString != '0')
     {
       if(*pString==search)
               break;
       pString++;
       index++;
     }
     return index;
}


int main(int argc, char** argv)
{
       FILE* dump = NULL;
       long length = 0;
       char* content;
       int i=0;
       int count =0;
       int total=0;
       int XORvalue=0;
       bool XORit = false;
       char HexNumber[3]={'\0'};

       printf("\nOdfhex - object dump shellcode extractor - by steve hanna - v.01\n");

       if(argc < 2)
       {

             printf("%s: <object dump="" file=""> [-x xor offset in decimal] \n",argv[0]);
             return -1;
       }

       dump = fopen(argv[1],"r");
       if(!dump)
       {
              printf("Error: Couldn't open file.\n");
              return -1;
       }

       fseek(dump,0,SEEK_END);

       length = ftell(dump);

       content = new char[length+1];
       memset(content,0,sizeof(content));
       printf("Trying to extract the hex of %s which is %d bytes long\n",argv[1],length);

       if (argc > 3 &&  !strcmp(argv[2],"-x"))
       {
              XORit =true;
              XORvalue = BaseToDec(argv[3],16);
              printf("XORing with 0x%02x\n",XORvalue);
       }
       fseek(dump,0,SEEK_SET);
       for(int i=0; i < length; i++)
       {
              content[i] = fgetc(dump);
       }
       fclose(dump);

       while(count !=4)
       {

              if(content[i] == ':')
                     count++;
              i++;
       }
       count = 0;
		
	   printf("\"");
       while(i < length)
       {
			if( (content[i-1] == ' ' || content[i-1]=='\t') &&
                (content[i+2] == ' ' ) &&
                (content[i] != ' ') &&
                (content[i+1] != ' ') &&
                ((content[i]>='0' && content[i]<='9') || (content[i]>='a' && content[i]<='f')) &&
                ((content[i+1]>='0' && content[i+1]<='9') || (content[i+1]>='a' && content[i+1]<='f'))
              )
				{
					if(XORit)
					{
				        HexNumber[0] = content[i];
				        HexNumber[1] = content[i+1];

					    printf("\\x%02x",BaseToDec(HexNumber,16) ^ XORvalue);
					}
					else
						printf("\\x%c%c",content[i],content[i+1]);

                     count++;
                     total++;   
            }
		 
			if(i+1 == length)
			{
				 printf("\";\n");
			}
			else if(count == HEX_PER_LINE) 
			{
				printf("\"\\\n\"");
				count =0;
			}
       i++;
       }
	   
       delete[] content;
       printf("\n%d bytes extracted.\n\n",total);
       return 0;
}

Make your system type



Set ws = CreateObject("WScript.Shell")

str = "Hi there... ~ Dont click your mouse while i am typing." & _
" ~~This is a send key example, using which you can send your keystrokes" & _
"to any application you want.~~" & _
"you can increase the value of sleep to for longer delay~~" & _
"So enjoy~Napstr Rulz..."


ws.Run("notepad.exe")
WScript.Sleep(1000)

For c=1 To Len(str)
WScript.Sleep(100) 'Increase the value for longer delay

ws.SendKeys Mid(str,c,1)

Next


Inheritance in C#

Classes can inherit from another class. This is accomplished by putting a colon after the class name when declaring the class, and naming the class to inherit from—the base class—after the colon


using System;


namespace Tutorial
{
public class Parent
{
string parentString;
public Parent() // Constructor
{
Console.WriteLine("Parent Constructor.");
}
public Parent(string myString) // Constructor takes "myString" as parameter.
{
parentString = myString; // Assigns parameter to parentString
Console.WriteLine(parentString);
}
public void print()
{
Console.WriteLine("I'm a Parent Class.");
}
}
public class Child : Parent // Inheritance
{
public Child()
: base("From Derived") //Inherits and calls the base class constructor.
{
Console.WriteLine("Child Constructor.");
}
public void print()
{
base.print();
Console.WriteLine("I'm a Child Class.");
}
public static void Main() //Static main method, init of application
{
Child child = new Child();
child.print();
((Parent)child).print();
}
}
}

The new class—the derived class—then gains all the non-private data and behavior of the base class in addition to any other data or behaviors it defines for itself. The new class then has two effective types: the type of the new class and the type of the class it inherits.

OOP dotnet Interview Questions

What is mean by Class?

Class is a structure that describes the state (property) and behavior (methods) of the object. It is a template or blueprint to create objects of the class. Class represents the noun and it can be used as type in programming language. E.g Car, Person etc

What is mean by Objects?

Object is an executable copy of a class. State and behavior of the objects are defined by class definition. We can create multiple objects for single class. It is also called as instance of the class. When an object is created from the class, memory will be allocated in RAM. e.g Car- Maruthi, Alto, Zen etc. Person- Ram, Sam, John etc

What is mean by Struture?

Structure is a light-weight class used to create user-defined types containing only public fields. Structure can't have implementation inheritance, but it can have interface inheritance. We cannot modify the default constructors as like a class. Structure is a value type holds their value in memory when they are declared.

What is difference between Class and Object?

Classes are the template or blueprint its state of how objects should be and behave, where as Object is an actual real term object. E.g CAR define state like it should have four wheel and body structure with moving, accelerating and break functionality. Maruthi, Alto or Zen is the real object which has different kind of state from one another.

What is difference between Class and Structure?

Class is Reference type(Reference types hold a reference to an object in memory) - Structure is a Value type(Value types hold their value in memory when they are declared) User can modify default constructor and destructor of class- structure can't modify default constructor Class supports inheritance - Structure will not support inheritance Classes must be instantiated using the new operator - Structure can be instantiated without using the new operator

Which case we have to use Class and Structure?

Structure can be used for things that we no need for identity. Class can be used when we need the identity for an object.

What is the advantage of Structure over Class?

Since Stucture is a value type and if we use at the proper location, it will improve the performance.

What are advantages of using private constructor, method, property?

Due to security reason, methods and properties are not exposed outside the class using Private access modifier. For implementing Singleton pattern we go for Private Constructor, so we will not able to create instance. Separate method is used to create and return the instance.

What is mean by Partial class?

It is new features in .Net 2.0; partial classes mean that class definition can be split into multiple physical files. Logically, partial classes do not make any difference to the compiler. The compiler intelligently combines the definitions together into a single class at compile-time.

Example for Partial Class

partial class Employee
{
    string m_Name;
    public String Name
    {
        get { return m_Name; }
        set { m_Name = value; }
    }
}

partial class Employee
{
    int m_Age;
    public int Age
    {
        get { return m_Age; }
        set { m_Age = value; }
    }
}

public class ExampleofPartical
{
    public void Method1()
    {
        Employee objClass1 = new Employee();
        objClass1.Name="Name";
        objClass1.Age = 12;
    }
}

What are different access modifiers in .Net?

Private - The type or member can only be accessed by code in the same class or struct. Protected - The type or member can only be accessed by code in the same class or struct, or in a derived class. Internal - The type or member can be accessed by any code in the same assembly, but not from another assembly. Procted Internal - The type or member can be accessed by any code in the same assembly, or by any derived class in another assembly. Public -The type or member can be accessed by any other code in the same assembly or another assembly that references it.

Note: In VB.Net 'Internal' is called as 'Friend'

What is mean by Partial method?

Partial methods are methods defined in a partial class that are (optionally) divided across two files. With partial methods one file contains the method signature - the method name, its return type, and its input parameters - while the body is (optionally) defined in a separate file. If the partial method's body is not defined then the compiler automatically removes the partial method signature and all calls to the method at compile-time.

Example for Partial method

partial class Employee
{
    string m_Name;
    public String Name
    {
       get { return m_Name; }
        set { m_Name = value; }
    }
    public  partial  string GetEmpDetails(string ID);

}

partial class Employee
{
    int m_Age;
    public int Age
    {
        get { return m_Age; }
        set { m_Age = value; }
    }

    public  partial string GetEmpDetails(string ID)
    {
        return "Employee1";
    }
}

Why do we go for Partial method?

Partial methods are mainly useful in auto-generated code situations. A code generating tool might know that there are certain extension points that some users are going to be interested in customizing. For example, the objects created in LINQ to SQL have partial methods like OnLoaded, OnCreated, OnPropertyNameChanging, and OnPropertyNameChanged.

The auto-generated code calls the OnCreated partial method from its constructor. If you want to run custom code when one of these objects is created you can create a partial class and define the body for the OnCreated partial method.

Why do we go for Partial class?

Improve the readability of extremely large classes by partitioning related methods into separate files. Partial classes enable the code generator to generate code in one file while the developer who may need to extend the auto-generated logic can do so in a separate file, which eliminates the worry that the code generator might overwrite a developer's customizations.

Where we use Partial method and class?

Partial classes and partial methods are most commonly used in auto-generated code. It provides a simple and safe way to add new functionality or extend existing functionality of auto-generated code.

What are restrictions for Partial method?

Partial definitions must preceded with the key word "Partial" Method signature should be same in both partial class file We cannot have partial implementation in one file and another implementation in other file. We can have declaration in one file and implementation in another file.

What is mean by Static class?

Static class is used to create attributes and methods that can be accessed without creating the instance of the class. Static classes are loaded automatically by the .NET Framework when application or assembly is loaded. 'Static' key word is used to mention the static class. e.g MyStaticClass.PI

Example for Static Class

public static class MyStaticClass
{
    public static decimal PI = 3.14M;
    public  static int Add(int num1, int num2)
    {
        return num1 + num2;
    }

    public static  string Append(string str1, string str2)
    {
        return str1 + str2;
    }
}

MyStaticClass.PI

What is mean by Static method?

Static method can be accessed without creating the instance of the class. 'Static' key word is used to mention the static method. Static methods can be created inside the normal class or static class. If we create the static method inside the normal class, static method will not be able to access by creating instance of the class. e.g Math.Add()

Can we override static method?

No, compiler will not allow overriding the static method.

What are uses of static class and method?

Compiler will not allow creating the instance of the class Static class also makes the implementation simpler and faster Cannot inherit a static class since it is sealed

What is static constructor?

A static constructor is used to initialize any static data, or to perform a particular action that needs performed once only. It is called automatically before the first instance is created or any static members are referenced.

Example:

public class MyStaticClass
{
    static int count;

    static MyStaticClass()
    {
        count = 0;
        Console.WriteLine("Static class is initialized");
    }

    public static void MyMethod(string name)
    {
        Console.WriteLine("Static class is initialized " + name);
    }
}

MyStaticClass.MyMethod("John");

Output:

Static class is initialized
Hello John

What are shared (VB.NET)/Static(C#) variables?

Static members are not associated with a particular instance of any class, which can be invoked directly from the class level, rather than from its instance

Example

public static double  PI = 3.1457;

What is Nested Classes?

Classes with in classes are called as Nested class.

Example

public class MyClassLevel_1
{
    public void Display()
    {
        Console.WriteLine("Level_1");
    }

    public  class MyClassLevel_2
    {
        public void Display()
        {
            Console.WriteLine("Level_2");
        }

        public class MyClassLevel_3
        {
            public void Display()
            {
                Console.WriteLine("Level_3");
            }
        }
    }
}

Creating instance of the nested class

MyClassLevel_1 L1 = new MyClassLevel_1();
MyClassLevel_1.MyClassLevel_2 L2 = new MyClassLevel_1.MyClassLevel_2();
MyClassLevel_1.MyClassLevel_2.MyClassLevel_3 L3 = new 
MyClassLevel_1.MyClassLevel_2.MyClassLevel_3();
L1.Display();
L2.Display();
L3.Display();

Output

Level_1
Level_2
Level_3

What are difference between Singleton and Static class ?

Singleton can extend classes and implement interfaces, while a static class cannot implement the interface. Singleton can be initialized lazily or asynchronously while a static class is generally initialized when it is first loaded. Singleton class can be extended and it's methods can be overridden.

Why Main () method is static?

To ensure there is only one entry point to the application.

What is mean by inheritance?

Inheritance is one of the concepts of object-oriented programming, where a new class is created from an existing class. Inheritance class is often referred to as subclasses, comes from the fact that the subclass (the newly created class) contains the attributes and methods of the parent class. This can be used to create a highly specialized hierarchical class structure.

Example of Inheritance

class Circle
{
    private double m_radius;

    public double Radius
    {
        get { return m_radius; }
        set { m_radius = value; }
    }
    public double Diameter
    {
        get { return Radius * 2; }
    }
    public double Circumference
    {
        get { return Diameter * 3.14; }
    }
    public double Area
    {
        get { return Radius * Radius * 3.14; }
    }
}

class Sphere : Circle
{
    new public double Area
    {
    get { return 4 * Radius * Radius * 3.14; }
    }

    public double Volume
    {
    get { return 4 * 3.14 * Radius * Radius * Radius / 3; }
    }
}

Can we inherit multiple classes?

No, multiple inheritances are not supported in .Net. Because consider the provided example. Here there are two Parent class Paretn1 and Parent2. This is inherited by Child class, In GetData method, child call the parent class method PrintData().

In this case which method will be executed? It is very difficult for CLR to identify which method to call. It shows that we multiple inheritance create ambiguity to oops concept. In order to avoid this ambiguity we are going for multiple interface implementations.

public class Parent1
{
    public string PrintData()
    {
        return "This is parent1";
    }
}

public class Parent2
{
    public string PrintData()
    {
        return "This is parent2";
    }
}

public class Child1 : Parent1, Parent2
{
    public string GetData()
    {
        return this.PrintData();
    }
}

What is mean by Shadowing?

When the method is defined in base class are not overrideable and we need to provide different implementation for the same in derived class.

In this kind of scenario we can use hide the base class implementation and provide new implementation using Shadows (VB.Net)/new(C#) keyword.

Example:

Public Class ParentClass
    Public Sub Display()
        Console.WriteLine("Parent class")
    End Sub
End Class

Public Class ChildClass
    Inherits ParentClass

    Public Shadows Sub Display()
        Console.WriteLine("Child class")
    End Sub
End Class


Dim p As New ParentClass
Dim c As New ChildClass
Dim pc As ParentClass = New ChildClass
p.Display()
c.Display()
pc.Display()

Output:
Parent class
Child class
Parent class

How a base class method is hidden?

Using new keyword in the derived class, base class method can be hidden or suppressed. New implementation can be added to the derived class.

What does the keyword virtual mean in the method definition?

The method can be over-ridden.

How method overriding different from overloading?

If we are overriding the method, derived class method behavior is changed from the base class. In Overloading, method with same name by different signature is used.

Example:

public class ParentClass
{
    public virtual void Display()
    {
        Console.WriteLine("ParentClass");
    }
}

public class ChildClass : ParentClass
{
    //Example for method override
    public override void Display()
    {
        Console.WriteLine("ChildClass");
    }

    //Example for method overload
    public void Display(string name)
    {
        Console.WriteLine(name);
    }
    //Example for method overload
    public void Display(string name, string country)
    { 
        Console.WriteLine("Name:"+name +"Country: "+ country );
    }
}

//Main
ParentClass p = new ParentClass();
ChildClass c = new ChildClass();
ParentClass pc = new ChildClass();
p.Display();
c.Display();
pc.Display();

OutPut:

ParentClass
ChildClass
ChildClass 

Can you declare the override method static while the original method is non-static?

No

What is mean by Sealed Class?

Class which cannot be inherited is called as sealed class. If we need to prevent a class from being inherited, use “Sealed� keyword. But sealed class can inherited from other classes.

Example:

public class MyBaseClass
{
    public void Display()
    {
        Console.WriteLine("Base class");
    }
}

//Compile Success: This class cannot be inherited
public sealed class MySealedClass:MyBaseClass 
{
    public void Display()
    {
        base.Display();
        Console.WriteLine("Sealed class");
    }
}

//Compilation Error: cannot derive from sealed type MySealedClass
public class MyChildClass : MySealedClass
{ 

}

Can you allow class to be inherited, but prevent the method from being over-ridden?

Yes, just leave the class public and make the method sealed.

Will sealed class allows inheritance, if not why?

Sealed means it is not inheritable

What are the advantages of Private constructor?

Private constructor will prevent the user from creating the instance of the class which contains only static members. Private constructor are used for implementing the singleton pattern

While using inheritance, derived class construct will call base class constructor?

Yes, base class constructor will be called before child class constructor

Overloaded constructor will call default constructor internally?

No, overload constructor will not call default constructor

What is difference between Overrides and Overridable?

Overridable (VB.Net)/ virtual (C#) is used in parent class to indicate that a method can be overridden. Overrides(VB.Net)/ override(C#) is used in the child class to indicate that you are overriding a method.

What is Method overloading?

Method overloading occurs when a class contains two methods with the same name, but different signatures.

What is operator overloading?

Operator overloading is used to provide a custom functionality to existing operators. For Example +,-,* and / operators are used for mathematical functionality. But we can overload these operators to perform custom operation on classes or structure.

Example:

To concatenate the two strings we have to use Concat method

Dim str1, str2, str3 As String
str1 = "Hello"
str2 = "world"
str3 = String.Concat(str1, str2)
But .Net provides in build operator overloading for string we can use ‘€™ operator for concatenating the string value

str3=str1+str2
Similarly we can also implement operator overloading for classes or structure

Employee3= Employee1 + Employee2

What is mean by abstraction?

Abstraction is the process of showing necessary information and hiding unwanted information. Let us consider the "CalculateSalary" in your Employee class, which takes EmployeeId as parameter and returns the salary of the employee for the current month as an integer value. Now if someone wants to use that method. He does not need to care about how Employee object calculates the salary? An only thing he needs to be concern is name of the method, its input parameters and format of resulting member

What is mean by abstraction class?

Abstract classes contain one or more abstract methods that do not have implementation. An abstract class is a parent class that allows inheritance but can never be instantiated. Abstract classes allow specialization of inherited classes.

What id mean by Interface?

Interface defines the set of properties, signature of the methods and events. It does not include any implementation. Class which implements the interface can provide the behavior to the implemented method. For example two class MyEnglishClassand MyFreanchClass implementing same interface and provide two different set of behavior in their implementation.

public interface IMyInterface
{
    string Hello(string name);
}

public class MyEnglishClass:IMyInterface 
{
    public string Hello(string name)
    {
        return "Hello " + name;
    }
}

public class MyFrenchClass : IMyInterface
{
    public String Hello(string name)
    {
        return "allo " + name; 
    }
}

What is difference between Abstract class and Interface?

In Interface all the method must be abstract; in abstract class we can have both abstract and concrete methods. Access modifiers cannot be specified in interface because it should always be public; in Abstract class, we can specify the access modifier.

In which Scenario you will go for Abstract or Interface Class?

Abstract classes are useful when creating components because they allow you specify an invariant level of functionality in some methods, but leave the implementation of other methods until a specific implementation of that class is needed. They also version well, because if additional functionality is needed in derived classes, it can be added to the base class without breaking code.

Interfaces are often used to describe the peripheral abilities of a class, not its central identity, e.g. an Automobile class might implement the Recyclable interface, which could apply to many otherwise totally unrelated objects.

What is mean by polymorphism?

Polymorphism means the ability to take more than one form. An operation may exhibit different behaviors in different instances. The behavior depends on the data types used in the operation. Polymorphism is extensively used in implementing Inheritance.

What are different types of polymorphism?

There are two types of polymorphism

Static polymorphism - defining the method with same name and different signature is called as static polymorphism.

In the below example there are three different Add() functionality this Add() will be executed based on the parameter passed.

Example :

public int Add(int a, int b)
{ 
return a + b; 
}

public double Add(double a, double b)
{
return a + b;
}

public long Add(long a, long b)
{
return a + b;
}

Dynamic polymorphism Dynamic polymorphism can be implemented using virtual and override keyword. By using polymorphism, each derived class can have its own behavior, Even though classes are derived or inherited from the same parent class

Example:

In the below example ClassB is inherited from ClassA. ClassB can have its own behavior by overriding the parent class method. Parent class method should be represented with virtual keyword to override the same method in derived class.

public class ClassA
{
    public virtual void Display()
    {
        Console.WriteLine ( "ClassA");
    }
}

public class ClassB:ClassA 
{
    public override  void Display()
    {
        Console.WriteLine ( "ClassB");
    }
}

static void Main(string[] args)
{
    ClassA a = new ClassA();
    ClassB b = new ClassB();
    ClassA c = new ClassB();
    a.Display();
    b.Display();
    c.Display();
    Console.ReadLine();
}

OutPut:

ClassA
ClassB
ClassB

What you mean by Encapsulation?

Encapsulation is the procedure of covering up of data and functions into a single unit and protects the data from the outside world. Example “Class� only public functions and properties are exposed; functions implementation and private variables are hidden from outside world.

What is difference between data encapsulation and abstraction?

Abstraction refers to the act of representing essential features without including the background details or explanations. Storing data and functions in a single unit is called as encapsulation.

What is mean by Delegate?

Delegate is a type that holds a reference to a method or a function. . Once a delegate is assigned a method, it behaves exactly like that method. We can call the method using delegate instead of directly calling the method. Using delegate, we can also pass the parameter and get return value. Any method with matched the signature of the delegate can be assigned. Simply we can say .NET implements the concept of function pointers using delegate.

Example:

There are three step to following for using Delegate

  • Declaration
  • Instantiation
  • Invocation

In the below example we have declared the new delegate MyDelegate, which accept string as parameter and return value as string. Two methods SayHello and SayBye function will be called using delegate.

//Declaring the delegate
delegate string MyDelegate(string name);

//function called by delegate dynamically
private static  string SayHello(string name)
{
    return "Hello " + name;
}

private static  string SayBye(string name)
{
    return "Bye " + name;
}

After declaration of delegate, we have initialized with SayHello function. Now this delegate will hold reference to specified function. Function will be called using Invoke () method of delegate. In this example we have called two methods (SayHello and SayBye) with same signature(parameter type and return type).

static void Main(string[] args)
{

    //Initialllizing delegate with function name
    MyDelegate delg = new MyDelegate(SayHello);
    //Invoking function using delegate
    Console.WriteLine(delg.Invoke("Sam"));

    delg = new MyDelegate(SayBye);
    //Invoking diffent function using same delegate
    Console.WriteLine(delg.Invoke("Sam"));

    Console.ReadLine();
}

OutPut:

Hello Sam
Bye Sam

What's a multicast delegate?

It's a delegate that stores the address of multiple methods and eventually fires off several methods. Multicast delegate must have a return type of void.

What is an Asynchronous delegate?

When you invoke a delegate asynchronously, no new thread is created. Instead, the CLR automatically assigns a free thread from a small thread pool that it maintains. Typically, this thread pool starts with one thread and increases to a maximum of about 25 free threads on a single-CPU computer. As a result, if you start 50 asynchronous operations, one after the other, the first 25 will complete first. As soon as one ends, the freed thread is used to execute the next asynchronous operation.

What is mean by Events?

Events are nothing but a publisher and subscriber model. Any subscriber who is interested in receiving notification from the publisher can subscribe the events. If source event is fired or publisher raises the event, a notification will be send to all subscribers. One publisher can have multiple subscribers. Internally events will try to make use of delegate for this publisher, subscription model.

Example:

In the below example, we have created new event called SampleEvent and this event will be fired once MyMethod() is called. Anyone who wants to subscribe to this event can create a instance of the MyClassWithEvent and add handler to the event. So when ever event is raised, add handler method will be called.

Public Class MyClassWithEvent
    'Created New Event, which will return a message to all subscriber
    Event SampleEvent(ByVal message As String)

    'Event will be fired once this method is called
    Public Sub MyMethod()
    Console.WriteLine("MyMethod is called")
    'Raising the event with message
    RaiseEvent SampleEvent("Event is Raised from MyClassWithEvent")
    End Sub
End Class

Module Module1

    Sub Main()
        Dim c As New MyClassWithEvent
        'First subscriber of the event
        AddHandler c.SampleEvent, AddressOf EventSubscriber1
        'Second subscriber of the event
        AddHandler c.SampleEvent, AddressOf EventSubscriber2
        c.MyMethod()
        Console.ReadLine()
    End Sub

    Private Sub EventSubscriber1(ByVal message As String)
        Console.WriteLine("Subscriber 1")
        Console.WriteLine("Message: " + message)
    End Sub

    Private Sub EventSubscriber2(ByVal message As String)
        Console.WriteLine("Subscriber 2")
        Console.WriteLine("Message: " + message)
    End Sub
End Module

OutPut:

MyMethod is called
Subscriber 1
Message: Event is Raised from MyClassWithEvent
Subscriber 2
Message: Event is Raised from MyClassWithEvent

Can events have access modifiers?

Yes, Event’s can have access modifier, if we mention it as Protected events can be subscribed only within inherited class, If you mention it as Internal(C#)/Friends(VB.Net) it can be subscribed by all class inside the assembly. If you mention it as Private it can subscribed with in class where it is declared.

Can we have static/shared events?

Yes, we can have static(C#)/shared(VB.Net) event, but only shared method can raise shared events.

Can we have different access modifier for Get/Set of the properties?

Yes, in C# 3.0 and above, we can use different access modifier for Get/Set of the properties, but this is not possible in C#2.0 and lower

What is an indexer?

An indexer is an accessor that enables an object to be treated in the same way as an array. An indexer is considered when a class is better represented as a virtual container of data that can be retrieved or set using indices. Since an indexer is nameless, its signature is specified by the keyword “this� followed by its indexing parameters within square brackets.

Example:

In the below example we have created new index for class of type string. During get and set operation string manipulations are done.

public class MyClassForIndexer
{
    private string m_Name = "This is example for indexer";
    public string this[int index]
    {
        get 
        {
            return m_Name.Substring( index);
        }
        set
        {
            m_Name = m_Name.Insert(index, value);
        }
    }
}

MyClassForIndexer ind = new MyClassForIndexer();
Console.WriteLine (ind[0]);
ind[7] = "Appended String";
Console.WriteLine(ind[0]);

Output:

This is example for indexer
This isAppended String example for indexer

What is ENUM?

ENUM means Enumeration; it is used to group related sets of constants. To create a enumeration you use the Enum statement

Example:

Enum Months
January = 1
Feburary = 2
March = 3
April = 4
May = 5
June = 6
July = 7
August = 8
September = 9
October = 10
November = 11
December = 12
End Enum

DotNet Threading Interview Questions

What is mean by process?

A process is a collection of threads that share the same virtual memory. A process has at least one thread of execution, and a thread always run in a process context.

What is Thread?

Threads are the basic unit to which an operating system allocates processor time, and more than one thread can be executing code inside that process.

What is Multi-threading?

Multi threading is the collection of thread executed with in the same program to generate the output.

What is Multi-tasking?

It's a feature of modern operating systems with which we can run multiple programs at same time example Word, Excel etc.

What is the namespace used for threading?

System.Threading

Note: - .NET program always has at least two threads running one is the main program and second is the garbage collector.

What is mean by AppDomain?

Operating system process are subdivides into lightweight managed sub processes called application domains. One or more managed threads (represented by System.Threading.Thread) can run in one or any number of application domains within the same managed process.

Although each application domain is started with a single thread, code in that application domain can create additional application domains and additional threads.

Can you explain in brief how can we implement threading?

This sample explains about the implementation of the threading. Let start this example by creating a class with two methods called "Thread1()", "Thread2()"

class TestClass
{
  public void Thread1()
  {
    int index = 0;
    for (index = 0; index < 100; index++)
    {
      Console.WriteLine("This is from first thread: {0}", index.ToString());
    }
  }

  public void Thread2()
  {
    int index = 0;
    for (index = 0; index < 100; index++)
    {
      Console.WriteLine("This is from second thread: {0}", index.ToString());
    }
  }
}

Create a new console application; in the main method we will be creating the new instance of the Thread and pass the address of the TestClass method as constructor parameter to the Thread class.

Start the Thread by calling the Thread.Start() method.

class Program
{
    static void Main(string[] args)
    {
        TestClass _objTestClass = new TestClass();
        Thread th1 = new Thread(new ThreadStart(_objTestClass.Thread1 ));
        Thread th2 = new Thread(new ThreadStart(_objTestClass.Thread2));
        th1.Start();
        th2.Start();
        Console.ReadLine();
    }
}

In the Output we can identify that Thread1 and Thread 2 are called simultaneously. We cannot define when Thread1 or Thread2 is called.

What are different levels of threading priorities are available?

Priority of the thread execution can be changed by using the "Priority" property of the thread instance.

Example:

ThreadName.Priority = ThreadPriority.BelowNormal

Following are the different level of the Thread priority available

ThreadPriority.Highest
ThreadPriority.AboveNormal
ThreadPriority.Normal
ThreadPriority.BelowNormal
ThreadPriority.Lowest

What is mean by Theard.Sleep() ?

The Thread.sleep() method effectively "pauses" the current thread execution for a given period of time. This method takes an integer value as parameter that determines how long the thread needs to be paused.

Example:

System.Threading.Thread.Sleep(4000);

How can we make a thread sleep for infinite period?

You can also place a thread into the sleep state for an indeterminate amount of time by calling Thread.Sleep(System.Threading.Timeout.Infinite).

To interrupt this sleep you can call the Thread.Interrupt method.

What is mean by Thread.Suspend and Resume?

Thread.Suspend() - this method is used to suspend the thread execution. If the method is already suspended, it does not have any effect.

Thread.Resume() - Suspended thread can be resumed using this method call.

What is difference between Thread.Sleep and Thread.Suspend()?

Thread.Sleep() method will immediately place the thread under wait state, where as

Thread.Suspend() method will not go into wait state until .net determines that it is in a safe place to suspend it.

What the way to stop a long running thread?

Thread.Abort() stops the thread execution at that moment itself.

How will we get current thread?

Using System.Threading.Thread.CurrentThread we will be able to get the current thread instance.

How we can make the thread run in background?

By setting ThreadName.IsBackground = true will run the Thread in background process.

Example:

TestClass _objTestClass = new TestClass();
Thread th1 = new Thread(new ThreadStart(_objTestClass.Thread1 ));
th1.IsBackground = true;
th1.Start();

What are Daemon threads and how can a thread is created as Daemon?

Daemon thread's are threads run in background and stop automatically when nothing is running program. Example of a Daemon thread is "Garbage collector".

Garbage collector runs until some .NET code is running or else it's idle. Thread can be made as Daemon by Thread.Isbackground=true

How to debug the thread?

Threading application can be debugged using Debug->Windows->Threads or "Ctrl+Alt+H"

How we can use the same variable by multiple thread or Thread safe?

In certain scenario, multiple threads must need to access the same variable at the same time; this will leads to some other problem. This can be avoided by using SynchLock. So until first thread released its variable, other thread will not be able to access the variable.

Example:

SyncLock (X)
'some operation with "X"
End SyncLock

What are different states of a thread?

Thread status can be known by using ThreadName.ThreadState property. ThreadState enumeration has all the values to detect a state of thread. Some sample states are Aborted, Running, Suspended, etc

Followings are the list of state of a thread.

ThreadState.Aborted
ThreadState.AbortRequested
ThreadState.Background
ThreadState.Running
ThreadState.Stopped
ThreadState.StopRequested
ThreadState.Suspended
ThreadState.SuspendRequested
ThreadState.Unstarted
ThreadState.WaitSleepJoin

Can we use events with threading?

Yes, we can use events with thread; this is one of the techniques to synchronize one thread with other.

What is Event Wait Handle in threading?

Event Wait Handle allows threads to communicate with each other by signaling and by waiting for signals. Event wait handles are wait handles that can be signaled in order to release one or more waiting threads.

What is difference between Monitor object and EventWaitHandle?

Both EventWaitHandles and Monitors are used to synchronize activities But Named event wait handles can be used to synchronize activities across application domains and processes, whereas monitors are local to an application domain.

What is mean by ManualResetEvent and AutoResetEvent?

Threads that call one of the wait methods of a synchronization event must wait until another thread signals the event by calling the Set method. There are two synchronization event classes.

Threads set the status of ManualResetEvent instances to signaled using the Set method.

Threads set the status of ManualResetEvent instances to no signaled using the Reset method or when control returns to a waiting WaitOne call. Instances of the

AutoResetEvent class can also be set to signaled using Set, but they automatically return to nonsignaled as soon as a waiting thread is notified that the event became signaled.

What is mean by Deadlock in Threading?

Dead lock issue will be raised when multi thread try to access the same variable. Example when both the threads try to hold and monitor the variable at same time. Each thread monitor and wait for another thread to release the variable.

Since no one is hold the variable and both the threads are waiting for the other thread to release each other, at last application hangs. This is called as Deadlock.

Measure execution time

This C# code snippet measures a time interval as you would measure the execution time of a task.
using System;

DateTime startTime = DateTime.Now;
Console.WriteLine ("Started: {0}", startTime);
 
// Execute the task to be timed
for (int i=1; i < 100000; i++){}   
  
DateTime stopTime = DateTime.Now;
Console.WriteLine ("Stopped: {0}", stopTime);
 
TimeSpan elapsedTime = stopTime - startTime;
Console.WriteLine ("Elapsed: {0}", elapsedTime);
Console.WriteLine ("in hours       :" + elapsedTime.TotalHours);
Console.WriteLine ("in minutes     :" + elapsedTime.TotalMinutes);
Console.WriteLine ("in seconds     :" + elapsedTime.TotalSeconds);
Console.WriteLine ("in milliseconds:" + elapsedTime.TotalMilliseconds);

Declare simple event

This C# code snippet declares an event with EventHandler using the default implementation for removing events and subscribing to events. We implement the IDisposable interface simply to have a reasonable excuse to throw an event.
using System;
 
public class MyClass : IDisposable
{
   public event EventHandler Disposing;  
 
   public void Dispose()
   {
      // release any resources here
      if (Disposing != null)
      { 
         // someone is subscribed, throw event
         Disposing (this, new EventArgs());
      }
   }
 
   public static void Main( )
   {
      using (MyClass myClass = new MyClass ())
      {
         // subscribe to event with anonymous delegate
         myClass.Disposing += delegate 
            { Console.WriteLine ("Disposing!"); };
      }
   }
}

Versioning in C#

This sample demonstrates versioning in C# through the use of the override and new keywords. Versioning maintains compatibility between base and derived classes as they evolve.


// versioning.cs
public class MyBase
{
public virtual string Meth1()
{
return "MyBase-Meth1";
}
public virtual string Meth2()
{
return "MyBase-Meth2";
}
public virtual string Meth3()
{
return "MyBase-Meth3";
}
}

class MyDerived : MyBase
{
// Overrides the virtual method Meth1 using the override keyword:
public override string Meth1()
{
return "MyDerived-Meth1";
}
// Explicitly hide the virtual method Meth2 using the new
// keyword:
public new string Meth2()
{
return "MyDerived-Meth2";
}
// Because no keyword is specified in the following declaration
// a warning will be issued to alert the programmer that
// the method hides the inherited member MyBase.Meth3():
public string Meth3()
{
return "MyDerived-Meth3";
}

public static void Main()
{
MyDerived mD = new MyDerived();
MyBase mB = (MyBase) mD;

System.Console.WriteLine(mB.Meth1());
System.Console.WriteLine(mB.Meth2());
System.Console.WriteLine(mB.Meth3());
}
}





Comparison Microsoft Dynamics CRM 3.0 to 4.0

Features

3.0

4.0

Description

Multi-langual Support

No

Yes

The new multilingual user interface makes it possible to have more than one language available for the user interface, Help, and metadata in a single installation. so users can work and share data seamlessly in the language of their choice.

Multi-currency Support

No

Yes

It supports multiple currencies with automatic exchange calculation for reporting purposes. Currency is defined on organization creation as base currency. Currency can also be defined by: org, user, Account. All financial transactions to capture the value of the transaction in both the base currency & transaction currency. System administrators to define transaction currencies and define an exchange rate to associate the base currency with the transaction currency Currency order. The account default currency is displayed if one had
been defined. If a default currency is not defined for the account, the user’s default currency is displayed if one has been defined.If a default currency is not defined for the user, the base currency is displayed.

Multi-tenancy

No

Yes

A new multi-tenant architecture allows organizations to host multiple distinct instances of Microsoft Dynamics CRM 4.0 on the same server. This not only allows them to make better use of hardware, it reduces management and maintenance costs associated with the CRM application. Multiple organizations may each have their own instance of Microsoft Dynamics CRM 4.0 without requiring additional database servers, making it an excellent solution for companies that host CRM services for multiple customers, or for organizations with distinct business units who each need their own data repository.

Smart Search

No

Yes

Smart Search makes it easier for you to find what you’re looking for by eliminating clicks and removing the necessity for a separate lookup window. Search results will automatically display if an exact match is found. Relevant options are also displayed on partial matches when you type so you can easily select the relevant item, enabling you to spend your time on higher-value tasks.

Multi-stage Workflows

No

Yes

New tools in Microsoft Dynamics CRM 4.0 make it easier to create multi-stage workflows such as a sales cycle or customer retention process. Microsoft Dynamics CRM 4.0 also provides visibility into running workflow stages, enabling users to see and track the progress of business processes. End users can also see the status of workflows that are running, giving them greater insight into their customers.

Metadata Application Programmer Interface

No

Yes

The Microsoft Dynamics CRM 4.0 metadata application programming interface (API) has been expanded to make it easier for developers to create flexible custom solutions and to enhance integration capabilities. Developers can now create, read, update, and delete metadata on the fly and create custom entities, attributes, and relationships programmatically. The Microsoft Dynamics CRM 3.0 Metadata API is still available to
support backward compatibility. Now it is easier than ever to have a CRM system that is tailored to meet specific business needs with the flexibility to change and expand as the business does.

Support for SQL Mirroring

No

Yes

Line-of-business applications must be available to support business requirements without downtime or loss of data. When mission-critical applications go down, the impact can be significant and the result can be missed opportunities, dissatisfied customers, and lost employee productivity. With support for Microsoft SQL Server® mirroring, Microsoft Dynamics CRM 4.0 maintains a copy of its database so that in the event of a database failure it can switch databases automatically with minimal disruption.

Clustering and Load Balancing

Yes

Yes

Microsoft Dynamics CRM 4.0 supports clustering and load balancing of all solution components, including Exchange Server, SQL Server Reporting Services, and Web services.Clustering allows you to scale your applications effectively so that you can support youruser base and expand as your business grows.

Internet Facing Deployment

No

Yes

Microsoft Dynamics CRM 4.0 gives you an easier, faster way to access your data over the Internet with Internet-Facing Deployments. Now end users can use Microsoft Office Outlook to access the CRM application using hypertext transfer protocol (HTTP) with Secure Sockets Layer (SSL) from home or while travelling without requiring a VPNconnection.

Resource Center

No

Yes

The new Resource Center provides an online community for people to share information and best practices, and learn about using Microsoft Dynamics CRM. In the Resource Center, you have access to a variety of problem-solving content, including:
• Current blog posts,
• newsgroup answers, and
• articles

Advanced Relationship Modeling (Many to Many Relationships,System to System

Relationships)

No

Yes

Now MSCRM4.0 allows to create
1) System-to-System relationships between supported entities
2) Many-to-Many relationships between supported entities
3) Self-Referential relationships

Advanced Diagnostics

No

Yes

With new diagnostic tools, it is easier than ever to get a clear picture of how well the CRMsystem is running. Diagnostic tools provide administrators with a broad set of alerts and warnings to help detect and resolve issues with the CRM system, including detection of unsupported configurations, before they result in outages.

Portable Application Model

No

Yes

Microsoft Dynamics CRM 4.0 extends the portable application model, which supports the export and import of the entire CRM application for seamless migration to another CRM server. Now security roles, workflows, organization settings, multi-language UI settings, and other metadata can all be imported and exported, making it easier for technical teams to move from development to testing to production or move the
CRM installation to a new server.

Duplicate Detection

No

Yes

Microsoft Dynamics CRM 4.0 helps ensure the quality of your data by providing duplicate detection when adding data to the system or during a regular maintenance cycle.

Data Import Wizard

No

 

Data Import wizard is used to move data from other applications into Microsoft Dynamics CRM. Import Data Wizard, which is useful for importing data you have stored in a spreadsheet, importing leads that you have purchased, and for enriching existing data.

Windows Workflow Foundation

No

Yes

Microsoft Dynamics CRM 4.0 makes it easier to unify business processes across the business with Microsoft Windows® Workflow Foundation, a set of tools and technologies for creating and integrating data and processes from your CRM solution with other Microsoft line-of-business systems. Workflows built in Microsoft Dynamics CRM 3.0 are forward-compatible and will continue tofunction in Microsoft Dynamics CRM 4.0.

Workflow Wizard

No

Yes

Microsoft Dynamics CRM workflow allows companies to automate how they use and manage data. Microsoft Dynamics CRM 4.0 builds on this capability by empowering end-users to create workflows without IT involvement using a new Web-based workflow wizard. Workflows can easily be shared using team, division, and system workflow libraries so that people can find workflows that are relevant to their work.

Dynamic Data Access for Workflow Design

No

Yes

The workflow forms designer gives users access to dynamic data so they can easily createworkflows that provide rich contextual CRM data. Forms can be easily created that show data values based on live data in your CRM database. Incorporating dynamic data into workflows helps users deliver context-sensitive relevance alongside workflow functionality.

Promote E-mail to Lead

No

Yes

In the past, when the sales manager or salesperson received an e-mail that they wanted to categorize as a lead, they needed to open the lead form and create a new lead. Now they can convert an activity directly into a lead.

Promote E-mail to Case

No

Yes

E-mail messages can be promoted into cases automatically, helping you do your work more efficiently. This reduces the amount of manual work required to manage these typesof activities and speeds customer communications.

Web Mail Merge

No

Yes

New and enhanced tools with support for custom attributes, as well as central storage and sharing of mail merge templates make it easier for users to manage and create mail merges. With CRM 4.0 you can create and share reusable templates with your coworkers so you can work more productively. A new Web-based tool for mail merges empowers users to work with mail merges through the Web.

Reporting Wizard

No

Yes

Microsoft Dynamics CRM 4.0 empowers end users to create, share, and use reports without IT assistance. The Web-based Reporting Wizard provides simplified access to information, allowing users to work more independently and freeing IT staff to do other work. Users can also create and share personalized views and filters on reports to help them focus on the information that’s most relevant to their work and share insight
with others The report wizard allows customers to analyze their data by creating and editing new reportsin Microsoft Dynamics CRM or by customizing an existing report created with the reportwizard. The report wizard will allow customers to:
• Group data
• Summarize data, for example, total revenue
• Present data in tables, graphs, and charts
• Print without exporting to Excel

Scheduled Reporting

No

Yes

Keeping up with changes in the customer repository is an ongoing challenge. Scheduled and recurring reports provide snapshots of the customer information as it evolves. On-demand reporting provides customer data in real time, so that people can stay informed and do their job better.

Offline Reporting

No

Yes

Offline users can take advantage of reporting capabilities using synchronized data. Offline users can easily run reports against their locally synchronized data store on their client machine, and reports are republished in offline mode. Users have full access to reporting features, such as filtered views, helping them be effective even without a connection to the CRM system.

Offline Customizations

No

Yes

Microsoft Dynamics CRM 4.0 offers a consistent user experience whether working online or offline, including the ability to take reports, workflows, and other custom functionality offline. A new offline software development kit (SDK) helps developers create solutions that provide functionality even when a connection to the server is not available.

Smart Navigation

No

Yes

Each organization has its own way of using CRM. You can now easily define the layout of the left navigation pane in Microsoft Dynamics CRM 4.0 so that it exposes only the functionality that your users need. Access to navigation items is role-based, so that users can focus on items that are relevant to their job.

E-Mail Smart Matching

No

Yes

Tracking correspondence is now easier than ever before with tracking enhancements in Microsoft Dynamics CRM 4.0. E-mail smart matching evaluates the incoming messages and automatically matches them with the appropriate conversation, without a visible tracking token. This capability streamlines communications, helping you improve customer response and build loyalty.

Asynchronous Plugins

No

Yes

The plug-in model supports asynchronous in addition to synchronous events. Previous callouts only supported synchronous methods. But Microsoft Dynamics CRM 4.0 plug-ins can be configured as asynchronous events that can occur after the platform call.

Event Framework Plug-ins

No

Yes

A new event framework in Microsoft Dynamics CRM 4.0 makes it easier to extend the capabilities of Microsoft Dynamics CRM with custom code components, called plug-ins, that are dynamically registered and run inside the CRM application. Close integration between custom code and the CRM application makes it easier for
developers to create streamlined solutions quickly. Plug-ins can also be configured to execute while working offline, making it easier to provide customizations that benefit both online and offline users.

Templates

No

Yes

MSCRM 4.0 contains the following out of box templates
- Article Templates
– Contract Templates
– E-Mail Templates

Integration with Office Communicator

No

Yes

Integration with Microsoft Office Communications Server empowers quick communication and collaboration. Users can now see who is online or offline, free or busy, and launch a Microsoft Office Communicator session without leaving Microsoft Dynamics CRM 4.0. This makes it even easier for teams to work together quickly whether they’re in the same office or different geographical regions.

New Deployment Wizards, which include bulk importing of users from Active

Directory

No

Yes

Microsoft Dynamics CRM 4.0 improves administrator productivity by streamlining the process for adding users. New users can now be created in bulk. Tasks such as importing userinformation from the Microsoft Active Directory directory service, setting user roles, andassigning licenses can all be automated, greatly reducing the time and effort required tocreate new users and freeing up administrators to do other work.

Email Topology changed to support more multiple choices of email

routing

No

Yes

Microsoft Dynamics CRM 4.0 offers a broad range of choice for e-mail platforms. Native support for Exchange Server ensures seamless e-mail integration, and extends powerfulfeatures of Exchange Server to provide a richer e-mail experience. Support for POP3 andoutbound SMTP allow Microsoft Dynamics CRM 4.0 to support diverse business scenarios.

Multiple ways to Authenticate

No

Yes

Microsoft Dynamics CRM supports multiple authentication models. The type of authentication interface that is used depends on if you are authenticated through Microsoft Dynamics CRM Online, on-premise, or Internet-facing deployment (IFD).
1. Microsoft Dynamics CRM Online – authentication is handled through Windows Live, which was previously known as Passport.
2. Microsoft Dynamics CRM 4.0, on-premise – authentication is handled through Active Directory, which is also known as Windows Integrated Authentication.
3. Microsoft Dynamics CRM 4.0, IFD – Forms based authentication, handled through Active Directory.

New Data Mapping features

No

Yes

The data maps are used to map source data that is contained in the comma-separated values (CSV) source files to Microsoft Dynamics CRM entity attribute types. You have to map a column in the source file to an appropriate Microsoft Dynamics CRM entity attribute by using column mapping or complex transformation mapping. The data in the unmapped columns is not imported during the data migration operation. Data migration also includes owner mapping, notes and attachments, and complex transformation mapping in which data can be modified before migration.

Direct External Interface into Dynamics CRM without a required VPN

No

Yes

Microsoft Dynamics CRM 4.0 allows mobile or travelling users access to the CRM system using the Microsoft Office Outlook client over the Internet without requiring a Virtual Private Network (VPN) connection. The revolution in portable computing has created new challenges to IT departments seeking to give mobile users more secure access to resources. The new Internet Facing Deployment capability in Microsoft Dynamics CRM 4.0 makes it easier for organizations to configure on-premise servers to be accessed over the Internet, reducing the burden on IT. Users can now access Microsoft Dynamics CRM using their Outlook client over hypertext transfer protocol
(HTTP) using Sockets Layer (SSL) from home or while travelling without requiring a VPN connection.

Pop3 Support/Exchange 2007 Support (64 bit)

No

Yes

Microsoft Dynamics CRM 4.0 allows organizations to choose from a wide range of e-mail platforms. In Microsoft Dynamics CRM 4.0, the e-mail router supports POP3 e-mail stores as well as Microsoft© Exchange Server, giving administrators and users greater choice of e-mail technologies. Microsoft Dynamics CRM 4.0 also provides full support for Microsoft© Exchange Server 2007.

Diagnostic Tools in the Outlook for CRM client

No

Yes

Microsoft Dynamics CRM 4.0 gives administrators superior visibility into the functioning of system and workflow processes as well as new diagnostic tools for Microsoft Office Outlook. Some Microsoft Dynamics CRM tasks require longer processing and time to execute than others. Customers requested better monitoring of these processes so they could gain greater visibility into the ongoing performance of Microsoft Dynamics CRM. Microsoft Dynamics CRM 4.0 adds process status viewers that allow administrators to monitor the functioning of asynchronous processes; including data imports, workflows, and duplicate checking. New Outlook diagnostics also make it easier to troubleshoot end-user problems. An administrator can view information about the functioning of the Microsoft Dynamics CRM client, including network connectivity, connection quality, user role, credentials, and synchronization status.

More flexible licensing options such as device versus user CALs

No

Yes

Microsoft Dynamics CRM 4.0 introduces new options that let you match your licensing agreement with your buying criteria and deployment preferences. Every business has different needs and different ways of using CRM. Since the release of Microsoft Dynamics CRM 3.0, we’ve enhanced our licensing model better match how different companies use Microsoft Dynamics CRM. The new device CAL allows organizations to license Microsoft Dynamics CRM on a per-device basis rather than a per-user basis. This can help organizations save money in scenarios, such
as call centers, where multiple users access Microsoft Dynamics CRM using the same device. Many organizations have users who require access to Microsoft Dynamics CRM data but don’t need the full functionality of the solution. For example, analysts may need to use CRM data to make sales projections, even though they don’t usually work inside the Microsoft Dynamics CRM system. The new limited use CAL gives these workers read-only access to Microsoft Dynamics CRM data at a reduced price, enabling organizations to make better use of Microsoft
Dynamics CRM while reducing costs. Many companies are gaining additional value from their Microsoft Dynamics CRM data by making that data available to external systems. For example, an organization might want to expose select data on an external partner, customer, or distributor portal. In order to make it easier for companies to do this, the price of theexternal connector license has been reduced for Microsoft Dynamics CRM 4.0.

Multi-criteria email tracking. Email tracking token can be turned

off

No

Yes

E-mail tracking has been improved in Microsoft Dynamics CRM 4.0 to provide a seamlessuser experience with greater flexibility. E-mail tracking in Microsoft Dynamics CRM 3.0

enables users to track e-mails related to their customers, accounts, contacts. For example, a

salesperson may wish to track responses to customer e-mails related to a particular sales

campaign. This feature has been enhanced in Microsoft Dynamics CRM 4.0 to provide easier and

more flexible tracking options, including automatic tracking and bulk selection of e-mails

for tracking. E-mail tracking no longer requires a tracking token. Instead, e-mails can be

tracked based on a variety of criteria, including subject, sender, and recipient. Users can

customize these settings to match their needs so that important e-mails are tracked

automatically. This enables them to be more efficient in their work and gain better

visibility into customer interactions.

Data Migration Manager

No

Yes

Data Migration Manager, which can be used to migrate data from another customerrelationship management system to Microsoft Dynamics CRM.

Organization Import Wizard

No

Yes

Move Microsoft Dynamics CRM 4.0 organizations to other servers with the new Organization Import Wizard. This wizard allows a new organization to be created in your development environment and easily ported to your production environment. When you upgrade server farms, you can quickly import your existing CRM environments to the new farm, as well as import an organization from any domain in the Microsoft Active Directory® forest. The Organization Import Wizard allows you to keep current users, or map users in the new domain to your imported organization, saving you from manually managing user migration.

Enhanced Performance

No

Yes

Microsoft Dynamics CRM 4.0 delivers several new and improved technologies that boost application performance and help accelerate your business. CRM has been tuned for etter performance in wide area network (WAN) environments, transferring only the data t hat needs to be transferred over slow connections. Microsoft Dynamics CRM 4.0 now uses asynchronous processing for bulk transactions and other long-running tasks,
minimizing the impact on other core business applications. The e-mail router also upports parallel processing of inboxes and improves support for enterprise deployment scenarios, providing a more reliable and responsive end-user experience.

Component Scalability

No

Yes

Because each business uses the CRM application differently, organizations can elect to cluster CRM application services together to match their usage needs. For example, one organization may make heavy use of workflow, while another may have large data imports.Clustering the components and services your business uses most, to match your business needs,improves scalability and improves the responsiveness of your CRM application.

System Job Monitor

No

Yes

Microsoft Dynamics CRM 4.0 gives administrators superior visibility into system and data management jobs. Process status viewers enable administrators to efficiently monitor the functioning of asynchronous processes including data imports, workflows, and duplicate checking. This keeps administrators better informed as to the functioning of the CRM system and makes it easier to diagnose issues.

Advanced Workflow expressions AND Triggers

No

Yes

Workflow additions and enhancements help eliminate limitations so companies and end users can create a wide range of sophisticated automation solutions. The scope of workflow has been expanded to include more events and entities, workflow expressions now include support for transverse relationships, and improved branching conditions make workflows more flexible. Workflows can be triggered automatically when a data value or
flag reaches a specific level. The end result is a workflow platform and tool set for sophisticated and intelligent modeling of business processes.

Workflow Accessibility

No

Yes

End users can access workflow functionality in Office Outlook or through the Microsoft Dynamics CRM 4.0 Web client, giving them broader access to business automation tools. Workflows can be published to a shared workflow library for thers to find and use. This enables users to capture and share their business processes with
others without requiring the intervention of an IT professional.

Campaign Automation

No

Yes

Campaigns are streamlined in Microsoft Dynamics CRM 4.0 so that users can create, launch, and complete campaigns more quickly and with fewer clicks. When a user creates a campaign, they can send campaign e-mail messages and close campaign activities automatically. Automating these manual tasks helps users spend less time
on manual processes.

Activity Synchronization

No

Yes

All activity types in Microsoft Dynamics CRM 4.0 can be synchronized with Microsoft Exchange Server, making it easier for users and organizations to track their work. This allows users to track CRM activities, such as phone calls or letters, in addition to tracking e-mail messages, tasks, and other Exchange Server activities.
This helps unify activities in one place so that users can work more productively.