locked
Google Recaptcha throwing System.Web.HttpRuntime.WebObjectActivator error RRS feed

  • Question

  • User351619809 posted

    am trying to use Google Recaptcha on on my web pages. I keep getting an error saying:

    GoogleReCaptcha.GoogleReCaptcha)(System.Web.HttpRuntime.WebObjectActivator.GetService(typeof(GoogleReCaptcha.GoogleReCaptcha))));

    Below is the screen shot:

    Below is my aspx page code:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TryAgain.WebForm1" %>
    <%@ Register Assembly="GoogleReCaptcha" Namespace="GoogleReCaptcha" TagPrefix="cc1" %>
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                 <p>
            <h1>Google ReCaptcha Form</h1>
            <asp:TextBox ID="txt" runat="server"></asp:TextBox>
            <cc1:GoogleReCaptcha ID="ctrlGoogleReCaptcha" runat="server" PublicKey="XXXX" PrivateKey="XXX" />
            <asp:Panel ID="Panel1" runat="server">
            </asp:Panel>
            <asp:Label ID="lblStatus" runat="server" Text=""></asp:Label>
            <asp:Button ID="btn" runat="server" Text="Submit" OnClick="btn_Click" />
        </p>
            </div>
        </form>
    </body>
    </html>

    Below is my aspx.cs file code:

      protected void btn_Click(object sender, EventArgs e)
            {
                if (ctrlGoogleReCaptcha.Validate())
                {
                    //submit form
                    lblStatus.Text = "Success";
                }
                else
                {
                    lblStatus.Text = "Captcha Failed!! Please try again!!";
                }
            }

    GoogleRecaptcha that I downloaded has properties like so:

    I downloaded the GoogleRecaptcha from here:

    https://www.codeproject.com/Tips/884193/Google-ReCaptcha-ASP-net-Control

    I am using ASP.net version 4.7.2

    Any help will be highly appreciated

    Thursday, June 18, 2020 10:57 PM

Answers

  • User288213138 posted

    Hi anjaliagarwal5,

    I downloaded the GoogleRecaptcha from here:

    https://www.codeproject.com/Tips/884193/Google-ReCaptcha-ASP-net-Control

    I am using ASP.net version 4.7.2

    This error is caused by the version of .net framework

    I tested your code and then encountered the same error(i'm using .net framework 4.7.2).

    But when I change the .net framework version to 4.5, it works.

    Best regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 19, 2020 3:33 AM