473,503 Members | 11,435 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Determine full name of an object at runtime.

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

Nov 20 '05 #1
10 1434
"Lance" <zi***@hotmail.com> 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
Nov 20 '05 #2
"Lance" <zi***@hotmail.com> 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
Nov 20 '05 #3
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
Nov 20 '05 #4
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
Nov 20 '05 #5
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.

Nov 20 '05 #6
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.

Nov 20 '05 #7
"Lance" <an*******@discussions.microsoft.com> 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

Nov 20 '05 #8
"Lance" <an*******@discussions.microsoft.com> 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

Nov 20 '05 #9
Great suggestion. Thanks.
Nov 20 '05 #10
Great suggestion. Thanks.
Nov 20 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
2849
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
18
7687
by: Keith Brown | last post by:
I have an application that allows embedded storage of ANY chosen file in an OLE field. The file could have been dragged-and-dropped into the field or it might have been selected and imported...
3
3016
by: nfr | last post by:
I have a Singleton Model object that can be instantiated by different applications at runtime. This object activates a Channel using the config file in its constructor, which needs the name of the...
1
2273
by: Dan | last post by:
All, I am working on an application that allows users to track various items for various clients. For example Client A may have an object Box where Client B has an object Canister. When a user...
3
2203
by: Jordan | last post by:
I am dynamically inserting an html <input> tag as text (equivalent of an image button) into a page via a Literal control. Something like this gets inserted: <input type="image"...
10
855
by: Lance | last post by:
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...
3
11560
by: Developer in California | last post by:
I am working on developing a generic Web framework using Master Pages in ASP.NET 2.0. What I have done is created a PageRenderer class which has a public method which will retrieve the path of the...
4
2685
by: Bill Fuller | last post by:
I am trying to determine the type for ActiveControls using 3rd party controls (Infragistics in this case) during runtime and getting a rather odd return type at runtime for the UltraWinEditor. ...
3
2533
by: LordHog | last post by:
Hello, How would I go about finding the default handler, let's say a text file (*.txt), then launch the default handler with the file as an argument? I had found how to launch an external...
0
7067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
4992
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
371
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.