Recaptcha Extension Error

Topics: Controls
Aug 9, 2010 at 6:22 AM

I just finished installing the latest version of Blogengine.net and put it in a sub-folder. The blog is using aspnetmembership everything seems to be working fine but when I try to create a new block or try to post a comment on existing blog it throws the error below:

I did some research online but couldn't find any solution please help me to find out wha am I doing wrong.

 

Thanks,

Davinder

Object reference not set to an instance of an object.

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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 100:            {
Line 101: ExtensionSettings Settings = ExtensionManager.GetSettings("Recaptcha");
Line 102: return Convert.ToInt32(Settings.GetSingleValue("MaxLogEntries"));
Line 103: }
Line 104: }

Nov 3, 2010 at 4:27 PM

I've also got this problem.

Can anyone shed any light on it please?

Nov 3, 2010 at 9:01 PM

It kind of looks like the settings for the Recaptcha are not initialized. 

You could try to change line 102 in the screenshot above to:

return 0;

Doing so will disable logging for the recaptcha control, but it should still work.  However, I have a feeling that there might be a bigger issue here, since all of the settings might be missing...

Nov 4, 2010 at 11:05 AM
Edited Nov 4, 2010 at 11:06 AM

Davinder,

 

It is because the Application_Start in global.asax is not run.

 

void Application_Start(object sender, EventArgs e)    {        Utils.LoadExtensions();    }

 

Solution would be either to check for ExtensionManager being uninitialized on first access either call Utils.LoadExtensions from your own Application_Start

 

Best Regards.

CS

 

Nov 4, 2010 at 5:37 PM

I have the same issue, I have integrated the blog into a sub folder of an existing program and Application_Start is not run. but I cant seem to get it to run.

In VS is I put a break point at the application_start it tells me that is will not be hit, no symbols have been loaded.

Anyone have any pointers?

 

 

 

Nov 5, 2010 at 6:11 PM
Edited Nov 5, 2010 at 6:23 PM

VirtualTap, try adding

 

void Application_BeginRequest (object sender, EventArgs e)
{
Utils.LoadExtensions();
}

 

to your global.asax file. I've found it gets called.

Anyway, this led me to another issue- I'm getting a SystemNullReferenceException here (on the public key):

(this is with 'return Convert.ToInt32(Settings.GetSingleValue("MaxLogEntries")); commented out and using 'return 0;' instead)

protected override void OnInit(EventArgs e)
{
base.OnInit(e);

ExtensionSettings Settings = ExtensionManager.GetSettings("Recaptcha");
publicKey = Settings.GetSingleValue("PublicKey");
privateKey = Settings.GetSingleValue("PrivateKey");
}

In recaptcha.cs, I have set the public key, so now I'm confused!

 

With 'return Convert.ToInt32(Settings.GetSingleValue("MaxLogEntries"));' not commented out, I get the same error as before, but I've seen that an error message shown in the debugger says "The verification words are incorrect".

Thanks in advance!

Nov 5, 2010 at 7:02 PM

Apologies to those whose inboxes are going to be packed with my responses!

I've just tried hard- coding my public and private key at the above points and found that the application falls over at the next line:

 

if (String.IsNullOrEmpty(Theme)) { Theme = Settings.GetSingleValue("Theme"); }

 

This makes me think that GetSettings method isn't being called properly. Anybody got any ideas?

Thanks!

Nov 5, 2010 at 7:07 PM

I have tried as you sugessted adding adding

void Application_BeginRequest (object sender, EventArgs e)
{
Utils.LoadExtensions();
}

to global.asax

after doing that with the program I am integrating the blog into (aspdotnetstorefront) I get the following

Server Error in '/' Application.
Could not load file or assembly 'file:///C:\inetpub\wwwroot\domain.com\Dev\bin\CybsWSSecurity.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
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.BadImageFormatException: Could not load file or assembly 'file:///C:\inetpub\wwwroot\domain.com\Dev\bin\CybsWSSecurity.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
Coordinator
Nov 5, 2010 at 7:10 PM

What version of BE are you using?  If you're using the default XML storage method, I would check the App_Data\datastore\extensions folder, find Recaptcha.xml and see if your settings (public/private keys, etc) are in there.  And check the timestamp on that Recaptcha.xml file to see if it's getting updated when you update the settings in the control panel.  These steps are not necessarily answers to the problem, but just things to check to make sure some of the basics are working.

Coordinator
Nov 5, 2010 at 7:11 PM

Do you have the blog installed in a subfolder?  It's trying to load CybsWSSecurity.dll which has nothing to do with BE (I've never heard of it).  This type of problem typically happens if you have another application installed on the website at the same time.

