2012-06-01 2 views
2

내가 할당 일하고와 방법보다 액세스 할 수 있으며이 오류 얻을 :일관성 접근성 : 매개 변수 유형은 WCF MEX가

Error 1 Inconsistent accessibility: parameter type 'MexWcfService.MyComplex' is less accessible than method 'MexWcfService.Calculator.complex_sum(MexWcfService.MyComplex, MexWcfService.MyComplex)' E:\North Central College\CSC615\lab8\MexWcfService\MexWcfService\Program.cs 75 26 MexWcfService

다음은 내 코드입니다. 내 문제는

는 몇 가지 중 하나가 여기에 나를 도와 줄 수 ..public MyComplex complex_sum에서 인터페이스 구현 클래스의 내부 (MyComplex A, MyComplex의 B)를 ... 발생합니다. 나는 C#에서 Metadata Exchange Endpoints를 사용하는 WCF 만 보았습니다. 모든 포인터 크게 감사하겠습니다.

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.ServiceModel; 
using System.Runtime.Serialization; 
using System.ServiceModel.Description; 

namespace MexWcfService 
{ 
    [DataContract] 
    class MyComplex 
    { 
     int real; 
     int im; 
     public MyComplex(int real, int im) 
     { 
      Real = real; 
      Im = im; 
     } 

     [DataMember] 
     public int Real 
     { 
      get { return real; } 
      set { real = value; } 
     } 
     [DataMember] 
     public int Im 
     { 
      get { return im; } 
      set { im = value; } 
     } 

    } 
    [ServiceContract] 
    interface ICalculator 
    { 
     [OperationContract] 
     int mult(int a, int b); 

     [OperationContract] 
     List<int> fib(int n); 

     [OperationContract] 
     MyComplex complex_sum(MyComplex a, MyComplex b); 
    } 

    public class Calculator : ICalculator 
    { 

     public int mult(int a, int b) 
     { 
      int total = (a * b); 
      return total; 
     } 
     public List<int> fib(int n) 
     { 
      List<int> list = new List<int>(); 
      for (int i = 0; i < n; i++) 
      { 
       int a = 0; 
       int b = 1; 
       for (int q = 0; q < i; q++) 
       { 
        int temp = a; 
        a = b; 
        b = temp + b; 
       } 
       list.Add(a); 
      } 

      return list; 
     } 
     public MyComplex complex_sum(MyComplex a, MyComplex b) 
     { 
      int real = (a.Real + b.Real); 
      int im = (a.Im + b.Im); 

      MyComplex complex = new MyComplex(real, im); 
      return complex; 
     } 

    } 

    class Program 
    { 
     static void Main(string[] args) 
     { 
      ServiceHost host = new ServiceHost(typeof(Calculator), new Uri("http://localhost:50000/Math")); 
      host.AddServiceEndpoint(typeof(Calculator), new BasicHttpBinding(), "mult"); 
      ServiceMetadataBehavior bhv = new ServiceMetadataBehavior(); 
      bhv.HttpGetEnabled = true; 
      host.Description.Behaviors.Add(bhv); 
      host.Open(); 
      Console.ReadLine(); 


     } 
    } 
} 

답변

7

Calculator 클래스에서 공용 메서드의 형식을 사용 했으므로 'MyComplex'클래스를 public으로 선언해야합니다. 매개 변수로 값을 전달하면서

+0

달콤한 감사합니다! – user975044

0

나는 비슷한 문제를 가지고 있었다. 매개 변수 유형의 액세스 지정자는 메소드 액세스 지정자와 동일하게 만들었습니다. 일

+1

당신의 행동을 표현할 수있는 코드를 게시 할 수 있습니까? – NirMH

관련 문제