Search code examples
c#asp.netdotnetnukedotnetnuke-9

DotNetNuke C# 'System.IO.FileNotFoundException' : Could not load file or assembly


I have created 2 DotNetNuke projects, first project name as FormAndList and second project name as FormAndList_Ext.

In FormAndList, i have to call FormAndList_Ext as following sample code.

Function in FormAndList Project

public void UpdateRow(DataSet ds, int ModuleId, int TabId)
{
        UserDefinedController udtc = new UserDefinedController();
        errMessage = udtc.userDefinedLogic(ds);
}

UserDefinedControllerclass in FormAndList_Ext

public class UserDefinedController
{
    #region Constructors
    public UserDefinedController()
    {

    }
    #endregion

    public ErrorMessage userDefinedLogic(DataSet ds)
    {
        int rowNr = 0;
        bool isDataToImport = false;
        bool isError = false;
        var currentRow = ds.Tables["Data"].Rows[rowNr];
        ErrorMessage errMessage = new ErrorMessage();

        foreach (DataRow field in ds.Tables["Fields"].Rows)
        {
            var strColumnName = field["FieldTitle"].ToString();
            var strValueColumn = ((!isDataToImport &&
                                  ds.Tables["Data"].Columns.Contains(strColumnName + "_UDT_Original"))
                                     ? strColumnName + "_UDT_Original"
                                     : strColumnName);

            string InsertData = currentRow[strValueColumn].ToString();

            if (InsertData == "Ali" || InsertData == "Ahmad")
            {
                isError = true;
            }
        }

        if (isError)
        {
            errMessage.setErrorCode(true);
            errMessage.setErrorMessage("Insert Unsuccessfully. Please retry it again. (User Defined Error)");
        }
        else
        {
            errMessage.setErrorCode(false);
        }

        return errMessage;
    }

}   

In my FormAndList reference folder, I added reference to FormAndList_Ext file. When I rebuild it without any error.

I have included FormAndList_Ext.dll in my portal bin folder as well.

But when I run my application in my DNN portal. It display me following error.

Error: is currently unavailable. DotNetNuke.Services.Exceptions.ModuleLoadException: Could not load file or assembly 'FormAndList_Ext, Version=0.0.1.31963, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'FormAndList_Ext, Version=0.0.1.31963, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. at DotNetNuke.Modules.UserDefinedTable.StandardDefinedTableController.UpdateRow(DataSet ds, Int32 ModuleId, Int32 TabId) at DotNetNuke.Modules.UserDefinedTable.EditForm.cmdUpdate_Click(Object sender, EventArgs e) --- End of inner exception stack trace ---

Any solution I can fix it?


Solution

  • Finally I figured it by myself. I only upload FormAndList file into my DNN Portal. I do not upload FormAndList_Ext file into my DNN Portal. Therefore the application cannot recognize FormAndList_Ext code.

    The solution I solved is I upload both FormAndList and FormAndList_Ext files also.