Tuesday, November 20, 2007

Visual Studio 2008 First Impressions

Yesterday VS.net 2008 shipped and is made available for download to MSDN subscribers. For the general public a trial edition is available for download.
For Vista users my suggestion do not use the link above and go to you subscription download page. The akamai download manager on the Top Downloads page causes all kinds of problems in Vista. The security restrictions in Vista does not allow the download manager to write to any folders even the %USERPROFILE%\Downloads folder. It virtualizes all folders to the Temporary Internet Folders. Actually I had to download twice the first time I left it download overnight it download in the virtualized folder and my nightly clean up job cleaned up the temporary folders. It took me a while to figure out why I could not find my files.
On XP actually the download is faster from the Top Downloads page then the MSDN Subscription Download Page.

Warning do not be fooled by the Team Foundation Server Trial Link(Visual Studio Team System 2008 Team Foundation Server Trial (x86 and x64 WoW) - DVD (English)). Team foundation server is not supported on a 64-bit OS. My hopes were raised looking at the name but it turned that the installer won't install on a 64 bit OS.
On my first attempt to install the Installer got stuck at last step the the SmartPhone SDK. I was not even able to cancel it just go hung. I had to kill the installer. Restart the machine and do a repair then everything installed fine.
I found a few warnings and errors in the event log which did not make much sense to me. Hopefully my install is not corrupt. I was able to upgrade an existing VS.NET 2005 project and run it.
One more weird thing that happened on my machine was the suddenly I lost 8 GB space on my hard drive and had to run the disk clean up utility which was able to recover all the 8 GB space that was filled. I am hoping that had nothing to do with the install.
I hope me bad experience with the installer is just a one of case as one my colleagues reported that he was able to install the IDE without any issues.
I am currently having second thoughts whether to install VS.NET 2008 on my Vista 64bit machine. Hopefully I will install it over the long weekend.

Wednesday, August 15, 2007

Team System 2008

Brian (VSTS Product Group Manager) in his recent post published the TFS 2008 feature list. I am very happy to see some of the features specially support for SPS 2007 and SQL reporting on any server.
My organization already deployed a SPS 2007 and SQL Reporting 2005 server farms in addition to the SQL Server 2005 farm hosting our data marts and RDBMS databases. TFS 2008 will enable us to leverage the existing infrastructure rather than build all the infrastructure from scratch. The cost of deploying/maintaining TFS 2008 will be much less than setting up a dedicated high availability environment.
The only thing I am still looking for answers is the support for 64 bit OS in TFS 2008. Unfortunately the TFS 2005 middle tier was not supported on 64 bit OS. I hope TFS 2008 will be supported on a 64 bit environment. I will try to install it on a virtual machine and see if that works.

Boxing/UnBoxing Continued

Since my last post I ran across some new questions.
1. Does boxing have a performance issue or UnBoxing?
2. In case when an int has to be concatenated with string is it better to use ToString() method.

After running some tests I have concluded.
Boxing is slower than UnBoxing and ToString() is slower than boxing. So if one cannot avoid boxing do not try to use ToString() methods they seem to be slower.

My current challenge is that I have a Winform screen with 15 drop downs and 6 grids. In order to bind the the controls I am converting strongly typed Business entities to DataTables. There are quite a few properties in the business entities which are int and DateTime resulting in boxing and impacting the performance of the screens.

Hopefully I will come up with a solution to this issue soon.

Wednesday, August 08, 2007

Boxing/Unboxing

Its been nearly three years since I last blogged and what better topic to start blogging back again than boxing/unboxing.
Most of the literature that I can find online tells me what is a boxing/unboxing operation or what are its disadvantages but none could definitively answer to the question that came up during a recent code review. Whether this code causes boxing/unboxing
class Class1
{
int i = 10;
static void Main(string[] args)
{
Class1 x = new Class1();
int a = x.i; //unboxing??
x.i= 20; //boxing??
}
}
I myself when initially came across the concept of boxing/unboxing used to think that the above code with cause box and unbox operations to be called but that's not the case. The above code does not cause boxing/unboxing.
The idea of boxing unboxing is a little little difficult to grasp and I have found lots of people(including myself) struggling with it. There is an article on type fundamentals by Jeffrey Richter which may help explain things and also there is a blog post by David Cumps which gives a nice visual explanation of boxing/unboxing
To figure out in the C# code if it has any box operation look for the following
  1. An instance of a value type is assigned to a variable/field/property of the type object
  2. An instance of a value type is cast to an instance of an object type
  3. An instance of a value type is passed to a method/property indexer which has object type as a parameter.
