Extension Not loading

Dec 29, 2010 at 2:26 AM
Edited Oct 24, 2011 at 5:36 PM

Hello All,

I am using BlogEngine.NET

Website is hosted at: http://www.demo07.somee.com/

Server: Microsoft-IIS/6.0


When I go to http://www.demo07.somee.com/admin/Extension%20Manager/default.aspx

No extensions are displaying. Its blank.  Also when I go to posts I get

Object reference not set to an instance of an object.


Line 130:            {
Line 131: var settings = ExtensionManager.GetSettings("Recaptcha");
Line 132: return Convert.ToInt32(settings.GetSingleValue("MaxLogEntries"));
Line 133: }
Line 134: }



Widgets are working but the extensions are not.


I am having the


Load on Session Start.
void Session_Start(object sender, EventArgs e)
///Change Session Timeout to 20 minutes (if you need to)
Session.Timeout = 1;
/// Set a Session Start Time
/// This is only important to assure we start a session



Global File:



<%@ Application Language="C#" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Web.Configuration" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="BlogEngine.Core" %>
<%@ Import Namespace="BlogEngine.Core.Web.Controls" %>
<%@ Import Namespace="BlogEngine.Core.Web" %>

<script RunAt="server">
  /// <summary>
  /// Application Error handler
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>
    void Application_Error(object sender, EventArgs e)
        HttpContext context = ((HttpApplication)sender).Context;
        Exception ex = context.Server.GetLastError();
        if (ex == null || !(ex is HttpException) || (ex as HttpException).GetHttpCode() == 404)
        StringBuilder sb = new StringBuilder();

            sb.AppendLine("Url : " + context.Request.Url);
            sb.AppendLine("Raw Url : " + context.Request.RawUrl);

            while (ex != null)
                sb.AppendLine("Message : " + ex.Message);
                sb.AppendLine("Source : " + ex.Source);
                sb.AppendLine("StackTrace : " + ex.StackTrace);
                sb.AppendLine("TargetSite : " + ex.TargetSite);
                ex = ex.InnerException;
        catch (Exception ex2)
            sb.AppendLine("Error logging error : " + ex2.Message);

        if (BlogSettings.Instance.EnableErrorLogging)
        context.Items["LastErrorDetails"] = sb.ToString();
        context.Response.StatusCode = 500;
        // Custom errors section defined in the Web.config, will rewrite (not redirect)
        // this 500 error request to error.aspx.

    /// <summary>
    /// Hooks up the available extensions located in the App_Code folder.
    /// An extension must be decorated with the ExtensionAttribute to work.
    /// <example>
    ///  <code>
    /// [Extension("Description of the SomeExtension class")]
    /// public class SomeExtension
    /// {
    ///   //There must be a parameterless default constructor.
    ///   public SomeExtension()
    ///   {
    ///     //Hook up to the BlogEngine.NET events.
    ///   }
    /// }
    /// </code>
    /// </example>
    /// </summary>
    void Session_Start(object sender, EventArgs e)
	///Change Session Timeout to 20 minutes (if you need to)
        Session.Timeout = 1;
        /// Set a Session Start Time
        /// This is only important to assure we start a session

    /// <summary>
    /// Sets the culture based on the language selection in the settings.
    /// </summary>
    void Application_PreRequestHandlerExecute(object sender, EventArgs e)
        var culture = BlogSettings.Instance.Culture;
        if (!string.IsNullOrEmpty(culture) && culture.Equals("Auto"))
            CultureInfo defaultCulture = Utils.GetDefaultCulture();
            Thread.CurrentThread.CurrentUICulture = defaultCulture;
            Thread.CurrentThread.CurrentCulture = defaultCulture;

Java Blog

Dec 29, 2010 at 4:30 AM

Now when I first visit the website the extensions load and then it goes away.

Dec 29, 2010 at 6:16 AM

I'm not sure why you have Utils.LoadExtensions() in Session_Start.  And I'm not sure if that's related to the issue.

In the BE you download, Utils.LoadExtensions() is in Application_Start (not Session_Start).  It runs only the first time the application starts.  By having it in Session_Start, it will run MANY times.  Everytime a new person comes to your site, or a search engine hits your site, etc, Session_Start will fire, which runs Utils.LoadExtensions().  Utils.LoadExtensions() is an expensive operation in that it goes thru all the assemblies, uses reflection to find information on them (expensive), and then loads them into memory.  I haven't tested it, but it seems like this could lead to many instances of the same extension being in memory at the same time.

Dec 30, 2010 at 3:10 AM



I have a shared server "Free" hosting and when I have it in the Application_Start it says Permission denied. It tries to access with out first

logging in or something like that.


I have two other websites


http://blogengine07.info/    "GoDaddy" Free edition

http://aspspider.net/kbdavis07/           "AspSpider"


I have the same global file for those and they work fine.  


But, on the http://www.demo07.somee.com/  server it does not work.  It worked before but when I upgraded BE it doesn't work anymore.


Will try to put it in the app_start again and post the error message here.




Brian Davis

Dec 30, 2010 at 3:35 AM

This is the error that I get.  The entire website will not work with the Utils.LoadExtensions() in the app_start.


Is there another place to put the Utils.LoadExtensions() ?  


Using the most current Global.aspx file





Access to the path 'd:\DZHosts\LocalUser\cms07\www.demo07.somee.com\App_Data\datastore\extensions\AkismetFilter.xml' is denied.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path 'd:\DZHosts\LocalUser\cms07\www.demo07.somee.com\App_Data\datastore\extensions\AkismetFilter.xml' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating.

If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.    <--- Can changing this in the web.config fix this?

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:

Line 70:     void Application_Start(object sender, EventArgs e)
Line 71: {
Line 72: Utils.LoadExtensions();
Line 73: }
Line 74:

Dec 30, 2010 at 5:55 AM

Do you have read/write access to app_data and alll files/subfolders below?
It's stated in the installation documentation somewhere

I have seen the error before enabling write access (666 in filezilla) solved the problem

hth /Peter

Dec 30, 2010 at 6:54 AM

One possible reason for the "access to the path .... is denied" error message is because of more than one process accessing the file at the same time.  If one process has the file open, and another process tries to write to it, this could happen ... I believe.

If you have a chance, try temporarily deleting AkismetFilter.cs from the App_Code\Extensions folder, and continue to have LoadExtensions() be in Application_Start.  See if another error occurs, or if it just loads.

Dec 30, 2010 at 8:44 AM

Somee Says "It will not work in Application_Start.
You need to move your code somewhere else.



I do have complete write access after the application start

Dec 30, 2010 at 5:35 PM

Here's two things you can do which should work.  Abandon Application_Start, and use Session_Start, but change it so it looks like this:

private static readonly object _SyncLock = new object();
private static bool _StartupProcsRun = false;
void Session_Start(object sender, EventArgs e)
	if (!_StartupProcsRun)
		lock (_SyncLock)
			if (!_StartupProcsRun)
				_StartupProcsRun = true;

This will make sure that Utils.LoadExtensions() only fires once -- not every time a new person comes to the site.

Second, in order for Session_Start to run, you need to make sure that Session State is enabled in the web.config file.  By default with BE, it's disabled ... so Session_Start won't fire.  This could be related to the reason why you didn't see any extensions at one point.

<pages enableSessionState="true" ... >