Re: how to find the type of an object represented by an interface



But you are not using any variable as reference, you are using "T" which has not been defined in that scope. Specify the actual type of the object that you want to create.

Random wrote:
Okay. Actually, I found the answer (seems I always stumble on it shortly after posting), but it led to another problem.

Sub GetNewObjectOfType(ByVal sender As IGenericInference)
Dim o As Object = sender
Dim T As Type = o.GetType()

'now, what I need to do is call a method that takes a generics argument
Dim newobject as Object = SomeObjectOfType(Of T)()
End Sub

Function SomeObjectOfType(Of T As IGenericInference)() As T
(code to create new object of type T)
End Function

Looks like I can't call SomeObjectOfType(Of T)() with a variable as a reference. Weird, because if T was passed into the Sub via a generics Of statement I would be able to pass it on.

"Milosz Skalecki [MCAD]" <mily242@xxxxxxxxxxxxxxxxx> wrote in message news:F0266DD5-BAE1-4288-A06D-A23D004BBBC9@xxxxxxxxxxxxxxxx
Show us the code
--
Milosz


"Random" wrote:

How can I use reflection (or some other method) to find the type of an
object that has been passed in to my method under an interface definition?

I try to use GetType, but that won't work.







--
Göran Andersson
_____
http://www.guffa.com
.



Relevant Pages

  • Re: Dynamic References to Word?
    ... Sub ListExcelReferences() ... Dim i As Long ... First set the reference manually in the VBE under Tools, ... On Error GoTo ERROROUT ...
    (microsoft.public.excel.programming)
  • Re: Dynamic References to Word?
    ... Sub ListExcelReferences() ... Dim i As Long ... .ColorIndex = xlAutomatic ... First set the reference manually in the VBE under Tools, ...
    (microsoft.public.excel.programming)
  • Re: Before Double Click
    ... Yes, but in the routine where you pass the object reference, you when you ... Dim rngVal As Range ... Sub EFG(ByVal r1 As Range, ByRef r2 As Range) ...
    (microsoft.public.excel.programming)
  • Re: Auto Load Add-In
    ... you posted that will unload the addin. ... Sub ListAddins() ... Dim adn As AddIn ... I also assume the reason you want to add a project reference to the addin to ...
    (microsoft.public.excel.programming)
  • Re: Auto Load Add-In
    ... I did manage to load the add-in into referencds after checking the option ... Why do you think excel is preventing me to simply test if a add-in reference ... Sub loadAddIn() ... Dim tempStr As String ...
    (microsoft.public.excel.programming)

Loading