To figure out in C# code if it has any Unbox operation check whether an instance of a type object is being cast to an instance of a value type.
Below are the few common cases of boxing and unboxing
int j;
int i = 10; // can be any value type like float, double, Point, DateTime, structures etc.
//The standard example
object o = i; //implicit boxing
o = (object)i; //explicit boxing
j = (int)o; //unboxing
//String.Format and its variations
string.Format("Boxing {0}",i); //implicit boxing
Console.WriteLine("Boxing {0}",i);
StringBuilder strBuild = new StringBuilder();
strBuild.AppendFormat("Boxing {0}",i); //implicit boxing
//Collections
ArrayList list = new ArrayList();
list.Add(i); //implicit boxing
list.BinarySearch(i); //implicit boxing
list.IndexOf(i); //implicit boxing
list.Insert(2,i); //implicit boxing (only for i)
list.LastIndexOf(i); //implicit boxing
list.Remove(i); //implicit boxing
j = (int) list[0]; //unboxing
Hashtable coll = new Hashtable();
coll.Add(i,i); //implicit boxing(twice)
coll.Contains(i); //implicit boxing
coll.ContainsKey(i); //implicit boxing
coll.ContainsValue(i); //implicit boxing
coll.Remove(i); //implicit boxing
j = (int) coll[i]; //implicit boxing for indexer and unboxing for assignment
//DataTable
DataTable dt = new DataTable();
dt.Columns.Add("UntypedColumn");
dt.Columns.Add("IntColumn",typeof(int));
DataRow dr = dt.NewRow();
dr["UntypedColumn"] = i; //implicit boxing
dr["IntColumn"] = i; //implicit boxing
j = (int) dr["UntypedColumn"]; //unboxing
j = (int) dr["UntypedColumn"]; //unboxing

Friday, October 15, 2004

Pre-compilation in ASP.NET v1.1

Today I came across Jon Galloway’s blog entry on pre-compiling ASP.NET web applications in v1.1. I have been looking for this for a while now. I tried it on with the web application I am currently developing on my development machine (Win XP Professional).
And here are the observations.
1. The handler compiles all the aspx files in the folder irrespective whether the file is part of your project. This was very troublesome for me as on my development machine there existed old aspx files which were removed from source control but they existed on my disk.
2. If an error occurs during compilation of a page the compilations stops and no other pages are compiled. Aspx pages are not classes which refer each other I think if a error occurs on a page that page should be skipped and the next page should be compiled and the list of pages which caused errors should be generated. For each time an old aspx file (no longer used in the project) was found I had to go and delete it and wait for the next error page.
3. If an error occurs during compilation and is then corrected. Restarting the pre-compilation doesn’t work. One needs to re-start the ASP.NET worker process for the compilation to work. That’s a major issue. We cannot keep on restarting the worker process each time we encounter an error during pre-compilation.
4. The handler only compiles the aspx files (and all the ascx user controls refrenced in the aspx ) in the specified folder not in all aspx pages the in the web application. In case one is developing a large website and the aspx pages are grouped in different folders one has to go to each folder for the pages to compile.
5. In my case I had forms authentication enabled so the ways I could make pre-compilation work is to either disable forms authentication for the time I am pre-compiling or through web.config grant access to the handler in each folder. Neither can be used for production environments as changing the web.config after compilation will cause the aspx to be recompiled by the runtime. The other smart thing would be login the website and the call the pre-compile page. But none of these solutions are good enough. The handler should behave something like the debug works. I can configure whether debug information is available on remote machines or only on local machines. Similarly I should be able to configure that I can make a pre-compilation request from a remote location or from a local machine. And an authorization mechanism where I can grant access to pre-compilation easily rather then listing out each folders in which pre-compilation is allowed

Overall the handler has still some issues and is very primitive to be used in an actual production environment. I think that’s the reason the handler has not been advertised. I fell its better that I wait for the ASP.NET v2.0 and see if it is good enough to be used in a production environment.

Thursday, September 16, 2004

The Debate: Should we set the value of a variable to Null after we have no use for it

Its been a long standing debate. I have found many developers setting the value of the local variables to null at the end of the method. That never made sense why should one set the value of a variable to null which will anyway be out of scope in the next line of code and will be garbage collected. It never made sense and it never will.
But Rico Mariani in his post Mid life crisis has pointed out a scenario where setting the value of the variable that are no longer used to null can be useful. But as he pointed out it in the post it needs to be done before we pass the task to some other thread and we know the variable is dead and will not be used in later processing. To understand in detail one must go through the article in detail and check out how the .Net Garbage Collector(GC) works.
learned something really interesting and useful today.

MSDN 2 is here

Microsoft has released the beta-documentation for Visual Studio 2005. I came to know about this from Krik Allen Evans's post MSDN2 and .NET Namespace Support cool new features and a different look I really find the namespace URL feature interesting, it can be very useful.

