title: EInvalidCast exception is raised when assign a procedure of object, via TRttiProperty.SetValue
body: <p>I'm trying assign a property which is of type <code>procedure of object</code> via rtti using the <code>TRttiProperty.SetValue</code> procedure, but this exception is raised when i try the made the assignment <code>EInvalidCast: Invalid class typecast</code></p>
  
  <p>This sample application shows the issue</p>
  
  <pre><code>{$APPTYPE CONSOLE}
  
  uses
   Rtti,
   SysUtils;
  
  type
    TMyCallBack = procedure (const Foo : string) of object;
    TMyClass    = class
      procedure DoSomething(const Foo: String);
    end;
  
    TMyAnotherClass  = class
    private
      FDoSomething: TMyCallBack;
    published
      property DoSomething : TMyCallBack read FDoSomething Write FDoSomething;
    end;
  
  { TMyClass }
  
  procedure TMyClass.DoSomething(const Foo: String);
  begin
    Writeln('Hello');
  end;
  
  Var
    MyClass : TMyClass;
    t       : TRttiInstanceType;
    v       : TValue;
    p       : TRttiProperty;
    Bar     : TMyCallBack;
  begin
    try
      MyClass:=TMyClass.Create;
      try
        t:=TRttiContext.Create.GetType(TMyAnotherClass).AsInstance;
        v:=t.GetMethod('Create').Invoke(t.MetaclassType,[]);
        p:=t.GetProperty('DoSomething');
        Bar:=MyClass.DoSomething;
        if p&lt;&gt;nil then
         p.SetValue(v.AsObject, @Bar); //here the exception is raised
      finally
       MyClass.Free;
      end;
    except
      on E: Exception do
        Writeln(E.ClassName, ': ', E.Message);
    end;
    Readln;
  end.
  </code></pre>
  
  <p>How i can fix this issue?</p>