Nov 5, 2010 at 7:28 PM

Hi Ben,

I'm using version 1.6.1 and am using MySql Database storage.

I've added the keys to the .xml file manually (I can't get onto the settings page- see the thread about the XML parser error) but still no luck- it falls over on the public key line.

Thanks!

 

Nov 5, 2010 at 7:38 PM

I am using 1.6 and I am using DB Storage MSSQL

Yes I am installing the Blog into a subfolder I have

    <add key="BlogEngine.VirtualPath" value="~/blog/" /> set in the web.config.

I only get the CybsWSSecurity.dll error when adding

void Application_BeginRequest (object sender, EventArgs e)
{
Utils.LoadExtensions();
}

Otherwise my extensions just don't show up in the extensions manager

Coordinator
Nov 5, 2010 at 7:43 PM

It looks like there's conflicts between BE and aspdotnetstorefront.

Is the BE subfolder its own application within IIS ?  If so, I would take a look at this thread for modifications you can make to the parent web.config file (aspdotnetstorefront) to prevent its settings from propagating down to BE.

Nov 5, 2010 at 7:43 PM
Even with void Application_BeginRequest (object sender, EventArgs e) { Utils.LoadExtensions(); } my extensions don't show up in extension manager. Very confusing!
Nov 5, 2010 at 7:46 PM

Yes I do not have blog as a virtual application, it is integrated, the web.config is combined. everything works great other then the extensions not showing up

Coordinator
Nov 5, 2010 at 7:48 PM

Then I would add those <location> tags in the aspdotnetstorefront web.config file as documented here.

Nov 5, 2010 at 7:51 PM

Sorry I should have worded it differently.

There is only one web.config, the blog folder is not an application.

Coordinator
Nov 5, 2010 at 7:56 PM

I see.  Although I'm not entirely sure, it seems there's a high probability there could be conflicts between the two applications.

If possible, I would see if you can install the blog into its own subfolder, and make it a separate application (an application starting point).  That would separate the applications more and reduce or eliminate conflicts that may be occurring between the two applications.  If you do this, then using those <location> tags would be a good idea.

It's probably still possible to combine the two applications, but I'm not familiar with aspdotnetstorefront or its architecture, so am not sure what's needed to do to make them work together as a single application.

Nov 5, 2010 at 8:13 PM
Edited Nov 5, 2010 at 8:15 PM

I've just tried hard- coding the theme in too, which it accepts but then falls over further on (shown below). I think the problem is will referencing ExtensionManager and ExtensionSettings, but I don't know how to proceed.

public bool RecaptchaEnabled { get { ManagedExtension captchaExtension = ExtensionManager.GetExtension("Recaptcha"); return captchaExtension.Enabled; } }

The stack trace is as follows:

System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object." Source="JohnEpiscopoMagic" StackTrace: at Controls.RecaptchaControl.get_RecaptchaEnabled() in C:\Users\John\Documents\My Web Sites\JohnEpiscopoMagic\JohnEpiscopoMagic\JohnEpiscopoMagic\Blog\App_Code\Extensions\Recaptcha\RecaptchaControl.cs:line 80 at Controls.RecaptchaControl.OnInit(EventArgs e) in C:\Users\John\Documents\My Web Sites\JohnEpiscopoMagic\JohnEpiscopoMagic\JohnEpiscopoMagic\Blog\App_Code\Extensions\Recaptcha\RecaptchaControl.cs:line 308 at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) InnerException:

 

Any help is greatly appreciated!

Nov 5, 2010 at 8:27 PM

donpisci - Hard coding all of the properties is not really the solution here.  There is a much bigger problem, and the inability to read the settings is just a symptom of that problem. 

It does appear that for both of you, the BE.NET folder on your domain is not configured to be an application (this is a specific IIS setting ).  

You could try to copy all of the BE.NET DLLs from the bin folder into the main bin folder of the website, and merge the web.configs.  However, doing that has its own risks and is potentially much more difficult than simply converting the folder to an application.

