Friday, December 22, 2006

C#: Random selection of elements in a list, with no repeats

Following code snippet shows how we can randomize selection of element in a list in effective manner:

System.Collections.Generic.List intList = new System.Collections.Generic.List();
intList.Add(1);
intList.Add(2);
intList.Add(3);
intList.Add(4);
intList.Add(5);

int size = intList.Count;
while (size>0)
{
size--;
int index = (new Random()).Next(0,size);
int elem = intList[index];
intList[index] = intList[size];
Console.WriteLine(elem.ToString());
}

Monday, December 18, 2006

Scala: A new programming paradigm

Scala is a modern multi-paradigm programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages.

Following are the highlights of this new language:
  • Object Oriented
  • Functional
  • Statically (strongly) typed
  • Extensible
  • Integration with .NET and Java Platforms
  • Built-in excellent pattern matching for Strings as well as other types like XML.
Please also read:
Why does the world need another programming language?

Thursday, December 14, 2006

Regex for atleast one alphabet and one number in string


This above Regular Expression uses Positive look ahead and Positive look behind to validate the conditions.

Wednesday, December 13, 2006

Perl: Free SQL Dependency Tracker

I am very impressed with RedGate SQl Depenency Tracker . This tool helped me lot in performing impact analysis of database object changed. Following Perl script is crude version of this tool. For given database object, it tracks dependent Stored Procedures, Functions, Views and Triggers drilled down to 3 levels. The only problem with this script it requires ODBC connection to Database.


#!/usr/bin/perl
use strict;
use DBI;

my $dbh = DBI->connect( "DBI:ODBC:localhost", 'sa', 'sa', { PrintError => 0 } );
die "Unable for connect to server $DBI::errstr"
unless $dbh;

my $search_object = $ARGV[0];

my $query = qq {
SELECT Name FROM dbo.sysobjects WHERE Xtype in ('P', 'FN', 'IF', 'V', 'TR', 'TF')
};

#print "Executing query: $query\n";
my $sth = $dbh->prepare($query)
or die "Couldn't prepare statement: " . $dbh->errstr;

$sth->execute or die "Couldn't execute statement: " . $sth->errstr;

my @object_array;
my %dbobjects;
while ( my @row = $sth->fetchrow_array ) {
if ( $row[0] !~ /^(dt_sys)/ ) {
push @object_array, $row[0];

}
}
$sth->finish;

foreach my $object (@object_array) {
my $text_query = qq {sp_helptext $object};
my $sth = $dbh->prepare($text_query)
or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->execute or die "Couldn't execute statement: " . $sth->errstr;
my $text = '';
while ( my @row_text = $sth->fetchrow_array ) {

foreach (@row_text) {
$_ =~ s/--.*$//;
$text .= $_;
}

}
$text =~
s#/\*[^*]*\*+([^/*][^*]*\*+)*/("(\\.[^"\\])*"'(\\.[^'\\])*'.[^/"'\\]*)#defined $2 ? $2 : ""#gse;
$text =~ s/create.*?AS//msgi;
$dbobjects{$object} = $text;
$sth->finish;

#print $text, "\n--------------------------------------\n";
}

my @Level1 = FindDepenency($search_object);
foreach (@Level1) {
print $_, "\n";
my @Level2 = FindDepenency($_);
foreach (@Level2) {
print "------$_\n";
my @Level3 = FindDepenency($_);
foreach (@Level3) {
print "\t\t------$_\n";
}
}
}

sub FindDepenency {
my $key = shift;
my @return_arr;
foreach my $dbo ( keys %dbobjects ) {
next if ( lc($dbo) eq lc($key) );
if ( $dbobjects{$dbo} =~ /$key/msig ) {
push @return_arr, $dbo;
}
}
return @return_arr;
}

# Disconnect the database from the database handle.
$dbh->disconnect;

Thursday, December 07, 2006

Perl: Finding duplicate files

Sometimes we need to track duplicates files (same file with different name or path) in directory hierarchy. Following PERL script finds duplicate file in given directory.


#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
use Digest::MD5;

###########################################################

