S h o r t S t o r i e s

// Tales from software development

Different return types from Activator.CreateInstance

leave a comment »

While writing some IOC infrastructure code a few days ago I stumbled across the fact that Activator.CreateInstance() sometimes returns an ObjectHandle rather than an Object.

Perhaps I’ve led a sheltered life but until now I’ve only needed to use overloads of Activator.CreateInstance() that return an Object. This just needs casting in order to use it.

I’m not sure why this difference exists but it’s easy enough to deal with as the ObjectHandle class implements an UnWrap() method that returns the Object that the handle references.


Written by Sea Monkey

September 16, 2011 at 8:00 pm

Posted in Development

Tagged with ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: