2012-11-05 3 views
2

메신저 Visual Studio에서 문제가 발생하면 동일한 매개 변수 유형을 가진 멤버를 정의했다고 계속 말합니다. 임 C는 새로운 프로그래밍 및 정말 어떻게 해야할지 모르겠다.Visual Studio 2010 C#에서 "이미 동일한 매개 변수 형식의 멤버를 정의했습니다. 오류가 발생했습니다."

오류 1 유형 'Secret.AddPage'이 (가) 이미 회원이

오류 2 유형 'Secret.AddPage가'이미 정의 같은 매개 변수 유형과 '같이 AddPage을'이라고 정의 다음은 발생하는 오류입니다 동일한 전화 번호 유형의 'PhoneApplicationPage_Loaded'

여기까지 제가 작성한 코드는 지금까지 어떤 도움도 크게 받으실 수 있습니다.

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(); 

    } 
} 
} 
+0

'여기에 코드 입력'부분이 있습니까? – mcalex

+3

'부분 클래스 '는 다른 부분을 가지고 있습니까? –

+0

"여기에 코드 입력"은 그 일부가 아닙니다. 그 부분 클래스에 의해 기본적으로, 정말 새로운 메신저 및 자습서를 수행하고 내 자신의 응용 프로그램에 구현하는 정확히 같은 짓을했는지 이러한 오류가 발생합니까? –

답변

8

부분 클래스를 작성 중이므로 부분 클래스의 다른 소스 파일에이 멤버가 정의되어있을 수 있습니다.

솔루션 탐색기에서 소스 파일을 찾아 제거하거나 현재 부분 클래스에서이 멤버를 제거 할 수 있습니다.

당신이 볼 수 Partial Classes and Methods (C# Programming Guide)

이 부분 클래스를 포함하는 다른 소스 파일을 검색하려면, 오른쪽 클래스 이름 AddPage 클릭하고 Go to Definition를 선택합니다. Visual Studio에서 Find Symbol 결과 창에 여러 결과가 표시됩니다.

+0

나는 다른 이름의 파일도 같은 이름을 가지고있는 것을 발견했다. 다른 파일도 이름이 바뀐다. 내가 수동으로 작성하고 참조 옵션을 사용하지 않고 이름을 변경하면 InitializeComponents와 editTextBox가 현재 컨텍스트에 존재하지 않습니다. –

2

AddPage() 생성자 또는 PhoneApplicationPage_Loaded() 메소드를 이미 정의한 다른 부분 클래스를 확인하십시오. 당신은 Ctrl 키 + F하여이를 달성하고 메소드 서명에 대한 솔루션을 검색 할 수 있습니다

public AddPage() 

PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) 
+0

일부 Addpage와 공용 Addpage를 표시합니다. 다른 것을 제거 할 때 다른 오류가 발생합니까?public partial class AddPage : PhoneApplicationPage { public AddPage() –

+0

원본 질문에 부분 클래스를 모두 게시하는 것이 좋습니다 (원래 질문 만 업데이트/편집하는 것이 좋습니다). – alan

0

나는 최근 매우 비슷한 있었고, 가져올 때이 밝혀졌다 기존 코드 파일 obj 디렉토리를 가져 왔습니다! visual studio screen shot

이 디렉토리는 예를 들어 자동으로 생성 된 (자동으로 가져온) MainWindow.g.i.cs 파일을 포함합니다. 그래서 효과적으로 동일한 부분 클래스 정의를 두 번 포함하므로 "이미 정의 된"오류가 발생했습니다.

다른 사람들에게 어떻게 도움이됩니까?