Monday, November 12, 2007

Pooling Wisely for Oracle Data Provider for .NET

Use the Decr Pool Size and Incr Pool Size properties wisely when you use ODP pooling.

Decr Pool Size Controls the number of connections that are closed when an excessive amount of established connections are unused, and Incr Pool Size Controls the number of connections that are established when all the connections in the pool are used.

When a connection pool is created, the connection-pooling service initially creates the number of connections defined by the Min Pool Size attribute of the ConnectionString, and then Incr/Decr pool size properties are used to maintain the connections pooled.

The values for Incr/Decr pool size should be based on your Min Pool Size and Max Pool Size values. Eg: "User Id=scott;Password=tiger;Data Source=oracle; Min Pool Size=10; Max Pool Size=1200;Connection Lifetime=120;Connection Timeout=60; Incr Pool Size=10; Decr Pool Size=5";

Friday, November 02, 2007

XmlSerializer Worries and Generating Typed Serializers

The simple constructors of XMLSerializer class caches the typed serializer once it is generated.

When you use XmlSeializer to serialize a type, XmlSerializer will create a dynamic assembly on the fly containing the serialization code. When XmlSerializer is invoked from your application,

  • The XmlSerializer constructor will reflect the type you are passing to the XmlSerializer constructor, and generate the code for typed serializer for the same.
  • The code is compiled by calling csc at run time
  • The resulting assembly is loaded to the application domain, and is cached for future uses.

How ever, there is a known problem with XmlSerializer - some XMLSerializer constructors (other than the simple constructors) will regenerate the typed serializer assembly each time, instead of getting it back from the cache. In other words, XmlSerializer is not using the caching mechanism in every constructor - but only for simple constructors.

Anyway, it is a better practice to generate your serializers at compile time, instead of using XmlSerializer which effects in run time generation of typed serializers. Atleast, this will definitely improve your application performance during startup (for web applications). For desktop applications, you should use typed serializers.

You can use some typed serializer generators like SGen or Mvp.Xml.XGen to generate typed serializers. SGen is not very mature, because it fails to handle a couple of scenarios, and may skip some types with out any warning.

Mvp.Xml.XGen is better.What it does is, pass the type to generate the code to XmlSerializer at design time itself, and then stealing away the code generated by XmlSerializer (and optimize it a little bit), to compile the typed serializer code - and provide you the typed serializer at design time itself.

When you pass a type to XmlSerializer, the code generated can be fetched from the temp folder, provided you requested XmlSerializer constructor not to cleanup the code it has generated. For this, you've to add a hidden switch to your application config file - like

<configuration> <system.diagnostics> <switches> <add name="XmlSerialization.Compilation" value="4"/> </switches> </system.diagnostics> </configuration>

Unloading assembly from the Appdomain

It is pretty sad that Microsoft is not providing an ideal way to unload individual assemblies from an application domain :( Right now, if you want to unload individual assemblies, you have to create another app domain, and then load your assemblies to that, and unload the entire app domain once you are done. But this approach has few problems

  • If you are loading your assembly to a separate application domain, you have to use remoting for cros app domain calls
  • You don't really need a separate app domain to load and unload assemblies - because of performance reasons.

I've read an interesting blog entry from Jason Zanders here

Thursday, June 28, 2007

Microsoft Surface

This should not be a post under .NET category, but still..

If you havn't heard much about Microsoft Surface

The Surface SDK is not released yet, but I suspect it will heavily oriented towards .NET and Silverlight :)

Friday, June 22, 2007

Microsoft Silverlight

If you havn't yet heard about Silverlight,

"Microsoft® Silverlight™ is a cross-browser, cross-platform plug-in for delivering the next generation of .NET based media experiences and rich interactive applications for the Web. Silverlight offers a flexible programming model that supports AJAX, VB, C#, Python, and Ruby, and integrates with existing Web applications. Silverlight supports fast, cost-effective delivery of high-quality video to all major browsers running on the Mac OS or Windows."

Here is more info -

You can watch more details and tutorials here

Tuesday, May 22, 2007

LINQ and C# 3.0

This months MSDN features LINQ (If you are not yet aware what is in store for the next release of .NET, LINQ is a dynamic querying framework that is tightly integrated to the next version of .NET)

