AW: [Mono-list] Assembly.LoadFrom() - Assembly.CreateInstance() - Activator.CreateInstanceFrom() ---> invalid cast
Tue, 27 Jan 2004 00:14:30 +0100
> Stating it is an invalid cast.
Can someone please explain me the following behaviour:
Assuming you have Assembly "A.dll", with one class Y (no
methods, no fields, just a plain class). Now copy this assembly to
A.1.dll, A.2.dll. You now have 3 assembly, A.dll, A.1.dll, A.2.dll (they
just differ in date of last modification).
Create a new project which references "A.dll" and write the following
static void Main(string args)
Type t1 = Assembly.LoadFrom(@"A.1.dll").GetType("A.Y");
Type t2 = Assembly.LoadFrom(@"A.2.dll").GetType("A.Y");
Type t3 = typeof(A.Y);
Console.WriteLine(t1 == t2);
Console.WriteLine(t1 == t3);
Console.WriteLine(t2 == t3);
Now guess the output (MS.NET 1.1 runtime):
Hu? :-). Why is t1 != t3, but t1 equals t2? Anyone?
So i guess that's related to your problem with your MySQL.ByteFX
DataProvider. You load your ByteFX assembly via Assembly.LoadFrom, which
references System.Data in its own "dll" scope. Your program also
references "System.Data", but somehow the "System.Data" of your program
isn't the same as in your lazy loaded ByteFX assembly.
I can't give you a solution for this, but if your application is a web
app i think you run into the problems if you're not using XSP but IIS
since IIS copies all bin\* files into some temporary directories and
there you'll get the same behaviour as stated above. (IIS does this in
order to enable dynamic reloading of web apps. Ever tried to update one
dll in your C:\inetpub\wwwroot\<App\bin\ directory? It is not locked,
you can overwrite it and if you do it, IIS will implicitly redeploy your
web app to reflect the update - makes life much easier 8-))