PC Review


Reply
Thread Tools Rate Thread

Determine full name of an object at runtime.

 
 
=?Utf-8?B?TGFuY2U=?=
Guest
Posts: n/a
 
      7th Apr 2004
Is there any way to determine the full name of an object at runtime? For example, if I have the following

Namespace MyNameSpac
Public Class MyClas
Protected MyObject As Object 'This could be any type
End Clas
End Namespac

then I want a function that would return the string, "RootNamespace.MyNameSpace.MyClass.MyObject" if I passed MyObject to the function, where RootNamespace is the root namespace for the project

Thanks for any help
Lanc

 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      8th Apr 2004
"Lance" <(E-Mail Removed)> schrieb
> Is there any way to determine the full name of an object at runtime?
> For example, if I have the following:
>
> Namespace MyNameSpace
> Public Class MyClass
> Protected MyObject As Object 'This could be any type.
> End Class
> End Namespace
>
> then I want a function that would return the string,
> "RootNamespace.MyNameSpace.MyClass.MyObject" if I passed MyObject to
> the function, where RootNamespace is the root namespace for the
> project.


This is not possible. If you pass a reference to a function, the function
can not know where the reference was stored. Even if you'd pass it ByRef,
the function won't know of which object and which class and namespace the
referenced variable is part of.

What's your intention? I'm sure we'll find a solution.

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


 
Reply With Quote
 
=?Utf-8?B?TGFuY2U=?=
Guest
Posts: n/a
 
      8th Apr 2004
Thanks for the info

>What's your intention? I'm sure we'll find a solution


Having this feature would have allowed me to automate a part of my app, but implementing a work around is not difficult

Thanks again for your help
Lance
 
Reply With Quote
 
Peter Huang
Guest
Posts: n/a
 
      8th Apr 2004
Hi Lance,

I agree with Armin's suggestion. When we pass an object, we will not know
what class the object belong to, we have to do it ourself.

For a workaroud, You may try to pass the TestABC object in the meantime, so
that we know that.

e.g.
[TestCls]
Public Class TestABC
Public tls As ArrayList
Public tls2 As ArrayList
Public Shared Function Hello() As String
Return "Hello World"
End Function
End Class

[Module1.vb]
Dim o As New TestCls.TestABC
o.tls2 = New ArrayList
Dim c As Object
c = o.tls2
Console.WriteLine(o.GetType().ToString)
For Each b As System.Reflection.FieldInfo In o.GetType().GetFields()
If Object.ReferenceEquals(c, b.GetValue(o)) Then
Console.WriteLine(b.Name)
End If
Next
Console.WriteLine(o.Hello)




Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      8th Apr 2004
"Lance" <(E-Mail Removed)> schrieb
> Thanks for the info.
>
> >What's your intention? I'm sure we'll find a solution.

>
> Having this feature would have allowed me to automate a part of my
> app, but implementing a work around is not difficult.


Well, withouth details I can't help you any further. I hope your work around
is "better" than my/our solution would have been. ;-)


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

 
Reply With Quote
 
=?Utf-8?B?TGFuY2U=?=
Guest
Posts: n/a
 
      12th Apr 2004
Great suggestion. Thanks.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine whether an object is a VALID COM object abhimanyu Microsoft C# .NET 3 17th May 2008 12:58 AM
Determine if an object is accessible from another object Robert Schneider Microsoft VB .NET 0 18th Jun 2007 07:43 AM
Determine whether an object is derived from another object Mark Berry Microsoft C# .NET 9 16th Jun 2007 12:51 AM
Determine if an Object is convertible to double at runtime =?Utf-8?B?UnVzbGFuIFBvcG92?= Microsoft VC .NET 2 25th Jan 2006 03:15 AM
Determine if an object is initialized and Object Type ? François Uldry Microsoft Access Form Coding 1 16th Feb 2004 12:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:47 PM.