Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / November 2003

Tip: Looking for answers? Try searching our database.

can not get type of class inside System.Data

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cyrus - 20 Nov 2003 07:14 GMT
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?
Mattias Sj?gren - 20 Nov 2003 11:35 GMT
>I can not get the type of the classes inside Data namespace by using the
>Type.GetType() method

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

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

Cyrus - 21 Nov 2003 01:50 GMT
I want to dynamically instantiate a class
is it that we can not get type of a Sealed Class?

> >I can not get the type of the classes inside Data namespace by using the
> >Type.GetType() method
[quoted text clipped - 3 lines]
>
> Mattias
Mattias Sj?gren - 21 Nov 2003 19:51 GMT
>is it that we can not get type of a Sealed Class?

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

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

Cyrus - 22 Nov 2003 02:18 GMT
i cant get the type by using this statement
Type t = Type.GetType(System.Data.OleDb.OleDbCommand);
it return null to me

> >is it that we can not get type of a Sealed Class?
>
> No, getting the type of and instantiating a sealed class should be no
> problem.
>
> Mattias
Mattias Sj?gren - 27 Nov 2003 21:24 GMT
>i cant get the type by using this statement
>Type t = Type.GetType(System.Data.OleDb.OleDbCommand);
>it return null to me

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

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.