# find_dups(@dir_list) -- Return an array containing a list
# of duplicate files.
###########################################################
sub find_dups(@)
{
# The list of directories to search
my @dir_list = @_;

# If nothing there, return nothing
if ($#dir_list < 0) {
return (undef);
}

my %files; # Files indexed by size

# Go through the file tree and find all
# files with a similar size
find(sub {
-f &&
push @{$files{(stat(_))[7]}}, $File::Find::name
}, @dir_list
);

my @result = (); # The resulting list

# Now loop through the list of files by size and see
# if the md5 is the same for any of them
foreach my $size (keys %files) {
if ($#{$files{$size}} < 1) {
next;
}
my %md5; # MD5 -> file name array hash

# Loop through each file of this size and
# compute the MD5 sum
foreach my $cur_file (@{$files{$size}}) {
# Open the file. Skip the files we can't open
open(FILE, $cur_file) or next;
binmode(FILE);
push @{$md5{
Digest::MD5->new->addfile(*FILE)->hexdigest}
}, $cur_file;
close (FILE);
}
# Now check for any duplicates in the MD5 hash
foreach my $hash (keys %md5) {
if ($#{$md5{$hash}} >= 1) {
push(@result, [@{$md5{$hash}}]);
}
}
}
return @result
}

# my @dups = find_dups(@ARGV);
my @dir = ('C:\tmp');
my @dups = find_dups(@dir);

foreach my $cur_dup (@dups) {
print "Duplicates\n";
foreach my $cur_file (@$cur_dup) {
print "\t$cur_file\n";
}
}

Tuesday, December 05, 2006

Video of Lifetime

This is video of a lifetime...http://www.metacafe.com/watch/277085/everyone_must_see_this/

lyrics -

Everybody's free to use sunscreen....Ladies and Gentlemen of the class of ’99 If I could offer you only one tip for the future, sunscreen would beit. The long term benefits of sunscreen have been proved byscientists whereas the rest of my advice has no basis more reliablethan my own meanderingexperience…I will dispense this advice now. Enjoy the power and beauty of your youth; oh nevermind; you will notunderstand the power and beauty of your youth until they have faded.But trust me, in 20 years you’ll look back at photos of yourself andrecall in a way you can’t grasp now how much possibility lay beforeyou and how fabulous you really looked….You’re not as fat as youimagine. Don’t worry about the future; or worry, but know that worrying is aseffective as trying to solve an algebra equation by chewingbubblegum. The real troubles in your life are apt to be things thatnever crossed your worried mind; the kind that blindside you at 4pmon some idle Tuesday. Do one thing everyday that scares you Sing Don’t be reckless with other people’s hearts, don’t put up withpeople who are reckless with yours. Floss Don’t waste your time on jealousy; sometimes you’re ahead, sometimesyou’re behind…the race is long, and in the end, it’s only withyourself. Remember the compliments you receive, forget the insults; if yousucceed in doing this, tell me how. Keep your old love letters, throw away your old bank statements. Stretch Don’t feel guilty if you don’t know what you want to do with yourlife…the most interesting people I know didn’t know at 22 what theywanted to do with their lives, some of the most interesting 40 yearolds I know still don’t. Get plenty of calcium. Be kind to your knees, you’ll miss them when they’re gone. Maybe you’ll marry, maybe you won’t, maybe you’ll have children,maybeyou won’t, maybe you’ll divorce at 40, maybe you’ll dance the funkychicken on your 75th wedding anniversary…what ever

Regex for Good and bad values


Above regex matches GOOD and doesnot match if string contains BAD.

Thursday, November 23, 2006

SQL: Using while loop for replacing cursor

Following SQL code snippet shows how we can use while loop :


create table #t (pk_counter int identity(1,1), pk_subquestion int, fk_question int, subquestion_text varchar (500), subquestion_type varchar (50), subquestion_order varchar(50), required_flag bit)

declare @counter int
declare @maxcount int
declare @subquestionid int
select @maxcount = count(pk_counter) from #t
set @counter = 1


while (@counter < @maxcount + 1) begin select @subquestionid=pk_subquestion from #t where pk_counter=@counter exec stp_get_options @subquestionid set @counter = @counter + 1 end
drop table #t

SQL: Finding duplicate rows in table

Following SQL code snippet demonstrates finding duplicate rows in table:

