Could not load file or assembly 'log4net, Version=1.2.10.0?

0

I have page called ProvinceWiseDistributionCivilWork which use crystal report to display the report I have other two pages which is works fine but for this page ProvinceWiseDistributionCivilWork it throw this error Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) However I search online for following error what I did so far to fix this

  1. I Enable 32 bit application pool in IIS.
  2. %systemdrive%\windows\assembly\ (in this path log4net is not present in GAC and GAC32 but log4net present in GAC64.

I Did the above to steps but the problem still there however I also download the log4net using NuGet also my framework is 4.7 VS 2019.

This is is the code of my ProvinceWiseDistributionCivilWork.aspx I believe the code side is fine not sure.

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ProvinceWiseDistributionCivilWork.aspx.cs" Inherits="Reports_CivilWorks_ProvinceWiseDistributionCivilWork" %>
<%@ Register assembly="CrystalDecisions.Web, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Mhead" runat="Server">
    <script src="~/aspnet_client/system_web/4_0_30319/crystalreportviewers13/js/crviewer/crv.js"></script> 
    <script src="~/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer3/js/print.js"></script> 
    <style>

        .singlerow {
            display: -webkit-box;
        }

            .singlerow span {
                display: -webkit-box;
            }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div class="layout-content-body">
          <div class="row gutter-xs">
            <div class="col-xs-12">
              <div class="card">
                <div class="card-header">
                
                  <strong>Event Agreement Printing</strong>
                </div>
                <div class="card-body">
             <div id="DivError" class="geterror" runat="server">
                    <img src="images/diverror.png" alt="Error" style="width: 30px; height: 30px; vertical-align: middle;" hspace="10" />
                    <asp:Label ID="lblError" runat="server"></asp:Label>
                </div>
                
                <CR:CrystalReportViewer   ID="vwrReport" runat="server"  HasCrystalLogo="false" 
                                           HasToggleParameterPanelButton="False"  HasDrilldownTabs="False" PrintMode="ActiveX"
                                                  HasPageNavigationButtons="True" HasZoomFactorList="True"    HasDrillUpButton="False" HasToggleGroupTreeButton="false"   PageZoomFactor="100"
                                           ToolPanelView="None"   
                                            AutoDataBind="true"    />
                   </div>
                </div>
              </div>
            </div>
          </div>
</asp:Content>

and this is my ProvinceWiseDistributionCivilWork.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLLV2;
using System.IO;
using System.Data.SqlClient;
using System.Text;
using System.Collections.Generic;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

public partial class Reports_CivilWorks_ProvinceWiseDistributionCivilWork : SystemWebUIPage
{
    private string g_strErrorMessage = "";
    private string g_strErrorType = "";
    
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Page_Init(object sender, EventArgs e)
    {
        DivError.Visible = false;
        lblError.Text = "";

         
        

        if (!Page.IsPostBack)
        {
            FillDataGrid();
        }

    }

    private void FillDataGrid()
    {
        try
        {


            vwrReport.ReportSource = null;
            vwrReport.DataBind();
            DataSet _dsreport = new DataSet();

            SqlCommand cmd = new SqlCommand();
//            cmd.CommandText = @"SELECT   Id as INT1, ContractorStatus as STR1, IUBy as STR2, IUDate as STR3
//FROM      ContractorStatuses";
            cmd.CommandText = @" SELECT  [Components] as STR1,[Azad Jammu & Kashmir] as STR2,[Balochistan] as STR3,[Sindh]as STR4,[Khyber Pakhtunkhwa] as STR5,[Punjab] as STR6, [Federal] as STR7, [FATA] as STR8, [Gilgit Baltistan] as STR9
                    FROM(
                        SELECT C_SubItems.SubItemName AS [Components], Province.Province AS [ProvinceName],COUNT(*) AS [Total Components] FROM University
                        INNER JOIN Province ON Province.id=University.provinceID
                        INNER JOIN Projects ON University.ID=Projects.ExecutingAgency_University
                        INNER JOIN ProjectItems ON Projects.ID=ProjectItems.ProjectID
                        INNER JOIN C_ProjectISubtems_CivilWorks ON ProjectItems.id=C_ProjectISubtems_CivilWorks.ProjectItemsID
                        INNER JOIN C_SubItems ON C_SubItems.ID=C_ProjectISubtems_CivilWorks.C_SubItemID
                        GROUP BY C_SubItems.ID, C_SubItems.SubItemName,Province.Province HAVING COUNT(*)>=1
                    )AS C_SubItems
                    PIVOT(
                    SUM([Total Components] ) FOR ProvinceName IN ([Azad Jammu & Kashmir],[Balochistan],[Sindh],[Khyber Pakhtunkhwa],[Punjab], [Federal], [FATA], [Gilgit Baltistan])
                    )Result";
           
            _dsreport = db.getDataSet(ref cmd);



            //Todo: 

            if (_dsreport != null)
            {
                if (_dsreport.Tables.Count > 0)
                {
                    if (_dsreport.Tables[0].Rows.Count > 0)
                    {
                        _dsreport.Tables[0].TableName = "GenRptFields";
                        ReportDocument rptDoc = new ReportDocument();
                        rptDoc.Load(Server.MapPath("ProvinceWiseDistributionCivilWork.rpt"));
                       
                        rptDoc.SetDataSource(_dsreport);
                        vwrReport.ReportSource = rptDoc;
                        vwrReport.RefreshReport();
                        vwrReport.DataBind();
                        rptDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "printrpt");
                    }
                    else
                    {
                        vwrReport.ReportSource = null;
                        vwrReport.DataBind();
                        DivError.Visible = true;
                        lblError.Text = "No record(s) found for the specified criteria.";
                    }
                }
                else
                {
                    vwrReport.ReportSource = null;
                    vwrReport.DataBind();
                    DivError.Visible = true;
                    lblError.Text = "No record(s) found for the specified criteria.";
                }
            }

            else
            {
                vwrReport.ReportSource = null;
                vwrReport.DataBind();
                DivError.Visible = true;
                lblError.Text = g_strErrorMessage;
            }

        }
        catch (Exception exp)
        {

            DivError.Visible = true;
            lblError.Text = exp.Message;
        }
    }
}
asp.net
crystal-reports
log4net
asked on Stack Overflow Apr 26, 2021 by Logitech Flames

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0