Re: Interesting Problem, what am I missing (WAS: Urgent pls -finding the assembly name from namespace).

Ivan Zderadička <[email protected]> Wed, 19 Jun 2002 12:30:43 +0200
Newsgroups gmane.comp.windows.devel.dotnet.general
Message-ID <[email protected]>
Mitch,
Problem is in the type name,
If it contains only type name, then the function GetType looks only in
the executing assembly and mscorelib assembly only. 
If you need Type from other assembly you have to specify the "fully
qualified type name" which also contains name of the assembly"
So it should look like
      
typeToFind = "System.ComponentModel.Component, System"

Look at detail on GetType method description in MSDN, it is described
there in more details.
Regards
Ivan
 

-----Original Message-----
From: Mitch Denny [mailto:[email protected]] 
Sent: 19. června 2002 8:08
To: [email protected]
Subject: [DOTNET] Interesting Problem, what am I missing (WAS: Urgent
pls -finding the assembly name from namespace).

Hi all/George,

Below is the code that I would have converted my C# sample into,
however George is quite correct, it doesn't seem to be working
at all. When executed, if it all works it should return a message
box giving the full assembly name for System.dll but it doesn't.

Probably best to read the code now so you know what I am jabbering
on about:

Imports FindAsmVB
Imports System
Imports System.ComponentModel
Imports System.Reflection
Imports System.Windows
Imports System.Windows.Forms

Namespace FindAsmVB

    Public Class EntryPoint

        Public Shared Sub Main()

            ' Declare locals.
            Dim typeToFind As String
            Dim typeReference As Type

                ' Try and find type.
            typeToFind = "System.ComponentModel.Component"
            typeReference = Type.GetType(typeToFind, False, True)
            If (typeReference Is Nothing) Then

                MessageBox.Show( _
                    String.Format( _
                        "Could not find type: {0} in loaded
assemblies.", _
                        typeToFind _
                        ) _
                    )

            Else

                MessageBox.Show( _
                    String.Format( _
                        "Found type: {0} in assembly: {1}.", _
                        typeReference.FullName, _
                        typeReference.Assembly.FullName _
                        ) _
                    )

                Trace.WriteLine(typeReference.Assembly.FullName)

            End If

        End Sub

    End Class

End Namespace

I thought that perhaps the System.dll assembly wasn't
getting loaded because I don't really need it, so I
inserted this diagnostic code up the top:

            Trace.Indent()

            Dim assm As System.Reflection.Assembly
            For Each assm In AppDomain.CurrentDomain.GetAssemblies()

                Trace.WriteLine(String.Format("Assembly: {0}",
assm.FullName))

                Trace.Indent()

                Dim modu As System.Reflection.Module
                For Each modu in assm.GetModules()

                    Trace.WriteLine(String.Format("Module: {0}",
modu.Name))

                Next

                Trace.Unindent()

            Next

            Trace.Unindent()

The output clearly shows that the System.dll assembly
is being loaded:

    Assembly: mscorlib, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
        Module: mscorlib.dll
    Assembly: FindAsmVB, Version=1.0.900.29656, Culture=neutral,
PublicKeyToken=null
        Module: FindAsmVB.exe
    Assembly: System, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
        Module: system.dll
    Assembly: System.Windows.Forms, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
        Module: system.windows.forms.dll
    Assembly: System.Xml, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
        Module: system.xml.dll

In fact, you look at the debug output in VS.NET or using
cordbg.exe you can see it there anyway without my trace
code. Basically I want to understand what I am doing wrong
here, perhaps some of the CLR gurus can help me out.

I'll give this question a shot here, and if that fails I
will try posting on the DOTNET-CLR list to see how I go.

----------------------------------------
- Mitch Denny
- [email protected]
- +61 (414) 610-141
-

-----Original Message-----
From: The DOTNET list will be retired 7/1/02
[mailto:[email protected]] On Behalf Of george antony
Sent: Wednesday, 19 June 2002 14:34
To: [email protected]
Subject: Re: [DOTNET] Urgent pls -finding the assembly name from
namespace


hi this is my code


 Dim mytype As Type
        mytype =
Type.GetType("System.ComponentModel.Component")
 MsgBox(mytype)

i am getting nothing in the msgbox
pls help on this. its very urgent for me now

regards
gan
--- Paul Gaske <[email protected]> wrote:
> That's a good start, but what about:
>
> >dim mytype as type=
> >type.gettype("System.Componentmodel.Component")
>
> Should be:
>
> Dim mytype as type =
> type.gettype("System.ComponentModel.Component")
>
> Note the capital 'M' for 'Model'.
>
> Cheers,
> Paul.
>
> -----Original Message-----
> From: Nicolas Benech
> [mailto:[email protected]]
> Sent: Wednesday, 19 June 2002 2:15 PM
> To: [email protected]
> Subject: Re: Urgent pls -finding the assembly name
> from namespace
>
>
> Chris meant that you have some typo in your code
> sample:
>
> > > dim x as system.refelction.assembly
> > > x=system.refelction.assembly.getassembly(mytype)
>
> System.Reflection.Assembly would work better... :)
>
>
> For what it's worth...
>
> Nicolas
>
>
> This message is for information purposes only and
> its content should not
> be construed as an offer, or solicitation of an
> offer, to buy or sell
> any banking or financial instruments or services and
> no representation
> or warranty is given in respect of its accuracy,
> completeness or
> fairness.  The material is subject to change without
> notice.  You should
> take your own independent tax, legal and other
> professional advice in
> respect of the content of this message. This message
> may contain
> confidential or legally privileged material and may
> not be copied,
> redistributed or published (in whole or in part)
> without our prior
> written consent.  This email may have been
> intercepted, partially
> destroyed, arrive late, incomplete or contain
> viruses and no liability
> is accepted by any member of the Credit Agricole
> Indosuez group as a
> result.  If you are not the intended recipient of
> this message, please
> immediately notify the sender and delete this
> message from your
> computer.
>
> You can read messages from the DOTNET archive,
> unsubscribe from DOTNET,
> or subscribe to other DevelopMentor lists at
> http://discuss.develop.com.
>
> You can read messages from the DOTNET archive,
> unsubscribe from DOTNET, or
> subscribe to other DevelopMentor lists at
http://discuss.develop.com.


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.