Have a look at this MSDN article here

Orcas And Microsoft.NET 3.5

Orcas Beta and .NET 3.5 is in store for some time - You can download Microsoft.NET 3.0 from MSDN.

If you are still not aware about the story, See this whitepaper about Orcas here

Orcas Whitepaper - Click here For .NET 3.5 Click here For Orcas Click here

A GPS Tracer Application for Windows Mobile

I found a good article about creating a simple GPS tracer application for Windows Mobile, in Code Project. It shows

  • Read data from any NMEA GPS device
  • Read your position and print it to the screen
  • Load and save your path
  • Zoom in/out
  • Pan on your path
  • Center on the map
  • Run in demo mode with randomly generated data
Very interesting. See for details

Saturday, March 17, 2007

ASP.NET Videos

Have a look at these ASP.NET Videos in Microsoft Website.

“How Do I?” with ASP.NET AJAX

“How Do I?” with ASP.NET

SQL Server 2005 Express for Beginners

Videos for ASP.NET 2.0 Beginners

“First Look” VideosVideos on Visual Studio 2005 Add-ins

Videos on Migrating to ASP.NET

Really good stuff.

Thursday, February 22, 2007

SandCastle And NDoc - For .NET 2.0 Code Documentation

Recently, I was searching for some good tools for generating MSDN style documentation from C# code comments. Here are few tools I came across.

Sand Castle - Provided by Microsoft, with out much official support. But serves the purpose. May take some time to configure :) - See

NDoc For .NET 2.0 - I don't think it is an official release of NDoc, but this one can generate code comments for VS 2005 - See . When you try to open a VS 2005 solution, it may say Invalid Solution, but I got around this problem by simply dragging the dll file to the 'Select Assemblies To Document' listbox before building them.

Sunday, January 14, 2007

Frameworks For .NET Development

Here is a little bit of information regarding some good frameworks, for .NET application development. Traditionally, we have the presentation layer, business logic layer, and the data logic layer. In these layers, things like Exception handling, logging etc can be common.

For example, Microsoft Enterprise Library blocks offers such common functionalities, as different functionality blocks.

The Enterprise Library consists of a Data Access Application Block. Though this provides a reusable pure data layer, it lacks the rich features of a true ORM. But because it has the backing of Microsoft and their legions of developers, many companies will adopt the Data Access Application Block as their standard platform. But still, to gain the real power, we need to look for some frameworks with much more features, than the Microsoft Data Access Application Block. Hence, let us have a look at some other frameworks- some of them are mainly for implementing data access logic and OR mapping, and others like AdapDev has much more features like support for advanced caching. Some of them (like EasyObject.NET) internally uses Microsoft Data Access Block for interfacing with the database.

1. Neo - Neo is a framework for .NET developers who want to write enterprise applications with an object-based domain model. It is well suited for domain-driven design and agile development. Pretty good for small apps See

2. nHibernate - NHibernate is a .NET based object persistence library for relational databases. It is a widely used OR persistant tool these days. It is inspired by Java hibernate. See

3. MyGeneration DoodAds - DoodAds is an elegant .NET architecture available in C# and VB.NET and capable of supporting any .NET managed data provider. Currently dOOdads are available for Microsoft SQL, Oracle, Firebird, Access, PostgreSQL, VistaDB, SQLite, and MySQL . You can use MyGeneration Code Generator to generate DAL classes easily for DoodAds. See . It is one of the great frameworks I've seen so far, with an elegant Dynamic Query support. Highly recommended.

4. EasyObjects.NET - EasyObjects.NET is an object relational mapper (ORM) architecture based on a combination of the popular MyGeneration dOOdads architecture and the Microsoft Enterprise Library. See

5. DataBlock - DataBlock is a Object Relational Mapping and persistence framework for .NET 2.0. - See

6. AdapDev.NET - Adapdev.NET is a robust enterprise framework that supplements the MS.NET framework. It's the foundation of Codus (OR Code generator) and Zanebug (A unit testing framework) providing the underlying code generation and unit testing engines. See

7. Gentle.NET - Gentle.NET is an RDBMS independent object persistence framework. It features automatic SQL generation and object construction, an SQL factory for creating custom queries, DataView construction helpers, excellent performance and reasonably complete docs. See

