Groups | Blog | Home
all groups > dotnet sdk > november 2003 >

dotnet sdk : can not get type of class inside System.Data


Mattias Sjögren
11/20/2003 12:35:06 PM

[quoted text, click to view]

What does your code look like? And why aren't you using the typeof
operator (or GetType if you're using VB.NET)?



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Cyrus
11/20/2003 3:14:59 PM
I can not get the type of the classes inside Data namespace by using the
Type.GetType() method
It throws the following exception

An unhandled exception of type 'System.TypeLoadException' occurred in
datatier.dll
Additional information: Could not load type System.Data.SqlClient.SqlCommand
from assembly DataTier, Version=1.0.1419.27277, Culture=neutral,
PublicKeyToken=null.

How come?

Cyrus
11/21/2003 9:50:58 AM
I want to dynamically instantiate a class
is it that we can not get type of a Sealed Class?

[quoted text, click to view]

Mattias Sjögren
11/21/2003 8:51:31 PM

[quoted text, click to view]

No, getting the type of and instantiating a sealed class should be no
problem.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Cyrus
11/22/2003 10:18:25 AM
i cant get the type by using this statement
Type t = Type.GetType(System.Data.OleDb.OleDbCommand);
it return null to me


[quoted text, click to view]

Mattias Sjögren
11/27/2003 10:24:21 PM

[quoted text, click to view]

That code shouldn't even compile. I assume you had the type name as a
string.

The reason it returns null is that Type.GetType only looks in
Mscorlib.dll and the calling assembly by default. To make it look in
some other assembly (System.Data.dll in this case) you have to pass it
the full type and assembly name

"System.Data.OleDb.OleDbCommand, System.Data, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"

But if you have System.Data.dll referenced, it's easier to just use
the typeof() operator.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
AddThis Social Bookmark Button