Im trying to create custom properties on feature activated event, but it doenst work, does anyone has any suggestion, what the problem could be?

When i do a console application and try there my code it does work ... but here not, and i really dont have any idea, what the problem could be.

So i build a wsp package and deploy so then the feature activated should be excuted and custom properties are created.

Here is the code:

    public void Create(string url)
         //Code example adds a new property called ATest.
        using (SPSite site = new SPSite(url))
            SPServiceContext context = SPServiceContext.GetContext(site);
            UserProfileConfigManager upcm = new UserProfileConfigManager(context);

                ProfilePropertyManager ppm = upcm.ProfilePropertyManager;

                // create property
                CorePropertyManager cpm = ppm.GetCoreProperties();
                CoreProperty cp = cpm.Create(false);
                cp.Name = "ATest";
                cp.DisplayName = "ATest";
                cp.Type = PropertyDataType.StringMultiValue;
                cp.Length = 100;
                cp.IsMultivalued = true;

                // create profile type property
                ProfileTypePropertyManager ptpm = ppm.GetProfileTypeProperties(ProfileType.User);
                ProfileTypeProperty ptp = ptpm.Create(cp);
                ptp.IsVisibleOnEditor = true;
                ptp.IsVisibleOnViewer = true;

                // create profile subtype property
                ProfileSubtypeManager psm = ProfileSubtypeManager.Get(context);
                ProfileSubtype ps = psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User));
                ProfileSubtypePropertyManager pspm = ps.Properties;
                ProfileSubtypeProperty psp = pspm.Create(ptp);

                psp.IsUserEditable = true;
                psp.PrivacyPolicy = PrivacyPolicy.OptIn;
                psp.DefaultPrivacy = Privacy.Public;

            catch (Exception e)


Thanks in advance for the help

Small update: i've took a closer look to uls files after deploying the wsp package and didnt find anything bad.

This 2 logs that i found: 01/03/2012 13:20:52.22 OWSTIMER.EXE (0x1C04) 0x1A14 SharePoint Foundation General 88jb Medium Feature Activation: Activating Feature 'UserProperties' (ID: '208317db-d650-40ad-834b-38e0ed66585e'). 491b992c-14b7-4027-ab32-e7cbb899ba7f

01/03/2012 13:20:52.22 OWSTIMER.EXE (0x1C04) 0x1A14 SharePoint Foundation General 75fb Medium Calling 'FeatureActivated' method of SPFeatureReceiver for Feature 'UserProperties' (ID: '208317db-d650-40ad-834b-38e0ed66585e'). 491b992c-14b7-4027-ab32-e7cbb899ba7f

which i suppose saying that everything went good and wel

  • I'd recommend you to explore the ULS logs right after the feature activation attempt, grab the detailed exception message and the stack trace from there, and then paste it here. This will significantly help to determine the problem. Jan 3, 2012 at 12:06
  • But i dont know what is the error ... in uls i cant find any errors ... or there are many errors and stuff ... but i dont know which one is causing by my code ... If i knew i would solve the problem but i hhonestly dont know what is the problem
    – Igorok
    Jan 3, 2012 at 12:17

2 Answers 2


Is your automatic feature activation is ON? Sometime due to less privileges it gives error while activation. but it works when you manually activate that feature. [Applicable to VS-2010 only]




The account activating your feature needs to have administrative rights/Full control on the User Profile Service Application to be able to add new user profile properties.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.