SELECT SampleDescription,
COUNT(SampleDescription) AS Occurance
FROM SchedTimeOffType
GROUP BY SampleDescription
HAVING ( COUNT(SampleDescription) > 1 ) order by Occurance desc

Tuesday, November 07, 2006

SQL: Recursive Select Variable

Using this method we can convert a vertical list into horizontal list. Atleast two uses are suggested by Paul Nielson:
  1. Denormalizing a list
  2. Dynamic Cross tabs query

In following example we will see how can we denormalize a list i.e. converting a vertical list into horizontal list.

use NorthWind;
DECLARE @Name nvarchar (2200)
SET @Name = ''
SELECT @Name = @Name + A.Name + '; ' FROM (Select DISTINCT CompanyName AS Name FROM Customers) AS A
PRINT @Name

Thursday, November 02, 2006

Getting Caller Function Name

Sometimes it would be great to know which is the caller function for the current executing function for debugging purpose. Following code snippet shows how to get caller function name:

StackTrace stackTrace = new StackTrace();
StackFrame stackFrame = stackTrace.GetFrame(1);
MethodBase methodBase = stackFrame.GetMethod();
Console.WriteLine(methodBase.Name);

Wednesday, August 23, 2006

C#: Event Model and Observer pattern

Observer pattern can be made easily using C# multicast deletgates. We will define two classes Publisher and Subscriber. Publisher is the class which publish the 'event'. Subscriber class subscribes the event and whenever event is called, subscriber is notified. Subscriber can have function which can be invoked in response to event. This function is called event handler. Publisher-Subscriber model can be built on two methodologies - Pull and Push.
In Pull, subscriber has permission to 'see' data/state of Publisher.
In Push, Publisher notify subscriber with only most relevant data/state. Here I am going to implement Push Model.


//Code
       public class Publisher2
{
// EventHandler delegate is defined .NET as
// public delegate void EventHandler (object obj, EventArgs e);
public event EventHandler onTick;

private void NotifyOnTick(EventArgs e)
{
if (onTick != null)
{
onTick(this, e);
}

}

public void StartClock()
{
int tick = 1;
while (tick <= 10) { System.Threading.Thread.Sleep(1000); NotifyOnTick(new MyEventArgs(tick));
tick++;
}
}

}

public class MyEventArgs : EventArgs
{
private int tick;
public int Tick
{
get { return this.tick;}
}

public MyEventArgs(int tick)
{
this.tick = tick;
}

}

public class Subscriber2
{
private int subsriberID;
public Subscriber2(Publisher2 publisher, int id)
{
this.subsriberID = id;
publisher.onTick += new EventHandler(this.DisplayOnTick);
}
public void DisplayOnTick(object obj, EventArgs e)
{
Console.Write("Subscriber [{0}]: ", this.subsriberID);
MyEventArgs me = e as MyEventArgs;
Console.WriteLine(me.Tick.ToString());
}
public void Unsubscribe(Publisher2 publisher)
{
publisher.onTick -= new EventHandler(this.DisplayOnTick);
}
}


class Class1
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{

Publisher2 publisher = new Publisher2();
Subscriber2 sbc1 = new Subscriber2(publisher,1);
Subscriber2 sbc2 = new Subscriber2(publisher,2);
publisher.StartClock();
sbc2.Unsubscribe(publisher);
publisher.StartClock();
}
}
//Output
Subscriber [1]: 1
Subscriber [2]: 1
Subscriber [1]: 2
Subscriber [2]: 2
Subscriber [1]: 3
Subscriber [2]: 3
Subscriber [1]: 4
Subscriber [2]: 4
Subscriber [1]: 5
Subscriber [2]: 5
Subscriber [1]: 6
Subscriber [2]: 6
Subscriber [1]: 7
Subscriber [2]: 7
Subscriber [1]: 8
Subscriber [2]: 8
Subscriber [1]: 9
Subscriber [2]: 9
Subscriber [1]: 10
Subscriber [2]: 10
Subscriber [1]: 1
Subscriber [1]: 2
Subscriber [1]: 3
Subscriber [1]: 4
Subscriber [1]: 5
Subscriber [1]: 6
Subscriber [1]: 7
Subscriber [1]: 8
Subscriber [1]: 9
Subscriber [1]: 10

