473,569 Members | 2,839 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.MyC lass.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 860
"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.MyC lass.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.MyC lass.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.WriteLi ne(o.GetType(). ToString)
For Each b As System.Reflecti on.FieldInfo In o.GetType().Get Fields()
If Object.Referenc eEquals(c, b.GetValue(o)) Then
Console.WriteLi ne(b.Name)
End If
Next
Console.WriteLi ne(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.WriteLi ne(o.GetType(). ToString)
For Each b As System.Reflecti on.FieldInfo In o.GetType().Get Fields()
If Object.Referenc eEquals(c, b.GetValue(o)) Then
Console.WriteLi ne(b.Name)
End If
Next
Console.WriteLi ne(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*******@disc ussions.microso ft.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*******@disc ussions.microso ft.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

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

Similar topics

18
2865
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 that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the...
18
7699
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 programmatically using the common file dialog. Regardless, I need to determine the filetype/extension of each of these files already stored in my OLE...
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 config file as a string. Because the object does not know the application in which it is being instantiated and because it's constructor is...
1
2279
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 goes to enter a new object I would like the application to determine what objects are available based upon the client (easy enough) and when they...
3
2209
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" name="MyImageButton" id="MyImageButton" src="somePic.jpg" /> I want for the code-behind to "know" when the user clicked on the image - but I don't want to also...
10
1445
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 any type End Clas End Namespac then I want a function that would return the string, "RootNamespace.MyNameSpace.MyClass.MyObject" if I passed...
3
11566
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 content I want to execute based on the name of the asp:Content control. As shown in the code snippet below, to get the content I want to display,...
6
4254
by: William | last post by:
for example, I have a global object: extern Object myobj; Can gcc get this object by using string "myobj" at runtime?? I know C++ rtti doesnt support this, but I dont know if gcc can , thanks in advance.
4
2689
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. Code shippet is as follows: if ( ActiveControl.GetType() == typeof(UltraTextEditor)) { UltraTextEditor tb = (UltraTextEditor) this.ActiveControl;...
3
2540
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 program, but I do not know how I would find the default handler to a file type. Any help is greatly appreciated. Code to launch application:...
0
7695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7922
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5218
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2111
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 we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.