invalid typecast that drives me mad…

So I was writing some code for a project – and it happened again: An error which makes no sense even after two hours of starring at it and triple-checking everything… and a call to a colleague…. The error stays and nobody understands why there even is one…

Let me tell you the complete story:

I was writing the Plugin-Interface for multeem and I had to pass several already instantiated classes to the plugin. So I added a property to the PluginInterface and implemented it this way:



As you can see…there’s the local IRC_Server_ which is of type multeem.IRC.IRCServer. Because I don’t want any other libraries in the PluginInterface definition I defined the IRC_Server in the PluginInterface as an object to make it as generic as possible.

When the plugin is initiated the already instantiated IRCServer is passed through to the plugin’s IRC_Server object…



and there it is…the typecast error…



To say it again: IRC_Server_ is of type multeem.IRC.IRCServer and value is of type System.Object and contains a multeem.IRC.IRCServer

but…



Something is going wrong…and I don’t have any clue what it might be… do you?

If you want to take a look at the whole sourcecode…fire up your Subversion Client and checkout your own work-copy from https://vcs.slash-me.net/multeem