Tuesday, August 22, 2006

C#: Interface as a subclass of Interface

Following code snippet shows how a Interface can have a Interface as a subclass.

public interface Class1
{
void Display(string str);
}

public interface Class2 : Class1
{
void DisplayInt(int i);
}

public class Class3 : Class2
{
// Must be implemented, even though
// its base class interface doesn't declare this method
public void Display(string str)
{
Console.WriteLine(str);
}
public void DisplayInt(int i)
{
Console.WriteLine(i.ToString());
}
}


public class MyClass
{
public static void Main()
{
Class1 c = new Class3();
//c.DisplayInt(2); // Will work only when Class3 c = new Class3();
c.Display("for tango");
}
}
//ouput
for tango

Casting in C#

In C#, there is two ways to explicitly cast an object:
  1. Using casting operator ()
  2. Using as keyword
Following code snippet conveys 3 important points:
  1. If no constructor is specified in subclass constructor, default constructor of base class is called. So parent class should either have no constructor or should must have default constructor defined if it has other overloaded constructors.
  2. Casting using casting operator throw exception if type is mismatched
  3. Casting using 'as' keyword make object null if type is mismatched
//Code
public class A
{
public A(){Console.WriteLine("Instance of A is created.");}
public A(string str){Console.WriteLine("Instance of A is created with string: " + str);}
}

public class B : A
{
public B(){Console.WriteLine("Instance of B is created.");}
public B(string str)
{
// Automatically calls default constructor
Console.WriteLine("Instance of B is created with string: " + str);
}
}

public class C : B
{
public C(){Console.WriteLine("Instance of C is created.");}
public C(string str) : base(str)
{
// Base Class Constructor B(str) is called
Console.WriteLine("Instance of C is created with string: " + str);
}
}


public class MyClass
{
public static void Main()
{
C c2 = new C("ashish");
A a = new C();
B b = (B) a;// if (ais B) stat.type(a) is Bin this expression; else exception
C c = (C) a;
a = null;
c = (C) a;// ok ..null can be casted to any reference type
A a1 = new A();
//C c1 = (C)a1; // Generates exeception
C c1 = a1 as C;
if (c1 == null) Console.WriteLine ("c1 is null"); // print c1 is null


}
}

// Output of above code
Instance of A is created.
Instance of B is created with string: ashish
Instance of C is created with string: ashish
Instance of A is created.
Instance of B is created.
Instance of C is created.
Instance of A is created.
c1 is null

Thursday, July 27, 2006

Important .NET Command Line tools

Assembly Linker

The Assembly Linker generates a file with an assembly manifest from one or more files that are either modules or resource files. A module is a Microsoft intermediate language (MSIL) file that doesn't have an assembly manifest. All Visual Studio compilers produce assemblies. However, if you have one or more modules (metadata without a manifest), you can use Al.exe creates an assembly with the manifest in a separate file.

Examples

Following examples shows a delay sigining using Assembly Linker

Al.exe Sample1.netmodule, Sample2.netmodule /delaysign+ /Keyfile:SamplePublicKey.snk /out:SignedSample.exe

-------------------------------------------------------------

Installer tool

Installutill.exe is used to install the assemblies which contain additional component resources. This tool works in conjunction with classes in System.Configuration.Install namespace. This tool performs installation in the transactional manner. If one of the assemblies fails to install, it roll backs the installation of all the assemblies. For example, this tool can be used when installing a window service.

Examples

To install the resourse in assembly Assembly1.dll, you need to execute the following command:

Installutil.exe Assembly1.dll

-------------------------------------------------------------

Native Image Generator

The Native Image Generator creates a native image from a managed assembly and installs it into the native image cache on the local computer. The native image cache is a reserved area of the GAC. Once you create a native image for an assembly, the runtime automatically uses that native image each time it runs the assembly.

Examples

Following example create native image of C:\MyApplication\bin\Assembly1.dll in current native image cache.

Ngen.exe /silent C:\MyApplication\bin\Assembly1.exe

Following examples create native image for assembly which directly reference to other assemblies. You must supply fully specified names of the references assemblies. ILDASM.EXE tool can be used to get fully specified assembly name.

