Thursday, February 12, 2009

Global Theme Setting for 2.0 or Later.

In order to set theme globally for application. There are two ways to do that. one is longer and second one shorter way to do that.

Create App_Themes directory for each application. This is special directory. You can copy Theme over here for each application.

Put New theme under Themes directory of aspnet_clientfile directory.


If themes directory not found then create one. For example if theme name is Green then it should be like


This will work for all website that already created. In IIS6 website can be created afterwards. so for that this clientfile does not map to new site, following location must contain themes directory and required theme folder.


After that run following command from studio command prompt
> aspnet_regiis –c

Above setting works for only IIS6 or previous versino of IIS 5.

Wednesday, February 11, 2009

Kill Process On Remote Machine

It is not recommended that each and every time abort process this way but sometime it is necessary stop some process from executing on remote machine.

There are few useful command for that.

Taskkill or tskill

Run following command on command prompt.
> TaskList     ( Current system running process list)

> TaskList /S <system name>
    e.g Remote system name remote1 then
   TaskList /S remote1
   Some of the case you require to pass credential for remote pc in that case use following command.
   TaskList /S remote1 /U <username> /P <Password>
TaskList command is used to get process id that we want to kill.

To Kill process there are two command TaskKill and tskill . I prefer TaskKill over tskill as it gives more command line options.

> TaskKill /PID <process id> ( use to kill perticular process that identified by process id on local machine)

> Taskkill /S <remote pc name or IP Address> /PID <process id> ( kill process that identified by process id on remote machine)

If remote pc require credential than use

> taskkill /S < remote pc name or IP Address> /PID <process id> /U <username> /P <password>

All above command are tested on Windows XP and Windows 2003.
You must require permission to run above command in order to use functionality.

In All Above you can use IP Address instead of remote PC name.

Sunday, February 1, 2009

Difference Between Explicit And Implicit Interface Implementation

Interface can be implemented two ways. Explicitly or Implicitly.
For Example :
public interface IEmployee
         string FullName

Implicit implementation of Interface
public class ImplicitClass : IEmployee
     public string FullName
           get ;
           set ; 

Explicit implementation of Interface.
public class ExplicitClass : IEmployee
    string IEmployee.FullName
           get ;
           set ;  
Here you can see that FullName property does not have access modifier.As this is explicit implementation so it does not allow access modifier.

Now we see what happen when try to create object of both of above class.

ImplicitClass cls = new ImplicitClass();
cls.FullName = “test”;
// Above code works fine

ExplicitClass cls1 = new ExplicitClass();
cls1.FullName = “test”; // error occur

As interface implement explicitly FullName property not available directly to cl1 object b’coz it become private to the Interface type.
By reflection

ImplicitClass cls = new ImplicitClass();
PropertyInfo pinfo = cls.GetType().GetProperty("FullName");
if (pinfo != null)
     pinfo.SetValue(cls, "test",null);

ExplicitClass cls1 = new ExplicitClass();
PropertyInfo pinfo1 = cls1.GetType().GetProperty("FullName");
            if (pinfo1 != null) // pinfo1 is null in this case.
                pinfo1.SetValue(cls1, "test",null);

By reflection way also not able to set property as can no available propertyinfo.

Solution for this is , If interface implemented explicit way then cast to Interface type then set property.

ExplicitClass cls1 = new ExplicitClass();
IEmployee emp = cls1 as IEmployee;
emp.FullName = “test”;

if want to access with use of Reflection
ExplicitClass cls1 = new ExplicitClass();                        PropertyInfo pinfo1 = cls1.GetType().GetInterface("IEmployee").GetProperty("FullName");
if (pinfo1 != null)
   pinfo1.SetValue(cls1, "test",null);

Note: only choose explicit interface if needed. One such case is if your class previously has property/Event/Method that Interface has also , than to avoid conflict must need of explicit interface implementation.

Please give you further suggestion about this article.