Type.GetType does not work in VB.NET but works in C#. VB.NET gurus Please help


Friends,
   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 Sad 
 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
 
0
enggr
5/23/2008 6:32:32 PM
📁 asp.net.visual-basic.net
📃 3721 articles.
⭐ 0 followers.

💬 4 Replies
👁️‍🗨️ 2741 Views



 Hi,
have a look on this article http://ziqbalbh.wordpress.com/2008/05/27/typegettype/ 

Zafar Iqbal
VP Technology
Hansvits


** Please mark as ANSWER if my reply helped you
0
ziqbalbh
5/27/2008 10:42:01 AM

Hi, 
Could you use the TypeOf Operator as all??
Dim ty As Boolean = TypeOf <object> Is JEB.DocumentIdsCaseNumbers
I know this example is not exact but it may help you??
Regards
Nick
0
ncoleman
5/30/2008 12:56:44 PM

Type.GetType is a framework call - it should work identically in C# and VB.
The global VB GetType macro is another story (and is equivalent to the C# 'typeof' operator), but this isn't a factor here.
 

David Anton
http://www.tangiblesoftwaresolutions.com
Convert VB to C#, C++, or Java
Convert C# to VB, C++, or Java
Convert C++ to C#, VB, or Java
Convert Java to C#, C++, or VB
0
David
5/30/2008 2:33:01 PM

'Method 1
Dim Form1 As Form = Activator.CreateInstance(Of frmContractEdit)()
Form1.Show()
'Method 2
Dim Form2Type As Type = GetType(frmContractEdit)
MsgBox(Form2Type.AssemblyQualifiedName)
Dim Form2 As Form = CType(Activator.CreateInstance(Form2Type), Form)
Form2.Show()
'Method 3
'Fusion. needs to be in front and was found using MsgBox above
'frmContractEdit needs to have Inherits System.Windows.Forms.Form in its Class definition (designer)
Dim Form3Type As Type = Type.GetType("Fusion.frmContractEdit", True, True)
MsgBox(Form3Type.AssemblyQualifiedName)
Dim Form3 As Form = CType(Activator.CreateInstance(Form3Type), Form)
Form3.Show()
'Method 4
Dim Form4 As Form = CType(Activator.CreateInstance(Type.GetType("Fusion.frmContractEdit", True, True)), Form)
Form4.Show()
0
scottizu
10/7/2008 12:16:34 AM
Reply: