Fatal error: Call to a member function raw() on a non-object in
You could try something like this instead, checking if the field value is set first and catching the exception.

function _gocoop_services_get_app_instance($wrapper) {
  $instance_id = FALSE;
  try {
    // Check if wrapper field set first
    if (isset($wrapper-&gt;field_seller) &amp;&amp; isset($wrapper-&gt;field_seller-&gt;field_application_instance)) {
      $instance_id = $wrapper-&gt;field_seller-&gt;field_application_instance-&gt;raw();
    }
    if (!$instance_id) {
      $query = new EntityFieldQuery();
      $query-&gt;entityCondition('entity_type', 'application_instance')
          -&gt;entityCondition('bundle', 'application_instance')
          -&gt;fieldCondition('field_internal', 'value', 1);
      $result = $query-&gt;execute();
      if ($result['application_instance']) {
        $instance_id = reset(array_keys($result['application_instance']));
      }
    }
  } catch (EntityMetadataWrapperException $e) {
    watchdog_exception('gocoop', $e);
  }
  return $instance_id;
}


You might also want to use a static cache for $instance_id, but that would need to vary based on your $wrapper id value.