.Net blog of Sijin Joseph
My experiences with .Net
-
Cool sites discovered using Spiderous
Spiderous is a site that aggregates popular links from social bookmark managers like del.icio.us , spurl and furlHere are some great links I found todayTabs on your webpage using CSSLike to build your own systems, check out this article on advanced system buildingColor Scheme generatorFree Menu designs using CSSFade anything technique for web pagesThe state of the scripting universeA+ Freeware
-
ADO.Net connection pooling
Connections are precious commodities, and writing code to minimize the stress on the server of having too many connections open concurrently will help with overall database performance. Fortunately, ADO.NET (like its predecessors) tries to help manage those connections with a facility called Connection Pooling. Connection Pooling is the process of managing connections as shared resources that can be doled out from a pool of recently used connections. Connection pooling takes advantage of the fact that many different parts of most applications require connections for a short amount of time as well as the fact that building and tearing down connections is an inherently expensive operation. Connection pooling is a method of reusing connections. The real magic occurs when connections are closed, because the pool hangs on to the connection for some short time (the pooling timeout) before actually closing the connection. If another connection is requested before that short amount of time has elapsed, it hands the open connection to the requestor. This saves the actual work of tearing down the connection and opening a new one. By utilizing connection pooling, you reduce the likelihood of making a round trip to the database only to find out that the database is out of connections. The connection pool reduces the time it takes to determine the out-of-connections state. In fact, with the connection pool, the additional requests can block to wait for a new connection to be available. This allows a machine to throttle its actual usage of the database so as not to swamp a particular database server with requests.
-
Notes from Webchat on serialization in .Net
Serialization in .Net
-
Using spiderous to discover cool sites
Once I started using del.icio.us for managing my bookmarks, I came across this site called spiderous which aggregates popular and new bookmarks from sites like del.icio.us , spurl, furl and a couple of others.
-
Excellent article on how to start a startup
Paul Graham who has written an excellent article on how to start a startup. He is also the author of a great book called Hackers and Painters, a definte read.
http://www.paulgraham.com/start.html
-
Load event gets fired on each call to ShowDialog()
While chasing down one bug in my custom message box at codeproject I came acorss an interesting fact. If you use ShowDialog() to show your form then the Load event gets fired everytime. I've been using Winforms for such a long time and was surprised that I had never really come across this behaviour.
It's not a bug, if you use reflector and take a look at Form.ShowDialog() you will see that the flag which is used to prevent Load event from getting fired more than once is disabled everytime ShowDialog() gets called.
-
How to hire Programmers
There is an interesting article on Artima on how to hire programmers. The forums where the article is being discussed has some cool ideas too. -
A new approach to Web Forms
Mike Roberts talks about a new approach to WebForms, he is the author of CruiseControl.Net a continuous integration software for .Net.
Extract
'What??' you may cry. 'You've stopped using ASP.NET??' No, I've just stopped using Web Forms. Web Forms are those
http://mikeroberts.thoughtworks.net/blog/archive/Tech/dotNet/GoodbyeWebForms.html.aspx
files you write and their code behinds. They're also the things that use server controls, view state and other such components that make up most of .NET web apps. I'm still using the ASP.NET runtime in the form of an IHttpHandler. This is a much more lightweight way of developing web apps, similar to Java's Servlets.
-
Spam Filter technology to fight AIDS
Microsoft Research has pioneered promising new ways to combat one of humankind's most deadly viruses with advanced software typically used to analyze large computer databases and complex digital images, or to separate spam from legitimate e-mail.
-
Tidbit on VisualStyles in Windows Forms
I wanted to implement theme support for my MessageBox component mentioned in the previous post, I came acorss this excellent post on how Application.EnableVisualStyles() works. So basically it uses the Activation Context API to specify that the v6.0 of common controls should be used.
When I looked at the API, I found that you have to specify a manifest file to specify that information. Now where does that manifest file come from? So I fired up reflector and this is what I found. Below is the code for the method that creates the ActivationContext for your application.
private bool EnsureActivateContextCreated()
{
bool flag1;
lock (typeof(SafeNativeMethods.EnableThemingInScope))
{
if (!SafeNativeMethods.EnableThemingInScope.contextCreationSucceeded)
{
string text1 = null;
FileIOPermission permission1 = new FileIOPermission(PermissionState.None);
permission1.AllFiles = FileIOPermissionAccess.PathDiscovery;
permission1.Assert();
try
{
text1 = typeof(object).Assembly.Location;
}
finally
{
CodeAccessPermission.RevertAssert();
}
string text2 = null;
string text3 = null;
if (text1 != null)
{
text3 = Path.GetDirectoryName(text1);
text2 = Path.Combine(text3, "XPThemes.manifest");
}
if ((text2 != null) && (text3 != null))
{
SafeNativeMethods.EnableThemingInScope.enableThemingActivationContext = new SafeNativeMethods.EnableThemingInScope.ACTCTX();
SafeNativeMethods.EnableThemingInScope.enableThemingActivationContext.cbSize = Marshal.SizeOf(typeof(SafeNativeMethods.EnableThemingInScope.ACTCTX));
SafeNativeMethods.EnableThemingInScope.enableThemingActivationContext.lpSource = text2;
SafeNativeMethods.EnableThemingInScope.enableThemingActivationContext.lpAssemblyDirectory = text3;
SafeNativeMethods.EnableThemingInScope.enableThemingActivationContext.dwFlags = 4;
SafeNativeMethods.EnableThemingInScope.hActCtx = SafeNativeMethods.EnableThemingInScope.CreateActCtx(ref SafeNativeMethods.EnableThemingInScope.enableThemingActivationContext);
SafeNativeMethods.EnableThemingInScope.contextCreationSucceeded = SafeNativeMethods.EnableThemingInScope.hActCtx != new IntPtr(-1);
}
}
flag1 = SafeNativeMethods.EnableThemingInScope.contextCreationSucceeded;
}
return flag1;
}
So the manifest file is called XPThemes.manifest, the intresting thing was how the code determines the directory in which to find the file, the relevant line of code is
text1 = typeof(object).Assembly.Location;
Since object is defined in mscorlib.dll and that is present in the directory where .Net is installed
the code can get the location where it can find XPThemes.manifest
If you search for XPthemes.manifest it will be present in the folder where you installed the .Net runtime.