B
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Root namespace of what?how do you find the root namespace at runtime?
Jay B. Harlow said:Bob,
Root namespace of what?
Jay B. Harlow said:Bob,
Have you tried using my second example?
For example to get the namespace of the main form class, you can use:
Dim [namespace] As String = GetType(MainForm).Namespace
MainForm is the name of your startup object (as set in Project Properties).
Hope this helps
Jay
Bob said:The project that created the currently executing assembly.
In the property pages of a project, available by right-clicking one one
and
selecting 'properties', under 'common properties'/'general' there is a
place
you can enter a 'Root Namespace'. I would like access to this at runtime.
Bob
No I meant exactly what I showed! Of course the above doesn't require you toYou mean something like this -
Dim asm As [Assembly] = System.Reflection.Assembly.GetEntryAssembly
MsgBox(asm.EntryPoint.DeclaringType.Namespace)
Then don't use the startup object, use a different class that is notBut there is no guarantee that the assembly's startup object is not
contained within a deeper namespace than the root.
Most of my projects have 2 or more namespaces for the root namespace, as theThe shortest Namespace will probably be
the root. Ugh, but again no guarantee...
Bingo!I guess I'll have to call this good enough.
Bob said:You mean something like this -
Dim asm As [Assembly] = System.Reflection.Assembly.GetEntryAssembly
MsgBox(asm.EntryPoint.DeclaringType.Namespace)
But there is no guarantee that the assembly's startup object is not
contained within a deeper namespace than the root.
Um... hmmm. I guess this will work if I make sure to exclude any types
from
referenced assemblies (not shown). The shortest Namespace will probably be
the root. Ugh, but again no guarantee...
Dim asm As [Assembly] = '<some assembly>
Dim Root As String
For Each t As Type In asm.GetTypes
If Root Is Nothing Then
Root = t.GetType.Namespace
Else
If Root.Length > t.FullName.Length Then
Root = t.FullName
End If
End If
Next
MsgBox(Root)
I guess I'll have to call this good enough.
Thanks,
Bob
Jay B. Harlow said:Bob,
Have you tried using my second example?
For example to get the namespace of the main form class, you can use:
Dim [namespace] As String = GetType(MainForm).Namespace
MainForm is the name of your startup object (as set in Project Properties).
Hope this helps
Jay
Bob said:Bob,
how do you find the root namespace at runtime?
Root namespace of what?
The project that created the currently executing assembly.
In the property pages of a project, available by right-clicking one one
and
selecting 'properties', under 'common properties'/'general' there is a
place
you can enter a 'Root Namespace'. I would like access to this at runtime.
Bob
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.