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. Follow

4 Replies
2079 Views

Similar Articles

[PageSpeed] 53

 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:

Similar Artilces:

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

converting to vb.net from c#.net authorize.net
authorize.net offered me some sample code when I signed up with them the only problem is the sample code is in c#.net but my page that they type all of their credit card into is vb.net <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll"); } private String readHtmlPage(string url) { ...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of developing. The trick is to use the "Src" attribute of the @Page directive. Check out the link if you are inclined. You are welcome to download the code if you are interested further, found at the same link. (Note that the reason that I looked for a way to do this is because I wanted to have the option to include some VB.NET-based demos at my site. Since my site is a C#.NET ASP.NET, I was told that there was no want to do this. Therefore, I looked for a workaround and just happened to find one.) Enjoy (and then get back to work!) http://www.NetBrainer.com you are right !!!mixing languages could cause unknow and uncontrolled problems !!! if a developer has to mix ....the practical way is to create a new project with different language and what will be absolutely fine !!!thanks mkamoski for raising this issue !!Fadil Alnassar www.fadilalnassar.com | FREE Nodil Tab Controlhttp://www.mefranchisi...

Help Me C# is working But VB.net Not working
Edited by SomeNewKid. Please post code between <code> and </code> tags. Pls, Help me, It is simple chat programe. My <IFRAME> src is calling the bellow event in C# it is working perfectly. private void Page_Load(object sender, System.EventArgs e) { string sDealer=""; string sWrite=""; if ( Session["Channel"] != null ) sDealer = Session["Channel"].ToString(); Response.Write( "<meta http-equiv=\"Refresh\"content=\"4\">" ); sWrite=MyModule.MyChat.GetAllMessages(sDealer); Response.Write(sWrite); } VB.net code..... Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Dim sDealer As String = "" Dim sWrite As String = "" If (Session.Item("Channel") <> "") Then sDealer = Session.Item("Channel").ToString() End If Response.Write("<meta http-equiv=Refresh content=4>") sWrite = MyClass.MyChat.GetAllMessages(sDealer) Response.Write(sWrite) End Sub the above VB code is not writting in iframe solution pls shekhar Dear Shekhar, Change your code as follows:- Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) ...

vb.net vs c#.net vs j#.net
just out of curiousity which looks, acts most like java? i'm still learning trying to used to vb.net but it seems that it was easier to do some stuff with java. C# is Java++ in my opinion. If you have done C or Jave you will prefer C#.Mike Schellenberger - MCAD If you are looking for language similar to java go for J#. However most code samples you find on the net will be in VB.NET and C#....

how can i write this line using vb.net : container.dataitem ?.... in vb.net its not working
Dim container As GridView = CType(newLinkButton.NamingContainer, GridView) Dim dataValue As Object = DataBinder.Eval(container.dataitem, _ColName)   _ColName its just a string a name of the field in my database   This is Vb.Net code man what you want? You can convert any format from this link http://www.developerfusion.com/tools/convert/vb-to-csharp/  If this post is answer of your question then don't forgot to Click Mark As Answer...

C#.NET or VB.NET
what lang does everyone prefer? Thanks, Peter Iuvara, MCP It's a very famous debatable question in forums! I would say if you are from Java/C/C++, then C# would be easy to use for you. If you are from ASP/VB, then VB.NET would be easy for you! As long as if you follow CLS, then what ever the language you use, it's going to be the same for CLR!Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti I would agree with that ... just curious as to what user's on this forum predominantly code in?Thanks, Peter Iuvara, MCP I came from no real programming background, started i...

VB.Net To C#.Net
Hello... Since Last from 1 year i had develope web application in using vb.net now i want to transfer from vb.net to c#.net so what should i do to transform to c# language any link or book related to me through i can easily understand and coding using c# in a short time... Thanks~ Mark As Answer If UseFull ~Kaushal. Hi, you can read the specifications of the language. You're already familiar with .NET and how to program in an OO manner thanks to your experience with vb.net. The only thing you need to learn is the new syntax of C#. You can also convert parts of your v...

vb .net or c# .net
I currently develop websites using php but have been requested to develop a site using asp.net. The question I have is for someone who knows php would it be better to transition to vb.net or c#.net? Thanks, Fr. Robert C# -> There is a converter that will transition about 60% or more of your PHP code to C#. Plus C# is closer to PHP than VB.NET.Jason N. GaylordASPInsider and Microsoft MVPhttp://jasongaylord.com...

