Get the DeclarationHeader of all Events of a Class at Runtime. 
Author Message
 Get the DeclarationHeader of all Events of a Class at Runtime.

Hello

I like to get the DeclarationHeader of all Events of a Class at Runtime.

I get the Informations with this Code but I can not find out
if the Varaiable is  ByRef or ByVal.

The "isout" Parameter doesn't work.....

How can i get this ?

Is there an easierway to get the Header ??

Here's my Code

Dim e As EventInfo
Dim m As MethodInfo
Dim p As ParameterInfo()
dim  ParName as string
dim  ParType as string

For Each e In MyType.GetEvents()

    m = e.EventHandlerType.GetMethod("Invoke")

    for each p in  m.GetParameters()
        ParName = ps.Name
        ParType  = ps.ParameterType.FullName
    next

next



Tue, 26 Apr 2005 23:36:56 GMT  
 Get the DeclarationHeader of all Events of a Class at Runtime.
Have you tried System.Reflection.Assembly?

You can enumerate through them with GetTypes()

HTH


Quote:
> Hello

> I like to get the DeclarationHeader of all Events of a Class at Runtime.

> I get the Informations with this Code but I can not find out
> if the Varaiable is  ByRef or ByVal.

> The "isout" Parameter doesn't work.....

> How can i get this ?

> Is there an easierway to get the Header ??

> Here's my Code

> Dim e As EventInfo
> Dim m As MethodInfo
> Dim p As ParameterInfo()
> dim  ParName as string
> dim  ParType as string

> For Each e In MyType.GetEvents()

>     m = e.EventHandlerType.GetMethod("Invoke")

>     for each p in  m.GetParameters()
>         ParName = ps.Name
>         ParType  = ps.ParameterType.FullName
>     next

> next



Wed, 27 Apr 2005 01:53:02 GMT  
 Get the DeclarationHeader of all Events of a Class at Runtime.
Who do I have to do this ?

I thought that's excatly what i do now with the Code......

Quote:
> > Dim e As EventInfo
> > Dim m As MethodInfo
> > Dim p As ParameterInfo()
> > dim  ParName as string
> > dim  ParType as string

> > For Each e In MyType.GetEvents()

> >     m = e.EventHandlerType.GetMethod("Invoke")

> >     for each p in  m.GetParameters()
> >         ParName = ps.Name
> >         ParType  = ps.ParameterType.FullName
> >     next

> > next



- Show quoted text -

Quote:
> Have you tried System.Reflection.Assembly?

> You can enumerate through them with GetTypes()

> HTH



> > Hello

> > I like to get the DeclarationHeader of all Events of a Class at Runtime.

> > I get the Informations with this Code but I can not find out
> > if the Varaiable is  ByRef or ByVal.

> > The "isout" Parameter doesn't work.....

> > How can i get this ?

> > Is there an easierway to get the Header ??

> > Here's my Code

> > Dim e As EventInfo
> > Dim m As MethodInfo
> > Dim p As ParameterInfo()
> > dim  ParName as string
> > dim  ParType as string

> > For Each e In MyType.GetEvents()

> >     m = e.EventHandlerType.GetMethod("Invoke")

> >     for each p in  m.GetParameters()
> >         ParName = ps.Name
> >         ParType  = ps.ParameterType.FullName
> >     next

> > next



Wed, 27 Apr 2005 02:55:32 GMT  
 Get the DeclarationHeader of all Events of a Class at Runtime.
Try this:

Dim t As Type

Dim eo As System.Reflection.EventInfo

Dim m As System.Reflection.MethodInfo

Dim p As System.Reflection.ParameterInfo

Dim ParName As String

Dim ParType As String

Dim myAssemblies As [Assembly]() = Thread.GetDomain().GetAssemblies()

' Get the dynamic assembly named 'MyAssembly'.

Dim myAssembly As [Assembly] = Nothing

Dim i As Integer

For i = 0 To myAssemblies.Length - 1

If [String].Compare(myAssemblies(i).GetName().Name,
Application.ProductName.ToString()) = 0 Then

myAssembly = myAssemblies(i)

Console.WriteLine(myAssembly)

For Each t In myAssembly.GetTypes()

For Each eo In t.GetEvents()