Nov 5, 2010 at 10:47 PM
Thanks for getting back to me- really appreciate it! Looking at my IIS Manager, my BE.Net folder is a web application and is in the default application pool. I've just tried moving all of the BE.Net dlls to the main bin folder and am already using the web.config supplied with the MySql connection setup but I'm still getting the error. Thanks!
Coordinator
Nov 5, 2010 at 10:51 PM

If the BE.net folder is a web application (which is what I believe you're saying), then don't forget to try the <location> tags I mentioned a couple of times.

Nov 6, 2010 at 7:22 PM
Hi Guys, me again (sorry!)! I've added the location tags, but to no avail unfortunately. I've gone into IIS7 and made sure that it is an application too. I've also downloaded another copy of BE.Net (via the Web Platform Installer) and that works perfectly, but that's as a standalone blog. Thanks again!
Nov 7, 2010 at 12:00 AM

Hello All, if I am using DB datastorage should be_DataStoreSettings be populated with anyting other then the widgetzones?

I read a post that said change ExtensionType = "1" in the be_DataStoreSettings table for all existing extensions, this makes me think that there should be somthing there for all the extensions. if that is the case maybe that is why it is not showing up.

 

Coordinator
Nov 7, 2010 at 12:22 AM

The be_DataStoreSettings table is used to store both Widget data and Extensions data.

Extension data has an ExtensionType of 0, and Widget data has an ExtensionType of 1.

Nov 7, 2010 at 12:52 AM

So shouldn't their be extensions listed in be_DataStoreSettings then? if so how do they get loaded in the DB?, all I have is widget data.

i.e. if you install an extension, what script/code loads the info into the DB?

Thanks!

 



        
    
Coordinator
Nov 7, 2010 at 12:59 AM

The ExtensionManager works with the DbBlogProvider to save data in that table.

I'm not sure offhand when data is stored.  If you Edit and Save settings, data will get saved there.  When the blog first loads, sometimes data is stored/updated at that time too.

Nov 7, 2010 at 1:34 AM

I set up another blog, using SQL to see if be_DataStoreSettings was populated with extenstion data and indeed it is.

So the Db is not populated, that is part of my problem. But could still come back to Utils.LoadExtensions(); possibly not firing. I just don't know how to tell if that is getting fired or not.



        
    
Nov 14, 2010 at 2:48 PM
Edited Oct 24, 2011 at 9:36 PM

I found a solution to the Global Problem with the Utils.LoadExtensions();

 

Load it on Session start

 

 

void Session_Start(object sender, EventArgs e)
    {
        Utils.LoadExtensions();
    }

 

I had the same problem at my website:

http://www.blogengine.somee.com

 

Seems to work ok now.


Java Blog

Nov 15, 2010 at 7:26 PM

Thanks unfortunaly I get the same error I did when I tried

void Application_BeginRequest (object sender, EventArgs e)
{
Utils.LoadExtensions();
}
Perhaps it fixes it but I have another issue that appears after it is fixed
The error is specific to the application I am integrating with which is aspdotnetstorefront
Thanks
Mar 9, 2011 at 12:05 AM

I know this is an older post, but i felt that I should respond.

I had this exact issue, even after I added the Utils.LoadExtensions(); to the Application_Start();

The main problem you are having seems to be with the following line of code. BlogEngine.Core - Utils line 538.

                        assemblyName = "App_Code";

Change this to 

                        assemblyName = "Name of web app dll";

 

I have found many problems when trying to run the blog in a sub directory in a web application. There are many link references that had to be changed, and there are many places that references "~/" rather than Utils.RelativeWebRoot.

Hope this helps.

Mar 12, 2011 at 8:40 PM

I solved this by putting the blog dll in another directory and changing the path. but I like your solution.

Mar 21, 2011 at 6:25 AM

virtualtap:

can you explain your solution? another directory and changing path? did you modified on web.config?

Thanks

Mar 23, 2011 at 12:49 AM

@nagraman    sorry for the delay - no change in web.config you must have the source code,  I just left the bin folder with a copy of the blog dll's in the blog directory     (root/blog/bin) then I added ~/blog/ to this line in Utils.cs  string s = Path.Combine(HttpContext.Current.Server.MapPath("~/blog/"), "bin");

Mar 23, 2011 at 1:12 AM

Thanks virtualtop for your solution