I love the way COM interfacing enables you to do awesome scripted things but sometimes (more often than not) it brings me just a little closer to madness.

Primarily I’ve been having huge problems getting things to marshal properly from vbs (visual basic script) to my C# classes. I don’t understand why it should be so hard. If you read Microsofts documentation like the Troubleshooter or the Array description it describes how arrays can be simple declared like this:

void MyMethod(string name, string[] someArguments){}

Unfortunately, you have to try, try again and then just resort to using untyped objects to get it to work with VBscript. This post on Stackoverflow made me give up and just settle with an object input to my method instead of a typed array. Problem is that when you’re generating documentation or using languages or typed imports with IntelliSense that type safety really helps so I hate having to give it up.

This is how the method ended up looking for anyone trying to do the same thing.

void MyMethod(string name, object someArguments)
{
	var typedList = ((object[])someArguments).Cast<string>().ToArray();
	// ....
}

And if any COM guru out there can suggest a better solution, please come forth!