Tuesday, January 18, 2011

Static Constructor in C#

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.

Properties of Static Constructor:
  1. Static constructor can't have access modifiers like Public,Private, Protected.
  2. It does not accept parameters.
  3. A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.
  4. A Static constructor can be called directly.
  5. Static constructor can only access static members.
  6. The user has no control on when the static constructor is executed in the program.

Ex:

public class MYStaticClass
{

  // Static constructor:

  static MYStaticClass()
  {
   System.Console.WriteLine("Static constructor called.");
  }

  public static void StaticMethod()
  {
   System.Console.WriteLine("StaticMethod is called.");
  }
}



class TestClass
{
  private void Test()
  {
   // Call to static method.
   MYStaticClass.StaticMethod();

  }

}




//Output:
//Static constructor called.
//StaticMethod is called.



Regards,

Mahesh Bagul

Sunday, January 16, 2011

Vehicle Tracking System in Pune, India

Remote Data Exchange,Pune,India provides GPS based Vehicle Tracking, Personal Tracking solutions.


GPS based Vehicle Tracking System offers an unique way for companies and individuals to monitor and control their cars, jeeps, trucks and other vehicles.  Vehicle Tracking  is applicable in following areas:

  1. Fleet Management
  2. Call Center´s, BPO´s
  3. Courier Services
  4. Public Transport Systems
  5. Taxi and Cool Cab Services
  6. Cash/Jewellery Carrying Vans
  7. Railways
  8. Goods Carrier Companies 
  9. Oil Tankers
  10. Milk Vans
  11. Car Rental and Leasing companies
  12. School Vans
Remote Data Exchange is reputed Vehicle Tracking Company in Pune ,India

Remote Data Exchange,Pune,India provides GPS based Vehicle Tracking, Personal Tracking solutions all over India.

Contact Remote Data Exchange for enquiry.

Address:
Remote Data Exchange,
A1-402, Mahalaxmi Nagar, Mumbai-Bangalore Highway,
Warje, Pune 411 058, Maharashtra, India.

Call:
Mr.Tushar S. Wakde

+91 98224 36151 
+91 20 64700247
Email: tushar@rdxindia.net

Tuesday, January 11, 2011

Learn Expression Blend in 5 days

Hi Friends,

Microsoft provides a very good training session for Expression Blend. Click following link:

Learn Expression Blend in 5 days



Keep smiling

Mahesh Bagul

Wednesday, January 5, 2011

How to install assembly in GAC

Hi friends,

Follow following steps to install assembly in GAC (Global assembly cache) using C# VS 2005/2008 .


  1. In Visual Studio, create a new Visual C# Class Library project, and name the project TestGAC.
  2. To install assembly in GAC, assembly should be strong name. We use SN tool to generate cryptographic key pair. This tool is located in the \bin subdirectory where the .NET Framework Solution Developer Kit (SDK) is installed. Or eaiser way is:
    • In Solution Explorer, right-click GACDemo, and then click Properties.
    • Click the Signing tab, and then click to select the Sign the assembly check box.
    • In the Choose a strong name key list, click .
    • Type Mykey.snk
    • Compile the project.
3.Now you can install your assembly using Gacutil tool.

Ex: gacutil -I "[DriveLetter]:\[PathToBinDirectoryInVSProject]\TestGAC.dll"



That's it.Your assembly is in GAC....

Keep smiling..
Keep programming...

Mahesh Bagul
 
  1. http://support.microsoft.com/kb/815808
  2. http://support.microsoft.com/kb/315682

( Mahesh Bagul )
 Sr. Software Eng. Pune, India.

useful Links:

Monday, January 3, 2011

Global Assembly Cache

The GAC (Global Assembly Cache) is a machine wide cache that contains the assemblies that are shared by multiple applications.
The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.
Install assembly in GAC only if required.

GAC is used in the following situations:
  1. If the application has to be shared among several applications.
  2. If assembly has special security requirement.
There are two ways to deploy an assembly into the global assembly cache:
  1. Use utility called as "Global assembly cache tool (Gacutil.exe), provided by Windows Software Development Kit (SDK)
  2. Use an installer designed to work with GAC.
Requirement to install assembly in GAC.
  • Assembly should be Strongly named.
  • Assembly residing in the GAC must adhere to a specific versioning scheme which allows for side-by-side execution of different code versions.

That's it for now.

Keep smiling.....
Keep programming......

Regards,

Mahesh Bagul

( Mahesh Bagul )
Sr.Software Engineer
Pune, India