Why do I get a "Can't add component because class doesn't exist!" error using generic AddComponent?

I have two ways of connecting to a database and the one used is based on whether the user is behind a proxy. I want to have the connection auto-switch based on the setting, so they both inherit from a DatabaseConnection class (which inherits from MonoBehaviour). There should only ever be one thing of type DatabaseConnection active at a time, so I use the following to get the correct connection for the situation:

if (Settings.instance.useProxy)
{
    connection = holder.AddComponent<DatabaseConnectionWithHttpWebRequest> ();
}
else
{
    connection = holder.AddComponent<DatabaseConnectionWithWWW> ();
}
Debug.Log ("Using DatabaseConnection of Type " + connection.GetType ().ToString ());
return connection;

The problem I have is that at run-time whenever there is a proxy and it tries to add the DatabaseConnectionWithHttpWebRequest, I get the following error:

Can't add component because class 'DatabaseConnectionWithHttpWebRequest' doesn't exist!
UnityEngine.GameObject:AddComponent(String)
UnityEngine.GameObject:AddComponent(String)
UnityEngine.GameObject:AddComponent()
DatabaseConnection:get_instance()

From this forum post, it appears the error shows up when you call AddComponent with a string representing a class that doesn't exist (which it appears the generic AddComponent does internally), but the class seems to exist as far as I can tell (MonoDevelop auto-completes it and I get no compilation errors in the editor). Any ideas what might be wrong?

ETA: I should add that using the DatabaseConnectionWithHttpWebRequest on its own worked fine. That is, neither class inherited from anything other than MonoBehaviour and I renamed whichever one I wanted to use as DatabaseConnection.cs and had no problem using what is now the HttpWebRequest one.

Shot in the dark: are DatabaseConnectionWithWWW and DatabaseConnectionWithHttpWebRequest class definitions in the same file? I think Unity will only recognize components that are named the same as the class, so having two in one file won't work.

It turns out MonoDevelop was showing a different filename than the actual file. I had renamed what is now DatabaseConnectionWithHttpWebRequest using the Rename context menu in MD, and it was reflected in the solution pane, but didn't actually change the file name. Since I wasn't manually adding the component in the Unity project, I didn't notice until I tried to manually add it in the inspector again. I ended up having to remove the file from the project, rename it in Finder and then add it back to the project, in case anyone else runs into this problem.

If you're trying to load a component which is inside a dll instead of a script in the editor, it's not possible.

You can, however, make the class in the dll a partial class, and then add a monobehaviour with the same name, no code inside and also partial.

This should let you load the one in the dll

Bit hacky, but works, without having to expose your code