What are the diff. visual basic 6 and vb.net ? How to convert the VB6 project to vb.net proj ?
What are the diff. visual basic 6 and vb.net ? How to convert the VB6 project to vb.net proj ? with code and interface too. There are entire forums dedicated to the differences between the two, and to convert your projects you should try the upgrade wizard in Visual Studio....

How to allow multiple people to work on same project ? (VB.NET w/ Visual Studio.NET Pro)
Hey All, I just recently purchased Visual Studio.NET 2003 Professional as both my boss and I are going to be jointly working on a project. We are having troubles figuring out how to allow eachother to work on the same project though. Ideally, we would be able to either share a folder, or put the project on our network drives, and work on the project at the same time. How can this be done? THanks This was the answer: You need Microsoft SourceSafe. This software can be purchased seperately, or you can get it when its included with VS 2003/2005 Enterprise Edition ...

vb.net code works but not c# code
Hello, I'm trying to insert the metatags dynamically. The following vb code works fine: aspx.vb code: Protected myTag As System.Web.UI.HtmlControls.HtmlGenericControl Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load myTag.Attributes("content") = "test" End Sub In aspx file head: <meta id="myTag" runat="server" /> The above code is working great. But the same thing I'm trying to put in C# which is not working. aspx.cs code: ...

Access Net work mapped drive VB.NET
Hi I have a docuemnt mangemnt system coded in VB.NET. The system sometimes needs to get documents from Network mapped drive and shared drives. In development machine everything works fine. But when I moved the code to Test serever, it could not access the mapped drives. I tried all security settings. But still could not. I tried unc path, but it throws In valid user exception. Can anybody help m eto solve this issue. Thank you Jikk Hi Jikk, What login is your app running under? Whichever it is, it has to have permission to access the network, which ASPNET doesn'...

VB.NET vs. C#.NET Behavior of Visual Studio
I'm transitioning from coding in VB to coding in C#. Maybe I have something set wrong, but a behavioral difference is driving me bananas. When I edit a VB source file, the two drop-downs at the top of the edit view are Class Name and Method Name, and it makes it easy to add a new event handler for any of the controls on the page. Choose which one on the left, pick your event on the right, and VS inserts an empty, properly formatted subroutine. In C# mode, however, those two drop-downs are labeled Types and Members, and there doesn't appear to be a way to tell it to create the empty framew...

Catch events in javascript from .NET usercontrol works in VB.Net
I've created a vb.net Windows Forms control that I've got working hosted in IE using the implementation found here: http://support.microsoft.com/default.aspx?scid=kb;en-us;305624 and here http://msdn.microsoft.com/library/default.asp?url=/msdnmag/issues/02/01/UserCtrl/TOC.asp I can access my properties and methods from javascript with no problem.  I tried to raise events in my UserControl and catch them in the HTML with javascript but I couldn't get it to work. The second article above on msdn explains how to source events from C#, but I need to get it working in VB.Net. A...

vb.net and c#.net same app
Been asked before, but... If I build a c# web app and someone builds a vb.net desktop app, can they communicate? and can you develop against it...ie..in my c# web app, can I add the vb.net desktop app as a reference? or at least make calls to it? web apps or desktop apps can contain components created in either language. i have a web solution that contains 4 projects. One of the projects is C# the others are VB.Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/ Thanks...that is what I was looking for ...

Difference Between VB.Net And C#.Net
 hi friends,Please tell me the key difference between the Vb.Net And C#.Net..wheather vb.net supports operator overloading..Thanks & Regards,Pravin Kumar T.   Regards,Pravin Kumar T. pravin_thanusu:Please tell me the key difference between the Vb.Net And C#.Net.. Neither are ASP.NET so you probably want a different forum.  You'll also find your answers at Microsoft.com. JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.  >Please tell me the k...

Converting from vb.net to c#.net
Hello I have recently purchased VBGolds RawDataPrinter which should allow users to print directly to label printers on our network directly from a c# web form.  Unfortunately they only supply vb.net examples and I have need of c#.  The component has been installed on our web server.  This is some code that they have supplied as examples in vb.net   "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" >"Head1" runat="server&qu...

