private MembershipSection GetMembershipSection()
{
MembershipSection section = new MembershipSection();
section.DefaultProvider = "default";
ConfigurationProperty _propProviders =
(ConfigurationProperty)typeof(MembershipSection).InvokeMember("_propProviders", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField, null, typeof(MembershipSection), null);
var collection = new System.Configuration.ProviderSettingsCollection();
collection.Add(new System.Configuration.ProviderSettings()
{
Name = "default",
Type = "MvcApplication3.Custom.CustomMembershipProvider, MvcApplication3"
});
// section[_propProviders] = collection;
typeof(ConfigurationElement).InvokeMember("SetPropertyValue", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod, null, section, new object[] { _propProviders, collection, false });
return(section);
}