0
Reply

question about TypeOF() and assemblies

akshay joshi

akshay joshi

Oct 10 2008 11:41 PM
2.8k
QUESTION NUMBER ONE

I have made one external private assembly mylibrary.dll with version=1.0.0.0.
It has got one type procsharp in the mylibrary namespace

When i run this code
 
  1. Type t = Type.GetType("mylibrary.procsharp, Mylibrary, version=3.0.0.0,publickeytoken=null,culture=neutra  l", true , true);

From another assembly(by having a copy of it in the same folder) it just runs perfectly despie of the fact that i have written version=3.0.0.0 in the code !
As a matter of fact changing the version seems to have no effect on the runability of the code.
Why is it so ?


QUESTION NUMBER TWO

For the TypeOf() function to work correctly u need to give it a string representing the fully qulalified name of the type u wish to return.
For all types in the current assembly and mscorlib.dll u dont need to give any other information except the name of the type.
Example TypeOf("System.Int32");

For extenal private assembly we have to write the name of the assemly as well.
Type.GetType("mylibrary.procsharp, Mylibrary);

U dont have to write version and other information.

but when u r referring to a type (not in mscorlid, but in BCL) u give the other info. too like.

Type t = Type.GetType("System.Data.DataTable, System.Data , Version=1.0.5000.0 , Culture=neutral, PublicKeyToken=b77a5c561934e089", true, true);

Why is this difference.
Also: Lets talk about uniformity
In this code 
Type.GetType("mylibrary.procsharp, Mylibrary);
does the compiler make any default assumption about the verion culture etc ?