Visual Studio 2010 C# "already defined a member with same parameter types error."

im having a problem in visual studio it keeps saying i have defined a member with same parameter types. Im new to C# programming and i dont really know what to do. These are the errors that are occurring:

Error 1 Type 'Secret.AddPage' already defines a member called 'AddPage' with the same parameter types

Error 2 Type 'Secret.AddPage' already defines a member called 'PhoneApplicationPage_Loaded' with the same parameter types

Here is the code i have written so far any help is greatly appreciated.

enter code here

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Device.Location;

namespace secret
{
public partial class AddPage : PhoneApplicationPage
{
    private string location = "";

    public AddPage()
    {
        InitializeComponent();

        GeoCoordinateWatcher myWatcher = new GeoCoordinateWatcher();
        var myPosition = myWatcher.Position;

        // Eftersom koden körs i emulatorn kan den inte få tillgång till riktiga GPS-värden
        // Därför hårdkodas koordinaterna till slottet i Gamla stan så att MSR MAPS Web Services
        //kan testas.

        double latitude = 40.717;
        double longitude = -74;

        if (!myPosition.Location.IsUnknown)
        {
            latitude = myPosition.Location.Latitude;
            longitude = myPosition.Location.Longitude;
        }

        myTerraService.TerraServiceSoapClient client = new myTerraService.TerraServiceSoapClient();

        client.ConvertLonLatPtToNearestPlaceCompleted += new EventHandler<myTerraService.ConvertLonLatPtToNearestPlaceCompletedEventArgs>(client_ConvertLonLatPtToNearestPlaceCompleted);

        client.ConvertLonLatPtToNearestPlaceAsync(new myTerraService.LonLatPt { Lat = latitude, Lon = longitude });
    }

    void client_ConvertLonLatPtToNearestPlaceCompleted(object sender, myTerraService.ConvertLonLatPtToNearestPlaceCompletedEventArgs e)
    {
        location = e.Result;

        //throw new NotImplementedException();
    }


    private void AppBar_Cancel_Click(object sender, EventArgs e)
    {
        navigateBack();
    }

    private void AppBar_Save_Click(object sender, EventArgs e)
    { // spara en ny anteckning

        if (location.Trim().Length == 0)
        {
            location = "Okänd";
        }

        navigateBack();

    }
    private void navigateBack()
    {
        NavigationService.Navigate(new Uri("/secret;component/NotesMainPage.xaml", UriKind.Relative));
    }

    private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
    {
        editTextBox.Focus();

    }
}
}

You are creating a partial class, so you probably have these members defined in another source file for your partial class.

You may look at the solution explorer, find that source file and either remove it from there or you may remove these members from your current partial class.

You may see: Partial Classes and Methods (C# Programming Guide)

To search for the other source file containing the partial class, right click on the Class Name AddPage and select Go to Definition. You will see multiple results in Find Symbol result window in visual studio.

Visual Studio tutorials | C#. Create C# apps with Visual Studio. Get started How-To Guide Install Visual Studio; Get Started Start a guided tour

Check for another partial class in which you've already defined the AddPage() constructor or PhoneApplicationPage_Loaded() methods. You can achieve this by Ctrl+F and searching the solution for the method signatures:

public AddPage()

and

PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)

Microsoft Visual Studio 2010 Professional is the essential tool for individuals performing basic development tasks. It simplifies the creation, debugging, and deployment of applications on a variety of platforms including SharePoint and the Cloud.

I had something very similar recently, and it turned out that when importing existing code files I had imported the obj directory itself!

This directory contained, for example, the auto-generated (and automatically imported) MainWindow.g.i.cs file. So I was effectively including the same partial class definition twice, hence the "already defined" errors.

How this help someone else!

Visual Studio C# 2010 Express Download.NET Framework > .NET Framework Setup and Servicing.NET Framework Setup and Servicing https:

i had a project where i opened the main program.cs in notepad++, made some edits and did a "save as" to make a copy of the file in the same folder. i later opened the same project in visual studio and got this same error when trying to compile. i just had to exclude the files i created from making a copy from the project by right clicking on the problem file and selecting "exclude from project". did a build and viola! the copy was still in the folder just not being included in the build.

Microsoft Visual Studio 2010 Ultimate. Free to try Microsoft Windows XP/2003/Vista/Server 2008/7/Server 2003 x64 R2/Server 2003 x86 R2/XP SP3 Version 2010 Full Specs . Average User Rating:

In my case the reason of this error was finally as simple as this. I added a new DB table to my EDMX in my DB project. I accidentally ticked the box for generation of class with methods (but these were already generated in the project). The EDMX file after this contained two similarly named classes AB.Context.tt and AB.xxx.Context.tt and both contained the same methods. As the classes were partial the mentioned error arose.

The solution was to remove accidentally and freshly added secondary AB.xxx.Contex.tt file and rebuild the project.

The Visual Studio Code C# extension can generate the assets you need to build and debug. If you missed the prompt when you first opened a new C# project, you can still perform this operation through the Command Palette (View > Command Palette) by typing '.NET', and running.NET: Generate Assets for Build and Debug.

This download installs the Visual Studio 2010 Tools for Office Runtime, which is required to run Microsoft Office based solutions built using Microsoft Visual Studio 2010, 2012, 2013 and 2015.

Visual Studio 2010 Professional; Visual Studio 2010 Premium; Visual Studio 2010 Ultimate. Visual Studio Team Foundation Server 2010. Visual Studio Team Explorer 2010. Visual Studio Team Explorer Everywhere 2010. Visual Studio 2010 Remote Debugger. Visual Studio 2010 Visualization & Modeling SDK. Visual Studio 2010 Agents. Visual Studio 2010 Express

High quality, print-ready PDFs in letter & A4 format containing the default keybindings in Visual Studio 2010 for Visual Basic, Visual C#, Visual C++ and Visual F#. High-resolution versions are also available.

Comments
  • is 'enter code here' part of it?
  • Does the partial class have any other parts?
  • no "enter code here" is not part of it. Its Partial Class by Default, im really new and are following a tutorial and implementing it into my own application though i have done exactly the same i get these errors?
  • i found that another c# file had the same names yet when i change them to their respective names The other files changes its names too? when i write them manually and dont use the option to reference and change the names the InitialiseComponents and editTextBox does not exist in the current context
  • this solution worked for me . Go to Definition -> multiple results in find result window .
  • It just shows the partial Addpage and the public Addpage im not entirely sure what to do because i get alot of other errors when removing on or the other? public partial class AddPage : PhoneApplicationPage { public AddPage()
  • I would recommend you post both partial classes in your original question (just update/edit the original question).