I would hope people are using the most current release, but it would be helpful as well to include what build number you have.
I believe this is the line:
string channelTarget = channel.Target.Substring(lastSlash + 1, lastDot - lastSlash - 1);
lastDot is likely
-1, which means
channel.Target did not have a dot.