locked
Type 'Solution1.Web.yourABC' already defines a member called 'Page_Load' with the same parameter types RRS feed

  • Question

  • User2041927334 posted

    <div>

    Hey Fellows,

    Below follows issues I have encountered when copying files into my solution, clicking on the reported error or on "Go to Definition" mislead me to spot the cause. The hint is one line above..... !

    I'm exposing the Problem AND how I finally Resolved it.

    Errors when building the application:

    • Error    1    Type 'Solution1.Web.yourABC' already defines a member called 'Page_Load' with the same parameter types    C:\<folderpath>\trunk\Solution1.Web\yourABC.aspx.cs    12    24    Solution1.Web
    • Error    2    Type 'Solution1.Web.yourABC' already defines a member called 'Page_Load' with the same parameter types    C:\<folderpath>\trunk\Solution1.Web\GuideABT.aspx.cs    12    24    Solution1.We


    How the problem arose:
    I copy/pasted a file .aspx in the same solution to make a new file.
    C#: Error like below started to appear; worst other misleading errors started to impact the application at runtime:

    * Be aware that error 1 IS NOT an error it is CORRECT, as it is the source code

    • Error    1    Type 'Solution1.Web.yourABC' already defines a member called 'Page_Load' with the same parameter types    C:\<folderpath>\trunk\Solution1.Web\yourABC.aspx.cs    12    24    Solution1.Web
    • Error    2    Type 'Solution1.Web.yourABC' already defines a member called 'Page_Load' with the same parameter types    C:\<folderpath>\trunk\Solution1.Web\GuideABT.aspx.cs    12    24    Solution1.Web


    Both classes "Page_Load" are empty, normally they are generated automatically by the Visual Studio Engine

    Solution:
    Change the .cs file of the newly create/pasted aspx page to reflect the page name after the Class "name". In this case "GuideABT.aspx" is the new pasted & renamed aspx file:

    Correction on Error 1: NO CORRECTION NEEDED as it is the copied from file. MAKE SURE THAT the name of the file and the name of the class reference ARE the same in the .cs files:

    File name yourABC.aspx, check the .cs extension files:
        namespace Solution1.Web
        {
            public partial class yourABC : System.Web.UI.Page
            {
                protected void Page_Load(object sender, EventArgs e)
                {
        
                }
            }
        }

    Correction on Error 2: MODIFY the pasted file. Correct the CLASS NAME to reflect the name of the .aspx file.

    File name GuideABT.aspx, check the .cs extension files:
    ORIGINAL code in .cs
        namespace Solution1.Web
        {
            public partial class yourABC : System.Web.UI.Page
            {
                protected void Page_Load(object sender, EventArgs e)
                {
        
                }
            }
        }

    CORRECTED this code in .cs TO
        namespace FEUnicenter.Web
        {
            public partial class GuideABT : System.Web.UI.Page
            {
                protected void Page_Load(object sender, EventArgs e)
                {
        
                }
            }
        }

    Issue RESOLVED.

    Cheers.

    </div>

    Wednesday, November 27, 2013 7:46 AM

Answers

  • User-166373564 posted

    Hi freddymio

    Solution: Change the .cs file of the newly create/pasted aspx page to reflect the page name after the Class "name". In this case "GuideABT.aspx" is the new pasted & renamed aspx file:

    CORRECTED this code in .cs TO
        namespace FEUnicenter.Web
        {
            public partial class GuideABT : System.Web.UI.Page
            {
                protected void Page_Load(object sender, EventArgs e)
                {
        
                }
            }
        }

    Issue RESOLVED.

    Congratulations! I’m glad to hear that you have solved this issue by yourself, and it is very appreciated to share your solution to us. It will be helpful for others, and welcome to post your question on this forum in your future programming.

    Best regards

    Angie

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 3, 2013 4:06 AM