Blog Stats
  • Posts - 17
  • Articles - 2
  • Comments - 16
  • Trackbacks - 1

 

Sunday, July 30, 2006

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();

 

 

Copyright © Shailen Sukul