fix possible null ref exception when get function from weakreference object