Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB.NET
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 23rd, 2008, 01:37 PM
Registered User
Join Date: Dec 2006
Location: Los Angeles, CA, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Type.GetType does not work in VB.NET. Please help


   I am an experienced C# programmer who is working on a VB.NET project now. I am writing different methods covering the following functionalities

1) Take a datareader as input and return an arraylist of class object

2) Take an xmlnode (received from a webservice) as input and return an arraylist of class object.

 The methods are generic methods which take datareader/xmlnode as first parameter and classname (string) as the second parameter. This way it will work trivially.

 The schema of class object matches with the input (datareader or xmlnode)

In C# I used to do this by using reflection and Type.GetType(). But the Type.GetType() is not working in VB.NET. Its returning "Nothing". I made sure that the namespace/class names are spelled properly. I even tested the same code in C# and it works like a charm. Only in VB.net it does not work.

The .vb file is created inside the App_Code folder of the web application.

I read other posts and removed the temporary asp.net files and stuff but didn't help

Any help will be greatly appreciated

 C# code

Type type_ClassName = Type.GetType(className); //Works like a charm

VB.NET code

Dim oType As Type = Type.GetType("JEB.DocumentIdsCaseNumbers") // Does not work :(

 I used Immediate window on debug mode for both vb.net and c# and confirmed that it does not work in vb.net

 Please help me to get the GetType() working in VB.NET

Reply With Quote
  #2 (permalink)  
Old May 24th, 2008, 04:03 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Hi there,

You probably want to use VB's GetType directly like this:

Dim type_ClassName As Type = GetType(ClassName)

Alternatively, if you need to check whether an instance is of a certain type you can also use TypeOf:

If TypeOf (instance) Is ClassName Then
End If

Hope this helps,


Imar Spaanjaars
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #3 (permalink)  
Old June 3rd, 2008, 06:07 AM
Registered User
Join Date: Jun 2008
Location: liverpool, , United Kingdom.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

I had a similar problem and Type.GetType( [string] ) was not working.

Check if you have already declared a class with the name Type. You can inevertently do this by creating LINQ classes. If this is the case then you will need to type.

System.Type, as the following example shows:

Dim typeModificator As System.Type = System.Type.GetType(("TemplateParser.Modificators. " + strExtra))

Hope this helps anyone stumbling across it.

There's plenty of different ways to skin a cat.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
default(System.Type) does this exist in VB.NET 2k5 Peace2u ASP.NET 2.0 Basics 0 August 18th, 2006 06:51 AM
Dowloaded code (VB.NET 2003) does not work kadesskade VB.NET 2002/2003 Basics 2 July 10th, 2006 12:49 AM
what data type in vb.net holds more thab 256 bits Hisham VB.NET 2002/2003 Basics 1 November 8th, 2004 05:35 AM
How to work on a VB.NET project from 2 PC's crt VS.NET 2002/2003 3 June 17th, 2003 10:33 AM

All times are GMT -4. The time now is 04:15 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.