cast using reflection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chad Silva

    #1

    cast using reflection


    Hi all

    I have an object created via reflection of type CateringObject. FBO. I'm trying to assign it to a property that accepts objects of type CateringObject. IDeliveryDestin ation (which is implemented by CateringObject. FBO). When I try to set the property to an object of type FBO, I get a bad type error. Using reflection, how do I cast the FBO object to IDeliveryDestin ation? Any advice would be very appreciated

    Code snippet included below

    Thank
    Cha

    Type* IDeliveryDestin ationType = myAssembly->GetType(S"Cate ringObjects.IDe liveryDestinati on", true)
    Type* fboType = myAssembly->GetType(S"Cate ringObjects.FBO ", true)
    MethodInfo* pfnGetFBOByID = fboType->GetMethod(S"Ge tFBOByID")

    Object* fboParams[] = {connectionStri ng, __box(destinati onID)}
    Object* FBO = pfnGetFBOByID->Invoke(fboType , fboParams)

    //error on this line, Object does not match target typ
    orderInstance_D eliveryDestinat ion_Property->SetValue(order Instance, FBO, NULL);

  • Chad Silva

    #2
    RE: cast using reflection


    Nevermind. All that effort researching the wrong problem...turne d out to be a typo.

    Chad

    Comment

    Working...