8. IBatis.NET - The iBATIS Data Mapper framework makes it easier to use a database with Java and .NET applications. iBATIS couples objects with stored procedures or SQL statements using a XML descriptor. Simple and elegant..See

Wednesday, January 10, 2007

Provider Pattern

I've published an article about creating a provider based framework here After reading this article, you'll be able to (1) Change your mindset a little bit, and start thinking about 'frameworks' instead of just 'code' (2) Understand a lot about practically applying provider pattern in your projects (3) Gain much knowledge regarding xml config files and providers

Monday, June 05, 2006

Dreaming About An XML Based Pre-Processor for Dotnet

A good concept I had in my mind is developing a pre-processor for .NET compilers, to convert an XSD data structure definition in a VB or C# source code file to equivalent code. Right now, if I need to specify and use a data structure in XSD,

  • First of all, I have to create an XSD schema
  • Use xsd tool or xsdobjectgen to map it to a set of classes or the Document Object Model.
  • Use the DOM in my project

I suggest, Microsoft may soon think about allowing developers to embed XSD definitions with in the source code, so that we can create objects of the XSD schema definition with out going through the above processes. Some kind of embedded XSD?

This will allow developers to define data structures using XSD, directly in their source files, and create and use instances of the same. I dream about writing something like this in a VB.NET source file in the near future.

public class FutureClass

<xs:element name="PersonType">
<xs:attribute name="Name" type="xs:string" use="required" />
<xs:attribute name="Address" type="xs:string" />

private person as PersonType

Sub New()

        person= new PersonType()


End Sub

End Class

Probably I am a little bit over ambitious, but I hope you got my point. But anyway, I'll consider developing a .NET pre-processor which can parse the code above, when I get some time. Err.. Who Knows? Whether something like this is already available?

Continuous Integration

These days, more and more companies are adopting continuous integration strategy for developing software applications. Continuous integration involves, putting a build server to build your projects periodically.

  • In this way, builds can be automated
  • Even clients can track the progress of the project and have a preview of the project by using the latest builds.
  • This helps the clients to track the progress of the project.

Continuous integration prevents any last minute hassles in a project. When ever some code is changed, if there is some problem, it breaks the build and a warning regarding the incompatible code can be obtained.

However, you need to put a dedicated build server for implementing Continuous Integration.

Some tools that you can use to implement Continuous integration. See more details about Continuous integration here - at Martin Fowler's site.

3D Programming In VB.NET

Interested in some 3D programming? Now you can use Open GL from VB.NET very easily, thanks to the CsGL library [CSGL Homepage]/ - which is a set of classes which wraps Open GL to use it from .NET. You may download the CsGL library binaires from here

If you need to grab some object oriented concepts in VB.NET, before you begin, have a look at my VB.NET article here.

Also, have a look at an interesting article here at, for a detailed discussion regarding using Open GL with VB.NET

An XML based programming language

I recently found an interesting 'language' from - X Plus Plus - which is an object-oriented language that is entirely based on XML's syntactical structure. I had some thoughts about developing a language like this long back, but I felt that XML is not so powerful when it comes to expression handling and evaluation. Just think how much difficult it is, to represent an expression, purely in XML? I just had a quick look at X++. Have a look at it, and it may trigger some new concepts in you.

Tuesday, May 30, 2006


Interested in some fun oriented, but serious programming? Want to create some virtual organisms using code, and to make them survive in a virtual, simulated environment? Get Dotnet Terrarium, and start developing some animals today - And evaluate your programming knowledge and technical skills!!

Wednesday, May 24, 2006

Information about neural networks

If you need to grasp some theory about Neural Networks, Visit - some good neural network links are there. Have a look at this video presentation from Neuro solutions See this essay about perceptrons at

Thursday, July 07, 2005

Operator overloading in VB.NET

Finally VB (VS 2005) supports operator overloading.. See this article for a detailed overview

Here is some example..

Public Class MyString
   Private _text As String
   Public Sub New(ByVal text As String)
      _text = text
   End Sub
   Property Text() As String
         Return _text
      End Get
      Set(ByVal value As String)
         _text = value
      End Set
   End Property
   Public Shared Operator -(ByVal str1 As MyString, _
      ByVal str2 As MyString) As String
      Return str1.Text.Substring _
         (0, str1.Text.Length - _
         str2.Text.Length) & str2.Text
   End Operator
