2011-08-02 14 views
0

私はエラーメッセージを次のコードでのWCFデータサービスを実行すると、エラーを取得:WCFデータサービスのサービスオペレーション

"The server encountered an error processing the request. See server logs for more details." 

コード:

public class WcfDataService1 : DataService<Entities1> 
    { 
     // This method is called only once to initialize service-wide policies. 
     public static void InitializeService(DataServiceConfiguration config) 
     { 
      // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc. 
      // Examples: 
      config.SetEntitySetAccessRule("*", EntitySetRights.All); 
      config.SetServiceOperationAccessRule("GetData", ServiceOperationRights.All); 
      config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; 
     } 

     [WebGet()] 
     public IQueryable GetData(int Id) 
     { 

      if (assayId > 0) 
      { 
       var query = from a in this.CurrentDataSource.Entity 
          where a.ID == Id 
          select a; 

       return query; 
      } 
      else 
       throw new DataServiceException(400, "ID is not valid"); 

     } 


    } 

私は何も返さいけないときに、同じコードが動作します操作から。

UPDATE:サーバログは言う:

"WebHost failed to process a request. 
Sender Information: System.ServiceModel.Activation.HostedHttpRequestAsyncResult/44530215 
Exception: System.ServiceModel.ServiceActivationException: The service '/MyWcfDataService.svc' cannot be activated due to an exception during compilation. The exception message is: The type 'MyWcfDataService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.. ---> System.InvalidOperationException: The type 'MyWcfDataService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found. 
    at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) 
    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath) 
    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath) 
    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) 
    --- End of inner exception stack trace --- 
    at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) 
    at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) 
Process Name: WebDev.WebServer40 
Process ID: 1124 

For more information, see Help and Support Center at 

は、誰もが解決策で私を助けてください。

また、EFで作成したエンティティではなく、自分自身のエンティティを公開したい場合は、そのアイデアをどのように実行するのですか。

+0

「詳細はサーバーログを参照してください。」 - >ログはあなたに何を伝えましたか? – Tim

+0

@Timはサーバーログを追加しました – genericuser

答えて

0

ちょうど

IQueryable<Entity>に戻り値の型を変更し、それが働きました。

関連する問題