2014-05-08 77 views
0

公共類在wcf服務中不工作。我創建了另一個公共類,並將其用於我的service.svc,但無法訪問類。請參閱下面的代碼。類在wcf服務類中不工作

ITest.cs

namespace TestProject.Services 
{ 
    [ServiceContract] 
    public interface ITest 
    { 
    [ServiceContract] 
    public interface ITest 
    { 
     [OperationContract] 
     DataTable SelectData(string sSectionName); 
    } 
} 
} 

ITest.svc.cs

namespace TestProject.Services 
{ 
    public class Test: ITest 
    { 
     public DataTable SelectData(string sSectionName) 
     { 
     //do some work 

     } 
    } 
    } 

Ohter新類

Public class connection 
{ 
    public int sum(int i, int b) 
    { 
    return i+b; 
    } 
} 

我的連接類不在ITest.svc.cs訪問。請幫助

+0

請爲該類創建構造函數,然後嘗試 –

+0

嘗試使用[命名空間]■連接 – shana

+0

@ user256103 - 如果在代碼中沒有提供一個構造函數,編譯器將生成一個默認的無參數構造函數。顯式添加構造函數不會解決OP的問題。 – Tim

回答

0

嘗試重寫連接,例如:

namespace TestProject.Services 
{ 
    Public class connection 
    { 
     public int sum(int i, int b) 
     { 
      return i+b; 
     } 
    } 
}