2.0.0.36 Null Reference Exception on RecaptchaControl

Topics: Controls
Feb 2, 2011 at 3:27 AM

I've finally got my Mono/Apache2 environment set up (migrated from nginx due to inability for AJAX posts), but the problem I had run into remains.  It even exists on an initial install from the release archive.  The exception is below.

System.NullReferenceException: Object reference not set to an instance of an object
  at App_Code.Controls.RecaptchaControl.OnInit (System.EventArgs e) [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.InitRecursive (System.Web.UI.Control namingContainer) [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.InitRecursive (System.Web.UI.Control namingContainer) [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.InitRecursive (System.Web.UI.Control namingContainer) [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.InitRecursive (System.Web.UI.Control namingContainer) [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.InitRecursive (System.Web.UI.Control namingContainer) [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.InitRecursive (System.Web.UI.Control namingContainer) [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.InitRecursive (System.Web.UI.Control namingContainer) [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.InternalProcessRequest () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0

FWIW, there is no App_Code/Controls/RecaptchaControl.* found in the directory.  Mono version is Mono 2.6.7-3ubuntu1 (the one from the Ubuntu repository). 

Any ideas?

Coordinator
Feb 2, 2011 at 4:43 PM

It was moved from "controls" to recaptcha folder, but namespace was not changed. You can fix this error by modifying code in the app_code/extensions/recaptcha/recaptchacontrol.cs

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

	var settings = ExtensionManager.GetSettings("Recaptcha");

	// add this
	if(settings == null)
	{
		var rcp = new Recaptcha();
		rcp.InitLogSettings();
		rcp.InitSettings();

		settings = ExtensionManager.GetSettings("Recaptcha");
	}
	// end of add this

Feb 3, 2011 at 1:42 AM

Well, I gave this a shot, but I still got the error.  I added a check that threw a different exception after the second attempt at getting the settings if they were null, and that's being thrown.

In the dashboard, the "Extensions" tab has no data.  I suspect that something's not getting wired up correctly with those - any idea where I'd need to look?

Coordinator
Feb 3, 2011 at 3:43 AM

I was looking at setting up BE 2.0 on Mono yesterday, to fix extensions not loading I had to comment out this code in Core/Utils.cs going from:

if (!IsMono)
{
	assemblyName = "App_Code";
}

to just

assemblyName = "App_Code";

The reason is Mono guys fixed not-standard name and now Mono also uses "App_Code". So after removing that check extensions loaded fine.

Unfortunately I'm still getting few errors and VM crashed before I got trough setting it all up, so this shifted into weekend project.

Feb 3, 2011 at 4:43 AM
Edited Feb 3, 2011 at 4:44 AM

Ah.  Is that in the "head" revision?  To fix that, would I just need to make a similar change, rebuild, then copy the DLL to the /Bin folder?

I'm going to be out of town this weekend, but if you've got something you'd like for me to try, I'd be happy to do it early next week.  :)  I really like what I've seen out of 2.0 so far.

Mar 13, 2011 at 10:37 PM

I just committed to my "mono4be" fork with this change.  This was the lone change that allowed BE 2.0 to run with Mono 2.10 (using mod-mono-server4).

Now to do something about those compiler warnings...  :)