Thursday, August 6, 2009

catch block with no arguments?

I was at first surprised to see a catch block that does not accept any Exception types as argument. Something that looks like this:

try
{
//some lines of code...
}
catch
{
//fixation code...
}

What it actually does is catch all CLS (Common Language Specification) based and Non-CLS-based (exception raised by COM components) exceptions. Or for simplicity's sake we could think of as equivalent to the following (in .NET 2.0 or above):

try
{
//some lines of code...
}
catch(Exception ex)
{
//fixaion code...
}

Sunday, February 15, 2009

Destructors in C#.NET

I find this topic really undiscussed among pure .NET developers (I don't know why they don't bother) Even I got to look at it when someone asked me how do we actually call destructors over an object in C#.NET.

A quick googling and here's a nice article on Destructors in C#.NET.

http://www.c-sharpcorner.com/UploadFile/chandrahundigam/UnderstandingDestructors11192005021208AM/UnderstandingDestructors.aspx?ArticleID=3cc8bfd4-d3ef-4bb2-bae9-41774fd943f7

Though needs a bit of work on English, its plainly written for someone like me.

Monday, February 2, 2009

Working around System.Runtime.InteropServices.COMException

Well, if you're trying to open up a solution in Visual Studio that has Web Services within and getting this annoying message about System.Runtime.InteropServices.COMException, ...

...

...

...

then all you may need to do is simply delete the (hidden) 'User Options' file in the folder where you've stored the .sln file, make sure IIS is already installed and there are Virtual Directories built up for you web service.

I tried to copy a web solution to a different machine than on which it was developed and I got this problem when I tried to open it in Visual Studio over the other machine. Just deleting that User Option file worked around for me.

You can also check out the following link for further information:

http://geekswithblogs.net/marocanu2001/archive/2008/05/20/annoying-visual-studio-2008-little-bug.aspx

Have fun!!!