Is the code used inside of the loop? The following code should work:
if ( class_exists( 'DPortfolio' ) ) {
echo DPortfolio::instance()->dportfolio_get_category();
}else{
the_category();
//or echo get_the_category();
}
If outside of the loop you can try echo get_the_category( $post_id )
to show the categories.
Note: As you are getting an error, if you edit the question, include the full code snippet with if/else
and include the error, then it’s easier to help.