Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 12th, 2006, 08:55 AM
Authorized User
 
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with namespaces & classes

Hi guys,

I have a DLL with a class named Test_Remoting with a namespace Testclass.The code is like this


    Dim tmp As Object
    tmp = System.Type.GetType("System.String")
    tmp = System.Type.GetType("TestClass.Test_Remoting")


The problem is when i write
     tmp = System.Type.GetType("System.String")
it returns a value but when I write
     tmp = System.Type.GetType("TestClass.Test_Remoting")
which refers to my class it refers to Nothing.
I have been breaking my head against this for a very long time.I simply cant und what is the problem.
Please guys help me out.

Thanks in advance.



 
Old October 12th, 2006, 03:11 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Please don't cross post the same message. Posting it once is more than enough.

That said, look at the docs for GetType:

http://msdn2.microsoft.com/en-us/library/system.type.assemblyqualifiedname(VS.80).aspx

You need to specify the assembly name in addition to the type. Untested, but something like this should work:
    Dim myType As Type
    Dim myAssembly As System.Reflection.[Assembly]
    Dim myObject As New MyClass()
    myType = myObject.GetType()

    myAssembly = System.Reflection.[Assembly].GetAssembly(MyClass.GetType())
    myType = System.Type.GetType("MyNamespace.MyClass," & myAssembly.FullName)

It's a bit too much code, and does already what you want at line 4. However, you need some way to get at the assembly's FullName.

I am sure there are smarter ways to do this, but this may get you in the right direction.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with the namespace & classes ayamas .NET Framework 2.0 2 November 25th, 2006 02:13 PM
Problems with namespace & classes ayamas Visual Studio 2005 0 October 12th, 2006 08:56 AM
Problems with namespaces (I think) hasanali00 BOOK: ASP.NET Website Programming Problem-Design-Solution 3 November 19th, 2005 02:05 AM
Namespaces, Schemas & XmlSerializer jinjer C# 0 February 3rd, 2005 06:01 AM
PhileIdentity & PhilePrincipal Classes chiefg BOOK: ASP.NET Website Programming Problem-Design-Solution 1 February 11th, 2004 06:39 PM





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