As speschka has pointed out, TopologyManager, PortalSite and PortalContext are obsolete classes (from SharePoint 2003). Instead, you should use ServerContext when invoking the UserProfileManager. Here is a useful snippet to achieve this:
using Microsoft.Office.Server;
...
using (SPSite site = new SPSite("http://servername")) {
ServerContext svrContext = ServerContext.GetContext(site);
UserProfileManager userProfileManager = new UserProfileManager(svrContext);
... do something here ...
}