WCF - Contract Name could not be found in the list of contracts

后端 未结 6 852
猫巷女王i
猫巷女王i 2020-12-20 11:10

I am relatively new to WCF. However, I need to create a service that exposes data to both Silverlight and AJAX client applications. In an attempt to accomplish this, I have

6条回答
  •  孤城傲影
    2020-12-20 11:35

    I have had that error before for ServiceModel framework 3.5, and I checked my host's config file. I found it was my cut-and-paste error. My service was pointing to an old non-existing service than the one I am using. It starts working again after I corrected these lines like below:

    
    
      
      
        
          
            
            
          
        
      
    
    
    

    Note that MyService has to be the name of your contract class in ServiceModel 3.5 BUT IT IS IMyService contract interface in Framework 4.0 -->

    namespace InUse {
    [ServiceContract]
    public interface IMyService 
    {
        [WebGet(UriTemplate = "/GetList/{PATTERN}",
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        [OperationContract]
        List GetIDListByPattern(string PATTERN);
    
    }
    
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]    
    public class MyService : IMyService
    {        
        List MySample = (new _PointRT()).Sample().Select(r=>r._pointXID).ToList();
    
        public List GetIDListByPattern(string PATTERN) {
            return MySample.Where(x => x.Contains(PATTERN)).ToList();
        }
    }
    

提交回复
热议问题