Ngen.exe Assembly1.exe "myLibOne, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0038abc9deabfle5", "myLibTwo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0038abc9deabfle5"

-------------------------------------------------------------

Assembly Binding Log Viewer

Fuslogvw.exe tool display details for assembly bind. This information is very useful in case of failure in loading assembly due to location/culture mismatch.

Example

fuslogvw.exe

-------------------------------------------------------------

GacUtil

This command line utility is useful for adding/removing the assemblies from GAC in the automated environment.

Example

Following example list all the assemblies in GAC

Gacutil.exe /l

Following example uninstall assembly from GAC

Gacutil.exe /u RandomNumberGenerator

Following example uninstall a specific version and culture of assembly from GAC

gacutil /u hello, Version=1.0.0.1, Culture="de",PublicKeyToken=45e343aae32233ca

Following example install list of assemblies from a file

gacutil /il assemblyList.txt

---------------------------------------------------

Type Library Importer

COM components do not have manifest file embedded in assembly itself, instead meta data is stored in separate Type Library. A type library can be a separate file or it can be embedded within another file. Type Library Importer tool (tlbimp.exe) can make a RCW component from meta data stored in Type Library.

Example

Tlbimp.exe MyCustomerCOM.dll /out:MyCustomerNET.dll

---------------------------------------------------

DISCO.EXE

The Web Services Discover Tool (disco.exe) retrieves the discovery document if the web services includes a static discovery document (.disco file). The .disco file is an XML file containing useful URLs. These include the URL for the WSDL file describing the service, the URL for the documentation of the service, and the URL to which SOAP messages should be sent.

Example

disco.exe http://localhost/MyWebservice/service1.asmx /out:MyWebSerDocs

It generates two files, first is service1.wsdl and other is results.discomap. Wsdl is a XML file which contains description of interfaces of web services.

---------------------------------------------------

WSDL.EXE

This tool is used to generate web proxy class from wsdl file. In can be understand in this way that output of disco.exe is input of wsdl.exe.

Example

Wsdl.exe service1.wsdl

Wsdl.exe results.discomap

---------------------------------------------------

Continue...

Friday, July 21, 2006

Pros and Cons of DataBinder.Eval()

Although DataBinder.Eval() function is very easy to use, it imposes performance penality due to late binding. This can be avoided using explicit casting. Following code snippet shows both the approaches:

Using DataBinder:
<%# DataBinder.Eval(Container.DataItem, "TotalAmount", "{0:n}" %>

Using Explicit Casting:
<%# String.Format("{0:n}", ( (DataRow)(Container.DataItem))["TotalAmount"]) %>

Tuesday, July 18, 2006

SSW Code Audit Tool

Got chance to play with this cool tool for code review.
Here is my feedback:

Features:

· Visual Studio Plug-in

· SSW works on source code directly unlike to FXCop which works on assembly. In this way, rules can be run on any type of text file like html, sql, xml, ascx, aspx, etc.

· Easily extensible – New rules can be added using Regular expressions(Tested)/Wild Cards (Tested)/ Xml Validate (not tested)/ Visual C#/VB.NET Code (not tested)

· Support for testing rules in tool itself before activating the rule

· Rules Exception – You can define exception conditions for particular rule

· Command Line/Batch File options to automate the review process

· Built-In Email and Scheduling options

· XML Output with default XLST file to provide Online Report. Report can be changed into different formats like By rules, By Files, By Ignored Files etc.

· SSW has rich rule repository. Rules can be categorized for particular needs:

1. ASP.NET – Migration Rules

2. C#/VB.NET UI & Code Rules

3. File Rules

4. Image Rules

5. Report/Reporting Service Rules

6. TEXT Rules

7. Web Rules

Down Sides:

  1. Although there is online knowledgebase, proper documentation is not available
  2. No support for Peer review like Jupiter Plug-in for Eclipse


Wednesday, July 12, 2006

Javascript - Converting m/d/yy date to mm/dd/yyyy using regular expressions

Following Javascript code snippet can be used to convert m/d/yy date to mm/dd/yyyy