use of vb.net and c#.net
i make a small website using vb.net,  in it i make a 2 class in C#.net. that i want to use in that website, i dont know how to call that class. let your class is  - class clsMyClass    {        public void myFunction()        {            // do something        }    } now the first way - create objectclsMyClass myObj = new clsMyClass();myObj.myFunction(); // call function================...

Visual Studio.Net and VB.Net
Can we install VS.Net and VB.Net on the same machine and work side by. Is there any thing I need to worry about? I use VS.Net enterprise for my office work and I am planning to buy VB.Net standard for my personal use. Before I goahead and buy, I wanted to make sure that it works. Thanks for your help. Anil...

FIX: The IntelliSense feature for a Visual C# .NET project stops working in the Visual Studio .NET IDE
Ever got mad because your IntelliSense disappeared? Microsoft finally heard you: http://www.kbalertz.com/Feedback_838470.aspx or: http://support.microsoft.com/default.aspx?scid=kb;EN-US;838470 MCSD, MCDBA, MCAD, MCSD .NET, MSF Practitioner...

Both C# ASPX pages and VB.NET ASPX in single VB.NET Web Applcation Template
Hi.. Is it possible to have both c# pages and VB pages in same Webapplication, what i chose is VB.NET Web application Template. With Thanks, Jaya.... I don't see why you couldn't, but for the sake of consistency I don't know why you would want to do this. When you choose a C# or VB.NET application template(I'm assuming you're using VS or WebMatrix), it simply creates a .aspx file that includes a page directive that specifies the page language. If you created a C# template but want to use VB.Net instead, you need to go from: <%@ Page Language="C#" .... to...

Upgrade VB.net 2002 to VB.net 2003
Hi, i want to upgrade VB.net 2002 to VB.net 2003.what is the procedure?Uninstall 2002 and Install 2003 or something else? VB.net 2003 includes Framework 1.1 or i will install it separately?thanx in advance ...

Integrating the C#.net and VB.net application
Hello All,  I'm trying to integrate the C#.net application and VB.net application.  Can you give me any suggestions of how to merge them.  Thanks in Advance You are probably goign to have to convert one of the applications to the other language at one point.  There are online conversion tools to help http://www.carlosag.net/Tools/CodeTranslator/- WilliamPlease mark the most helpful reply/replies as "Answer".Give some of my PWSK modules a try.  Type of application?We All move to our original place.Don't forget.Imran Baloch @weighfield: I d...

Web resources about - Type.GetType does not work in VB.NET but works in C#. VB.NET gurus Please help - asp.net.visual-basic.net

Hottest 'generics' Answers - Stack Overflow
... comma between )To get the Gen class through reflection, you must specify the full name of the type, including the namespace:var gen = asm.G ...

Java annotation - Wikipedia, the free encyclopedia
Classes, methods, variables, parameters and packages may be annotated. Unlike Javadoc tags, Java annotations can be reflective in that they can ...

filter provider - Robert Daniel Moore's Blog
Sometimes it’s necessary to use DependencyResolver.Current in your MVC code where there is code that can’t be simply injected using your dependency ...

SetProperty and GetProperty with C# Reflection
I'll make a post soon, comparing Ruby on Rails to C# with ASP.NET MVC, but this here is atomic and might be of help for one or two readers. If ...

Is it a bad practice to modify code strictly for testing purposes?
Developers weigh in on testing the software as-is versus making it easier to maintain.

Avanade xRM Blog
Avanade insight and thought leadership around Microsoft Dynamics xRM, CRM and industry issues faced within the Customer Relationship Management ...

Flexible configuration with Guice
... each property with a specific annotation: for (Property prop : Property.values() { Object value = PropertyConverters.getValue(prop.getType(), ...

Cute Little Abstractions
I'm refactoring several classes of over 2000 lines each. These are classic god-classes that mediate a handful of stubby little data-centric classes ...

Autocorrecting unknown actions using the Levenshtein distance
This weekend I prototyped an idea I had earlier this week: autocorrecting unknown actions in ASP.NET MVC. Handling unknown actions To give you ...

The Animated Pie Slice in Windows 8
March 30, 2012 New York, N.Y. Two of my favorite animation classes in the Windows Presentation Foundation are PointAnimationUsingPath and M ...

Resources last updated: 3/4/2016 10:58:22 AM