The Revamp

Its been long I published anything on this blog. I had said in an earlier post on my non-technical blog that a revamp is needed for this blog as well as lots of content. Over the last 10 days I have been on and off trying to revamp this blog. Though I have successfully added Google Adsense for content and Google Adsense for search to my blog and gave it a new look the blog looks far from satisfactory. Actually over the last 10 days tinkering with the standard template available in blogger and trying to put in the adsense code on the pages I concluded that I need to really sit down and work on developing a new template myself. That will require some real good work with HTML currently I am not up to it. So as of now I have decided that I start publishing content and delay the UI enhancements to another revamp.
So as why I finally chose today as the day because I have two interesting things I came across which I will like to share the posts following this will discuss them But the is one resource I will like to share with my readers. http://weblogs.asp.net/stefan_gossner/archive/2003/12/07/41859.aspx

An excellent post which is a single stop for all information needed to start working with Microsoft Content Management Server. I had found it very useful during the development of the Ardh Kumbh project which runs on MCMS 2002. I really will like to congratulate and thanks Stefan for an excellent work. I hope my friend Vendanshu who has been looking for some help on MCMS will find it equally useful.


Sunday, May 30, 2004

Another excellent analogy this time on .Net Remoting

A fabulous post on Marshal-by-ref versus Serializable Objects by Eric Lippert. I need to learn how people come up with such excllent analogies and simple explanation to complex things.

re:The Fishbowl: The Mac is a Harsh Mistress

Charles Miller has really written a excellent and funny analogy comparing Mac/Microsoft/Linux. He shows good knowledge two very complex things females and computers ;).

Longhorn and Loosing your mobile phone

In a recent post I lost my girlfriends phone number. Kevin Moore is very right in saying "Loosing your phone should be a great experience, because it gives you an excuse to get a Pocket PC Phone Edition". And I really look forward to the day where I am not worried upset at loosing my address book and spending enormous amount of time trying to back it up in an excel sheet and keeping it in Sync.
His idea of a unified Address books sounds nice but I still wonder how will they make it possible in Longhorn and how much it will cost as there are many devices today which offer softwares to communicate with the PC and backup the data, but need costly data cables other communication infrastructure.

It feels good to be heard

Few days back I posted my comment to a post Why don't nullable relational operators return bool? instead of bool? on the C# Frequently Asked Questions blog. In response the comment the C# Team updated the post. Its really nice to know that you are being heard.

Friday, May 28, 2004

Some useful links

Recently a collegue of mine needed some help with Creating a Windows Service, Creating an MSI Installer and Updater Application Block for .NET. Being in the middle of a project he prefered something a simple not the boring comprehensive resources from MSDN. Having used all these in my earlier projects more that an year ago, I had a tought time then finding quality resources to help me understand exactly how to use them. MSDN Was the only good place i could find something good. But yesterday when i started searching on the net for some good stuff I was amazed to see how many new resoruces are available. I compiled a list of link which he can use. I would like to share with everybody who may be interested in these.

Updater Application Block for .NET

Downloads
http://microsoft.com/downloads/details.aspx?FamilyId=C6C17F3A-D957-4B17-9B97-296FB4927C30&displaylang=en

How-To
http://www.gotdotnet.com/community/messageboard/Thread.aspx?id=181256
http://www.gotdotnet.com/community/messageboard/Thread.aspx?id=158337
http://www.ballzac.com/updaterblock/Updater%20Application%20Block%20HOW-TO%20generic.htm

The Gotdotnet community Workspace
http://www.gotdotnet.com/Community/Workspaces/workspace.aspx?id=83c68646-befb-4586-ba9f-fdf1301902f5

The nuts and bolts
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/updater.asp
http://builder.com.com/5100-6373-5080375.html
news://msnews.microsoft.com/microsoft.public.dotnet.distributed_apps
http://www.microsoft.com/downloads/details.aspx?FamilyId=5B7C6E2D-D03F-4B19-9025-6B87E6AE0DA6&displaylang=en


Windows Service

Walkthrough
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbwlkwalkthroughcreatingwindowsserviceapplication.asp

Tutorial
http://www.c-sharpcorner.com/2/window_service.asp

History & Geography (Architecture and related stuff)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconintroductiontontserviceapplications.asp


MSI Installer in .Net

Tutorial
http://www.c-sharpcorner.com/Code/2003/April/SetupProjects.asp
http://www.devarticles.com/c/a/C-Sharp/Creating-a-.NET-Windows-Installer--Part-1/

The nuts and bolts
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vbcondeployingsolution.asp

Unfourtunately, a majority of links are still from MSDN ;)