posts - 18, comments - 23, trackbacks - 1

My Links

News

This blog has moved to http://shailen.sukul.org

Article Categories

Archives

Post Categories

Things to watch out for when implementing a custom role provider

I recently implemented a custom role provider for an asp.net project and discovered an interesting point.

I had to instantiate a role business component in the custom provider class like so:

public class MyRoleProvider : RoleProvider

{

BLRole blRole = null;

public MyRoleProvider()

{

blRole = new BLRole();

}

All I could see on at runtime was:

Parser Error Message: Exception has been thrown by the target of an invocation.

I moved the instantiation code into the Initialize block and hey pretso, the IDE now told what was causing my error, ie the precached version of my business logic component was throwing the error!

public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)

{

// Verify that config isn't null

if (config == null)

throw new ArgumentNullException("config");

// instantiate the role business component

blRole = new BLRole();

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted on Sunday, July 30, 2006 4:57 PM | Filed Under [ ASP.Net 2.0 ]

Feedback

Gravatar

# re: Things to watch out for when implementing a custom role provider

It's very good tip. Now I know what the problem is.
4/29/2008 5:11 PM | hogan
Gravatar

# re: Things to watch out for when implementing a custom role provider

thank you, I was going crazy
10/20/2011 11:19 AM | cp
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: