Type casting error in get_config_object

Hi,
I am new to OVM and I am trying to pass an interface from top to the environment through set_config_object and get_config_object.
Below is my code and I am getting the error:
OVM_INFO @ 0.001ns: ovm_test_top.m_env_h[0].mon_h[0] [mon_h[0]] Connect Phase …

OVM_ERROR @ 0.001ns: ovm_test_top.m_env_h[0].mon_h[0] [mon_h[0]] Cannot cast to vif container in dpe mon

** Fatal: (vsim-131) */monitor.sv(25): Null instance encountered when dereferencing ‘vif_mon’

Kindly help me out in this issue. Any help would be very useful to me since I am stuck here.
Thanks in advance,
Vimala

interface mon_if();
  logic a;
  logic b;
    modport master(input a,output b);
  modport slave(input a,input b);
endinterface

class my_virtual_container #(type VIF = int) extends ovm_object;
    `ovm_object_param_utils(my_virtual_container #(VIF))
    VIF vif_h;
Endclass

module top();
    mon_if mon_if_top;
  typedef my_virtual_container #(virtual mon_if) container;
  container vif_top;
    vif_top =  container::type_id::create(vif_top);
    initial
    begin
      vif_top.vif_h = mon_if_top;
      set_config_object("*","virtual_handle_t",vif_top.vif_h,.clone(0));
    end
   endmodule

class monitor #(type MON_IF_MP=int, type MON_IF) extends ovm_monitor;
  MON_IF_MP mon_if_mp_h;
  ovm_object tmp;
   typedef my_virtual_container #(MON_IF) container_mon;
  container_mon vif_mon;
    task run();
  get_config_object("virtual_handle_t",tmp);
    assert($cast(vif_mon,tmp))
     else ovm_report_error(get_name(),"Cannot cast to vif container in dpe mon"); 
  endtask
    mon_if_mp_h = vif_mon.vif_h;
endclass

class checker extends ovm_scoreboard;
    monitor #((virtual mon_if.slave),virtual mon_if);
    endclass

In reply to vimalambigai:

You will get a better error message if you use
$cast
without the
assert
. get_config_object returns true if it was set, and you can test
via_mon
to see if it is still null.

In reply to dave_59:

Thanks Dave for the response.

I got the issue fixed. The issue was in the parameter list where I was creating my monitor. I missed a parameter there and when I corrected that my issue got fixed.

Anyways your response will be a good hint for further debug.

Thank you.