Gokul's Blog


Leave a comment

VPC Image download from Microsoft

You don’t have to install the OS, Visual Studio &…. Now Microsoft gives us VPC which expire once in an Year.

This VPC Image contains team suite for trial period till Dec 31st 2009.

http://www.microsoft.com/downloads/details.aspx?FamilyID=c7a809d8-8c9f-439f-8147-948bc6957812&displaylang=en

Advertisements


Leave a comment

An Interesting Exception while working with Collections

I wanted to remove a set of items from a collection.

Tried to achieve it by using

foreach(var item in myObjCollection)
{
myObjCollection.Remove(obj);
}

But the above statement will throw an Exception  saying that the container cannot be modified while enumerating.

I tried to remove the item from collection as follows:

for (int i = 0; i < myObjCollection.Count; ++i) {
 myObjCollection.Remove(myObjCollection[i]);
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

 

Do you think the above statement will work?

The above for statement also throws the same exception.

The resolution to the above problem are

  1. To call myCollection.RemoveAt(0) all the time
  2. Iterate in the reverse order (Starting from myCollection.Count() –1 to 0)


Leave a comment

Implementing Tortoise SVN and Sub-version

To setup the SVN server:

Download the SVN server from http://www.visualsvn.com/server/

If you want a tight integration with Visual Studio use their Visual SVN client for $50. Which is worth every penny as it gives you an excellent integration with studio similar to source safe/team system.

Free sub-version client (Tortoise SVN):

You can download tortoise SVN from : http://tortoisesvn.tigris.org/

Once tortoise SVN is installed it integrates to windows shell. Use the settings option to set the server details, exclusion file and folder list.

Then right click and use the checkout option to get the files from the server.

To get a latest version use UPDATE

Submit changes to server use COMMIT

Some of the important links to note:

For Removing specific folders and file types: http://tortoisesvn.net/docs/nightly/TortoiseSVN_en/ch05s25.html

http://arcware.net/tortoisesvn-global-ignore-pattern-vs-svn-ignore/


Leave a comment

System.Transaction Scope

We can wrap a set of operations under a transaction scope by using System.Transaction Scope.

Checkout a nice article on how to implement this by Rob Conery: blog.wekeroad.com/blog/Using-SubSonic-Within-Transactions/

Example code as implemented by Rob:

//use the product object to test the transaction scope
using (TransactionScope scope = new TransactionScope
     try {
 
         Product p1 = new Product(1);
 
         p1.QuantityPerUnit = "10 boxes x 30 bags";
 
         p1.Save("Unit Test");
 
         Product p2 = new Product(2);
 
         p2.QuantityPerUnit = "24 - 42 oz bottles";
 
         p2.Save("Unit Test");
 
         Product p3 = new Product(3);
 
         p3.QuantityPerUnit = "12 - 5500 ml bottles";
 
         p3.Save("Unit Test");
 
         scope.Complete();
 
     } catch (System.Data.SqlClient.SqlException x) {
 
         //trap/trace/log as needed
 
         throw x;
     }
 
  }

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }