SettingsPropertyValue settingsPropertyValue = new SettingsPropertyValue(settingsProperty); settingsProperty.PropertyType = typeof(string); //Must set the type to use the PropertyValue settingsPropertyValue.PropertyValue = "FooBar"; Assert.AreEqual("FooBar", settingsPropertyValue.PropertyValue);
If the SettingsProperty.PropertyType isn't set you will get a NullReferenceException when trying to access the PropertyValue.
See Also: Profile Provider Exception