-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: Pankil
Message 3 in Discussion

  
Hi,<o:p></o:p> 
 Please check following code. 
I have 2 managed dlls. <o:p></o:p> 
1. ABC.dll<o:p></o:p> 
2. XYZ.dll<o:p></o:p> 
<o:p> </o:p> 
XYZ.dll has a refrence of ABC.dll, which is installed in GAC.<o:p></o:p> 
<o:p> </o:p> 
I want to retrieve properties, methods and fields of XYZ.dll at run 
time.<o:p></o:p> 
<o:p> </o:p> 
I am using reflection to achieve this ... but when I try to use 
oAssembly.GetTypes() method I am getting ReflectionTypeLoadException 
error.<o:p></o:p> 
<o:p> </o:p>  
Code<o:p></o:p> 
<o:p> </o:p> 
    Private Sub Reflect()<o:p></o:p> 
        Dim oAssembly As [Assembly]<o:p></o:p> 
        Dim oTypes() As Type<o:p></o:p> 
        Dim i As Integer<o:p></o:p> 
<o:p> </o:p> 
        Try<o:p></o:p> 
            oAssembly = 
System.Reflection.Assembly.LoadFrom(“c:\test\xyz.dll”)<o:p></o:p> 
            oTypes = oAssembly.GetTypes ‘This line gives error<o:p></o:p> 
        Catch fnf As FileNotFoundException<o:p></o:p> 
            MessageBox.Show("Could not load Assembly: {0}", 
txtFile.Text)<o:p></o:p> 
            Exit Sub<o:p></o:p> 
        Catch tl As ReflectionTypeLoadException<o:p></o:p> 
            MessageBox.Show("Error in loading types")<o:p></o:p> 
            Exit Sub<o:p></o:p> 
        Catch ex As Exception<o:p></o:p> 
            MessageBox.Show("Error occured" + ex.Message)<o:p></o:p> 
            Exit Sub<o:p></o:p> 
        End Try<o:p></o:p> 
<o:p> </o:p> 
        For i = 0 To oTypes.Length - 1<o:p></o:p> 
            Dim fields() As FieldInfo = oTypes(i).GetFields()<o:p></o:p> 
            Dim f As FieldInfo<o:p></o:p> 
            If fields Is Nothing Then<o:p></o:p> 
<o:p> </o:p> 
            Else<o:p></o:p> 
                For Each f In fields<o:p></o:p> 
                    'Get fields<o:p></o:p> 
                Next<o:p></o:p> 
            End If<o:p></o:p> 
        Next<o:p></o:p>  
    End Sub<o:p></o:p> 
<o:p> </o:p> 
<o:p> </o:p> 
With error message as follows...<o:p></o:p> 
One or more of the types in the assembly unable to load.<o:p></o:p> 
<o:p> </o:p> 
I am wondering if this is the case ... how object browser is getting list of 
all types and methods and properties.<o:p></o:p> 
 <o:p></o:p> 
Is it possible to load types, methods and properties the way object browser 
displays?<o:p></o:p> 
 <o:p></o:p> 
Thanks,<o:p></o:p> 
Pankil<o:p></o:p>

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to