Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3334020
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:51:33+00:00 2026-05-17T23:51:33+00:00

I am creating a custom membership provider class library that defines a data provider

  • 0

I am creating a custom membership provider class library that defines a data provider interface for my web projects to implement.

I am having an issue creating an instance of the class that implements the interface.

I added a line in my web.config to pull the data provider type out, but it is looking for that type inside the membership library (but its defined in my web project).

public class MvcRoleProvider : RoleProvider
{
    public string ConnectionString { get; set; }

    private IDataProvider _dataProvider;

    public override void Initialize(string name, NameValueCollection config)
    {
        var dataProviderType = config["dataProviderType"];
        ConnectionString = ConfigurationManager.AppSettings[config["connectionStringName"]];

        if (!string.IsNullOrEmpty(dataProviderType))
        {
            var type = Type.GetType(dataProviderType, true, true);

            if (type != null && !string.IsNullOrEmpty(ConnectionString))
                _dataProvider = (IDataProvider)Activator.CreateInstance(type, ConnectionString);
        }
    }

Web.config

    <roleManager enabled="true" defaultProvider="WebTestRoleProvider">
  <providers>
    <clear />
    <add name="WebTestRoleProvider"
         applicationName="WebTest"
         type="MvcMembership.MvcRoleProvider, MvcMembership"
         dataProviderType="MyWebNameSpace.MyWebProject.DataProviderClassName"
         connectionStringName="TheConnectionStringName" />
  </providers>
</roleManager>

The error:

Parser Error Message: Could not load type 'MyWebNameSpace.MyWebProject.DataProviderClassName' from assembly 'MvcMembership, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Am I taking the right approach to this? If I want generic custom membership library, shouldn’t I be implementing the appropriate data provider in my web/data projects (in this example I am making one in web for testing)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:51:34+00:00Added an answer on May 17, 2026 at 11:51 pm

    I ended up using Assembly.CreateInstance like so:

    Factory:

        public class DataProviderFactory
    {
        public IDataProvider GetProvider(string assemblyName, string type, string connectionString)
        {
            var assembly = System.Reflection.Assembly.Load(new AssemblyName(assemblyName));
            return (IDataProvider)assembly.CreateInstance(type, true, BindingFlags.CreateInstance, null, new object[]{ connectionString }, null, null);
        }
    }
    

    RoleProvider:

     public class MvcRoleProvider : RoleProvider
    {
        public string ConnectionString { get; set; }
    
        private IDataProvider _dataProvider;
    
        public override void Initialize(string name, NameValueCollection config)
        {
            DataProviderFactory factory = new DataProviderFactory();
            _dataProvider = factory.GetProvider(config["dataProviderAssembly"], config["dataProviderType"], ConfigurationManager.AppSettings[config["connectionStringName"]]);
    
            base.Initialize(name, config);
        }
    

    With the following settings in web.config:

    <roleManager enabled="true" defaultProvider="MvcRoleProvider">
      <providers>
        <clear />
        <add name="MvcRoleProvider"
             applicationName="MyWebNameSpace"
             type="MvcMembership.MvcRoleProvider"
          dataProviderType="MyWebNameSpace.MyWebProject.DataProviderClassName"              dataProviderAssembly="EmailService.Web.EmailAdmin"
             connectionStringName="MyMembershipConnection" />
      </providers>
    </roleManager>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a custom membership provider for a web app that already has
I am creating custom membership provider for my asp.net application. I have also created
I'm implementing my custom Membership provider and I need to implement some additional fields
I'm looking at creating a custom membership provider in ASP.Net MVC3 and am struggling
I'm creating a Custom Membership Provider to be shared across all my MVC3 and
I'm writing a custom membership provider that uses LINQ to manage my users. I'm
I am having some problems creating custom types for my data table, using jquery.datatables.js.
I am working on creating a custom membership class for my asp.net project. In
i am creating custom listview. passing data to the edittext . at that time
Jython is great for creating custom data structures on need basis, but how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.