End Class


Generics is another new feature in the .NET 2.0 Framework. As such, languages such as C# and Visual Basic 2005 now support this new feature.

Using Generics, you can define a class definition without fixing the data type that it is using at design time. Generics are simply like template classes in C++. That is a great addition for our VB :)

Thursday, April 14, 2005

Recovering ASP.NET after an IIS crash

Your Internet Information Server crashed, and you reinstalled it. Now, how to re install ASP.NET so that IIS can load and execute aspx pages? There is a tiny tool aspnet_regiis.exe in your Microsoft.NET system folder (e.g, at C:\WINDOWS\Microsoft.NET\Framework\vx.x.xx). Execute aspnet_regiis.exe -i (don't foget the -i switch) in the command prompt.

Creating custom attributes for metadata

Do you want to create custom attributes for describing your functions and classes when developing .NET projects?

First of all, create an attribute class, derived from System.Attribute. Now, I'll create an attribute class named DescriptionAttribute. Mark it with AttributeUsageAttribute (it is a system provided attribute), to show that this class can be used as an attribute.

<AttributeUsageAttribute(AttributeTargets.Class)> _
Public Class DescriptionAttribute
Inherits System.Attribute
Public Description As String = ""
Public Sub New(ByVal MemberDescription As String)
'Whether we show this object type/method in the schema
Description = MemberDescription
End Sub
End Class

AttributeTargets.Class means, only classes can be marked with this attribute. Now, let us apply our above attribute to another class

<DescriptionAttribute("Cool Class")> _
Public Class MyClass
End Class

The string "cool class" will be passed to the constructor of your above class. That is it. Now, you may need to check a class to know whether your DescriptionAttribute is applied on it. In my next example, I'll show how to read back your custom attributes from a data type (class, functions etc) in a library.

Converting VS.NET solutions between versions

If you are using a version of Visual Studio.NET, you need a utility for converting VS.NET solutions and projects from one version to other. Go for vsconvert. This utility converts projects and solutions from VS.NET 7.0 to VS.NET 7.1 and vice versa See

Connecting to Access mdb from ASP.NET

A lot of newbies are facing security problems, when they try to connect to a Microsoft Access Database ( mdb file) from ASP.NET, using oledb. This is because, the ASPNET user account in Windows doesn't have security access to the mdb file by defualt. ASP.NET uses the ASPNET user account for connecting to the database. To solve this,

  • Right click the Access database file, click properties.
  • Click the security tab in properties dialog box.
  • Add the user ASPNET to the security list, and provide full control (check allow full control checkbox)
  • If you can't see the security tab when you take properties, it is because 'simple file sharing' is enabled by default. Use windows explorer->Tools->Folder Options to disable simple file sharing.

Tuesday, April 05, 2005

XSD Object Generator

XSD Object Generator (xsdobjectgen.exe) tool from Microsoft is a powerfull tool for working with Extensible Schema Types. For example, consider that you need to create an object model from a schema with cross references. XSD Object Generator can identify such references, and it will create a collection for child elements. That is excellent, isn't it? The classes generated are suitable for both creating and consuming XML and for use as parameters and return values in web service implementations.This is an ideal tool for developers who need to implement support for XML based on an existing schema, such as schemas published by industry standards groups. The classes generated can also be serialized. Download it from Here

Sunday, March 20, 2005

Patterns And Practices - GOF Patterns and more

In real world application development, you see recurring problems. Once such an issue is addressed, the we addressed that problem can be re-used. Such reusable recurring solutions are called patterns. For example, if you need to create a class with only single instance can exist, you use a pattern called Singleton. The GOF (Gang Of Four) patterns are used widely these days. See Design patterns are recurring solutions to software design problems you find again and again in real-world application development. See for reading about patterns and to view their implementations in C# . (I hope I can write VB.NET examples soon as a tutorial). Microsoft has also proposed certain patterns and practices for developers working in MS platforms (mainly .NET) - see . If you know these patterns, you can decide which pattern should be used for solving a problem - and not how to solve a problem from the ground level.

Articles - Design Patterns, Neural Networks, C#, Programming