var objtxtDate = document.getElementById("textboxDate");
var regex = /^\d{1,2}\/\d{1,2}\/\d{1,2}$/;
if (objtxtShipDate.value.match(regex))
{
var dateArr = objtxtShipDate.value.split("/");
var regex1 = /^(\d)$/; // for dd and mm
var regex2 = /^(\d\d)$/; // for yy

dateArr[0] = dateArr[0].replace(regex1, "0$1");
dateArr[1] = dateArr[1].replace(regex1, "0$1");

var now = new Date();
var year = now.getYear();
if(year < 2000) { year = year + 1900; }
var currentYear = year + '';
var regexYear = /^(\d\d)\d\d$/;
currentYear = currentYear.replace(regexYear, "$1");

dateArr[2] = dateArr[2].replace(regex2, currentYear + "$1");
objtxtDate.value = dateArr.join("/");
}

Tuesday, July 04, 2006

C# Late Binding

In Object Oriented Programming, Polymorphism allows programmers to have same interface for different type of Objects. Depending upon the type of object, interface produces different results.

This is called late-binding. In C#, it is achieved by combination of virtual functions, derived classes, and with 'new' & 'override' keywords.


using System;

public class Parent
{
public virtual void Print()
{
Console.WriteLine ("
This is parent class");

}

public virtual void Print2()
{
Console.WriteLine ("
Print2: This is parent class");

}

}

public class Child : Parent
{
public override void Print()
{
Console.WriteLine ("
This is child class");
}

public new void Print()
{
Console.WriteLine ("
Print2: This is child class");
}

}

public class MyClass

{

public static void Main()
{
Parent p;
p =
new Parent();
p.Print(); p.Print2();
p =
new Child();
p.Print(); p.Print2();
}

}



Following is the output:

This is parent class
Print2: This is parent class
This is child class
Print2: This is parent class

If we use 'new' keyword instead of 'override' keyword, it doesn't override base class function but hide it from base class object.

Monday, July 03, 2006

SQL 2000 Database Recovery from Network Drive using SQL commands

In my current project, we frequently need to update our QA database with our production database. We get production database backup copy by FTP. SQL Enterprise Manager donot support recovery of database from remote file. UI only support only local backup file. Following SQL commands came as rescue:

-- Command to list database from remote drive
restore filelistonly FROM disk='\\remotemachine\DB Backup\Northwind.bak'

-- Command to recover database using this list
RESTORE Database Core FROM disk='\\remotemachine\DB Backup\Northwind.bak''
WITH
move 'Northwind_Data'
TO 'C:\Program Files\Microsoft SQL Server\MSSQL$INSTANCE2\Data\Northwind.mdf',
move 'Northwind_Index'
TO 'C:\Program Files\Microsoft SQL Server\MSSQL$INSTANCE2\Data\Northwind_1.mdf',
move 'Northwind_Log'
TO 'C:\Program Files\Microsoft SQL Server\MSSQL$INSTANCE2\DataNorthwind_log.ldf',
Partial, Recovery

Thursday, June 29, 2006

Practical Uses of .NET Reflection

New to .NET Reflection? Following are good articles to start with:
  1. Part 1
  2. Part 2
  3. Practical Uses of .NET Reflection
In short, some of .NET Reflection Practical Uses:
  • Custom Collection Sorting
  • Designing Plug-in architecture
  • Designing External tools that operates on Codes - Lutz Rodeder's Reflector, FxCop, Nunit
  • Visual Studio uses in Property Dialog
  • Examine assembly at runtimes

Thursday, June 22, 2006

CSV Engine in MySQL

MySql 5.1 has fully functional CSV Engine. This aricle nicely explains its features and practical usages.

Monday, June 19, 2006

Access Denied Exception - New Excel.Application

I was having trouble in getting Excel Application object:
objExcel = New Excel.Application

It was giving exception :

Access is denied.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.



I solved problem going through following steps:

  1. Run "dcomcnfg"
  2. Go Component Services -> DCOM Config -> Microsoft Excel Application
  3. Right Click on it and open Properties dialog.
  4. Go to security and give appropriate launch permission to \ASPNET user.

Saturday, March 11, 2006

My trip to Manali

Spectacular View of Shelang Valley. Posted by Picasa

Monday, January 16, 2006

Caching techniques in Perl

'Memoize' is very handy module available on CPAN for caching expensive operation in Perl.
Combining with 'DB_File' module, this module can be also used for persistence caching.