Skip to main content

Posts

MVC error Unable to cast object of type 'System.Int32' to type 'System.String'.

If you are getting following error while posting back data in MVC Unable to cast object of type 'System.Int32' to type 'System.String'. Check for the validation attributes on the number data types. If you have a StringLength attribute on a numeric datatype, MVC autobinding converts the field to a string and causes above error while autobinding. Instead use RegularExpression to limit numbers in a numeric field.  

Pair class in .Net

Pair class in .Net is a utility class which allows to store two related objects in one Object. One of the most frequent use of this is while creating user controls with control state. You can see more information at http://msdn.microsoft.com/en-us/library/system.web.ui.pair.aspx

HotSpotMode enumeration

HotSpotMode enum has following values Inactive NotSet Navigate Postback You can set HotSpotMode either on ImageMap control or individual HotSpot control for the ImageMap. If you specify it on ImageMap only, all the HotSpot controls interhit the behavior. All HotSpot controls must be set to NotSet to inherit the behaviour. If you specify NotSet on ImageMap and HotSpot control, the default behaviour is Naviagate. If you specify NotSet only on HotSpot, it works out the behaviour based on the setting on ImageMap. The setting on HotSpot takes precendence over the ImageMap. The settings take precendence in the order they are specified. Hence you should specify inactive map before you specify active map to create complex mapping.

The Project Location is Not Trusted Dialog Box

Often due to backup issues, our desktop profile is setup to store all profile details (including documents) on  a share location. The benefit of this is two fold 1. It gives you roaming profile. You can logic from any desktop or even remotely, and you have access to all your personal documents 2. All your personal documents are backed up on a shared server. So if your desktop crashes or your laptop is stolen, still you have all your documents on the shared server. However as a developer using Visual Studio to develop web application, this presents some problems. By default the security policy on windows doesn't trust the files on a network share. So when you create or open a project from your My Documents/My Projects folder, Visual studio shows "The Project Location is Not Trusted" Dialog Box. Even worse if you try to debug the web application stored on a network share, you get an exception "An error occurred loading a configuration file: Failed to start monit...

No SQL Databases

Recentely there has been lot of discussion about No SQL databases. Some see it as alternate to SQL database which means writing no SQL to query the database Hence No SQL. Another camp is opinion it is 'Not Only SQL' which basically means you can query the database in more than one way. These databases are also know as Document Databases as the data is stored as Documents (serialised as JSON objects) . There are three main leading open source Document databases MongoDB - http://www.mongodb.org / RavenDB - http://ravendb.net/ CouchDB - http://couchdb.apache.org/ Update: fourth contender, Amazon Simple DB : http://aws.amazon.com/simpledb/ RavenDB and CouchDB stores data as JSON objects while MongoDB uses a twist and stored data as Binary JSON (BSON) objects. Mostly the data is queries either through RestFUL API's using HTTP or through TCP/IP. These databases also support Indexes and Transactions. For transaction critical applications like banking or realtime syst...

Difference between XML Serialization and Binary Serialization

XML Serialization Binary Serialization (Soap) No need of Serializable attribute on the class Need Serializable attribute Only public members are serialized All members are serializes unless specified as NonSerializable Class should have default public constructor and class itself should have public access. No need of default constructor or public access Namespace: System.XML,Serialization Namespace: System.Runtime.Serialization.Formatteres.Binary (.Soap) Outputfile is XML Outputfile is Binary or XML for SOAP formatter XMLSerializer need type of object to be serialized or deserialized No need to specify type of object to be serialized or deserialized. Support only IDesrializationCallback interface. No support for binary events. Binaryformatter support binary events. Soap formatter supports only IDeserializationCallback interface

Searching Unicode characters in Oracle table

Oracle implementation of Regular expression has no support for using hexadecimal code to search for Unicode characters. The only way to search for Unicode character is it use the character itself. Normally with Regular expression, you can use \x or \u followed by hexadecimal code to search for any character. E.g. \x20 will match space. But REGEXP_LIKE in Oracle does not support \x. You need to use unistr function to convert the code to equivalent character and then use it with REGEXP_LIKE. E.g. REGEXP_LIKE(source,'[' ||unistr('\0020')|| ']');

Handler error while running ASP.Net web application

If you are getting invalid handler error while running IIS application on local IIS, chances are that you have installed IIS after you installed .Net framework/Visual Studio. The problem is basically IIS by default is not configured to handle ASP.Net files. When you install the Framework, it configures IIS to handle all files for ASP.Net i.e files with extension .aspx, .asmx, .ascx etc. So to fix the error, login as local administrator on your machine. Go to Visual Studio command prompt from Program files. On the command prompt execute following command aspnet_regiis -i Wait for successful installation. Now try again running your application under IIS. This should solve the problem. More information about aspnet_regiis can be found at http://msdn.microsoft.com/en-us/library/k6h9cz8h%28v=VS.100%29.aspx