LoadProviderConfiguration()方法出错BUG修改方法
错误信息:
[NullReferenceException: 未将对象引用设置到对象的实例。]
AspNetForums.Components.ForumsDataProvider.LoadProviderConfiguration() +37
AspNetForums.Components.ForumsDataProvider.Instance(HttpContext context, String providerTypeName, String databaseOwner, String connectionString) +567
AspNetForums.Components.ForumException.Log() +20
AspNetForums.ForumsHttpModule.Application_BeginRequest(Object source, EventArgs e) +396
System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +60
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87
这个问题主要是由于Cache引起的。
修改方法:

Instance#region Instance
/**//// <summary>
/// Returns an instance of the user-specified data provider class.
/// </summary>
/// <returns>An instance of the user-specified data provider class. This class must inherit the
/// ForumsDataProvider interface.</returns>
public static ForumsDataProvider Instance() 
{
return Instance(HttpContext.Current, null, null, null);
}
public static ForumsDataProvider Instance (HttpContext context) 
{
return Instance(context, null, null, null);
}
public static ForumsDataProvider Instance (HttpContext context, string providerTypeName, string databaseOwner, string connectionString) 
{
// Use the cache because the reflection used later is expensive
//
Cache cache = HttpRuntime.Cache;
Type type = null;
// Get the names of the providers
//
ForumConfiguration config = ForumConfiguration.GetConfig();
// Read the configuration specific information
// for this provider
//
Provider sqlForumsProvider = (Provider) config.Providers[config.DefaultProvider];
// Read the connection string for this provider
//
if (connectionString == null)
connectionString = sqlForumsProvider.Attributes["connectionString"];
// Read the database owner name for this provider
//
if (databaseOwner == null)
databaseOwner = sqlForumsProvider.Attributes["databaseOwner"];
if (providerTypeName == null)
providerTypeName = ((Provider) config.Providers[config.DefaultProvider]).Type;
// In the provider instance in the cache?
//
if ( cache["DataProvider"] == null ) 
{
// The assembly should be in in or GAC, so we simply need
// to get an instance of the type
//
try 
{
type = Type.GetType( providerTypeName );
// Insert the type into the cache
//
Type[] paramTypes = new Type[2];
paramTypes[0] = typeof(string);
paramTypes[1] = typeof(string);
cache.Insert( "DataProvider", type.GetConstructor(paramTypes) );

}
catch 
{
if (context != null) 
{
// We can't load the dataprovider
//
StreamReader reader = new StreamReader( context.Server.MapPath("~/Languages/" + config.DefaultLanguage + "/errors/DataProvider.htm") );
string html = reader.ReadToEnd();
reader.Close();
html = html.Replace("[DATAPROVIDERCLASS]", config.DefaultProvider);
html = html.Replace("[DATAPROVIDERASSEMBLY]", config.DefaultProvider);
context.Response.Write(html);
context.Response.End();
}
else 
{
throw new ForumException(ForumExceptionType.DataProvider, "Unable to load " + config.DefaultProvider);
}
}
}
// Load the configuration settings
//
object[] paramArray = new object[2];
paramArray[0] = databaseOwner;
paramArray[1] = connectionString;
return (ForumsDataProvider)( ((ConstructorInfo)cache["DataProvider"]).Invoke(paramArray) );
}
#endregion