[Mono-list] Assembly.LoadFrom() - Assembly.CreateInstance() - Activator.CreateInstanceFrom() ---> invalid cast

Timothy Parez tpsoftware@users.sourceforge.net
Mon, 26 Jan 2004 19:06:19 +0100


Hi,

Thnx for the quick reply,
but could you guys tell me why I can't get this to work


            Assembly DataProvider;
            DataProvider = Assembly.LoadFrom(@"bytefx\ByteFX.Data.dll");
            object connObject = 
DataProvider.CreateInstance("ByteFX.Data.MySqlClient.MySqlConnection",false);
            Clipboard.SetDataObject(connObject.ToString(),true);
            IDbConnection dbConnection = (IDbConnection)connObject;

Clipboard.SetDataObject(connObject.ToString(),true);
outputs: "ByteFX.Data.MySqlClient.MySqlConnection"
So the type of the created instance seems to be ok,
but it throws an exception when I do:
        IDbConnection dbConnection = (IDbConnection)connObject;

Stating it is an invalid cast.

The assembly is not statically referenced by my application (that is the 
point of it)

Thnx.
Timothy.