Thursday, January 8, 2015

What to do when getting error "Profile id _SELF_ is not registered." when working with p2 API

This came up while I was writing some code using p2 API to uninstall certain features at launch of my product. No matter what I did I was getting this dreaded message that made little sense to me. Well, it made some sense, but how do I register this _SELF_ profile? Turns out all I needed to do was to check checkbox "Support software installation in the launched application" in Configuration tab of Launch configuration. After this whenever the following code was executed, a Profile(SelfHostingProfile) would get returned.

IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
IProfile selfProfile = registry.getProfile(IProfileRegistry.SELF);
This forum post was a big help in resolving this issue. I wish the exception I was getting was more verbose as it seems the only fix for it is to check that checkbox.

Blogger Syntax Highliter