m = eo.EventHandlerType.GetMethod("Invoke")

Console.WriteLine(m.Name.ToString)

For Each p In m.GetParameters()

ParName = p.Name

ParType = p.ParameterType.Name

Console.WriteLine(ParName.ToString())

Console.WriteLine(ParType.ToString())

Next

Next

Next

Exit For

End If

Next



Wed, 27 Apr 2005 06:20:19 GMT  
 Get the DeclarationHeader of all Events of a Class at Runtime.


Quote:
> Who do I have to do this ?

> I thought that's excatly what i do now with the Code......

> > > Dim e As EventInfo
> > > Dim m As MethodInfo
> > > Dim p As ParameterInfo()
> > > dim  ParName as string
> > > dim  ParType as string

> > > For Each e In MyType.GetEvents()

> > >     m = e.EventHandlerType.GetMethod("Invoke")

> > >     for each p in  m.GetParameters()
> > >         ParName = ps.Name
> > >         ParType  = ps.ParameterType.FullName
> > >     next

> > > next



> > Have you tried System.Reflection.Assembly?

> > You can enumerate through them with GetTypes()

> > HTH



> > > Hello

> > > I like to get the DeclarationHeader of all Events of a Class at
Runtime.

> > > I get the Informations with this Code but I can not find out
> > > if the Varaiable is  ByRef or ByVal.

> > > The "isout" Parameter doesn't work.....

> > > How can i get this ?

> > > Is there an easierway to get the Header ??

> > > Here's my Code

> > > Dim e As EventInfo
> > > Dim m As MethodInfo
> > > Dim p As ParameterInfo()
> > > dim  ParName as string
> > > dim  ParType as string

> > > For Each e In MyType.GetEvents()

> > >     m = e.EventHandlerType.GetMethod("Invoke")

> > >     for each p in  m.GetParameters()
> > >         ParName = ps.Name
> > >         ParType  = ps.ParameterType.FullName
> > >     next

> > > next



Wed, 27 Apr 2005 06:19:12 GMT  
 Get the DeclarationHeader of all Events of a Class at Runtime.
Hello Richard

thanx for your help.

I am still not knowing now
if the Variable is "By Reference" or "ByValue"......

That was the main Problem.....

To find out the Variables an Types works
with my Code same way as with yours.....

Micha



Quote:
> Try this:

> Dim t As Type

> Dim eo As System.Reflection.EventInfo

> Dim m As System.Reflection.MethodInfo

> Dim p As System.Reflection.ParameterInfo

> Dim ParName As String

> Dim ParType As String

> Dim myAssemblies As [Assembly]() = Thread.GetDomain().GetAssemblies()

> ' Get the dynamic assembly named 'MyAssembly'.

> Dim myAssembly As [Assembly] = Nothing

> Dim i As Integer

> For i = 0 To myAssemblies.Length - 1

> If [String].Compare(myAssemblies(i).GetName().Name,
> Application.ProductName.ToString()) = 0 Then

> myAssembly = myAssemblies(i)

> Console.WriteLine(myAssembly)

> For Each t In myAssembly.GetTypes()

> For Each eo In t.GetEvents()

> m = eo.EventHandlerType.GetMethod("Invoke")

> Console.WriteLine(m.Name.ToString)

> For Each p In m.GetParameters()

> ParName = p.Name

> ParType = p.ParameterType.Name

> Console.WriteLine(ParName.ToString())

> Console.WriteLine(ParType.ToString())

> Next

> Next

> Next

> Exit For

> End If

> Next



Wed, 27 Apr 2005 11:17:32 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Not getting Events from classes within classes.

2. Getting the properties of VB class at runtime

3. Make your class fire an Event ( custom class event, RaiseEvent )

4. How to add a button event handler at runtime from external class

5. Class raising an event from another class?

6. Raising events from a class within a collection class

7. Instantiating a class in another class with events

8. The way of getting another event during processing of a event

9. Retrieve name of Function, Sub, Class, Property etc from within that item during runtime

10. Resolve class name on runtime

11. Runtime Error 713 Class Not Registered

12. VB5 Setup Wizard RunTime error 713 Class not Registered

 

 
Powered by phpBB® Forum Software