2012-06-16 4 views
0

가 내 콘솔 호스트 응용 프로그램 구성이 MSDN 예제를 사용 찾을 수 없습니다 그것은 내가에 서비스 참조로 추가 할 수 있습니다 실행하는 동안 나는, 서비스 실행이 작동셀프 호스팅 WCF 계약은

http://msdn.microsoft.com/en-us/library/ms731758.aspx

을 내 Silverlight 클래스 라이브러리 ViewModel과 브라우저에서 실행되는 것을 볼 수 있습니다.

는 ServiceModel은 서비스 클라이언트 구성 섹션에 계약 'ServiceLayer.IServiceLayer'를 참조하는 기본 끝점 요소를 찾을 수 없습니다 : 내 실버 라이트 응용 프로그램을 실행할 때

그러나 나는 다음과 같은 오류 메시지가 나타납니다. 응용 프로그램에 에 대한 구성 파일이 없거나이 계약과 일치하는 끝점 요소가 클라이언트 요소에서 발견되지 않았기 때문일 수 있습니다.

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.ServiceModel; 
using System.ServiceModel.Activation; 
using Model; 

namespace ServiceLayer 
{ 
    [ServiceContract(Namespace = "ServiceLayer")] //This has to match references or updating the service reference will not work. 
    public interface IServiceLayer 
    { 
     [OperationContract] //This is needed for each method. 
     string Compile(string cscode, string name, string type, int token); 

     [OperationContract] //This is needed for each method. 
     string LoginClick(string username, string password, bool createuser, int token); 

     [OperationContract] 
     bool IsLoggedIn(int token); 

     [OperationContract] //This is needed for each method. 
     object[] GetMessages(int token); 

     [OperationContract] //This is needed for each method. 
     int GetToken(int token); 

     [OperationContract] //This is needed for each method. 
     string[][] GetPlugins(int token); 

     [OperationContract] //This is needed for each method. 
     string Finalize(int token, string[] descriptions); 

     [OperationContract] //This is needed for each method. 
     object[][] Communicate(string methodName, int token, object[] args); 
    } 

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 
    public class ServiceLayer : IServiceLayer 
    { 
     public string Compile(string cscode, string name, string type, int token) 
     { 
      // Add your operation implementation here 
      ModelInterface MI = new ModelInterface(); 
      return MI.Compile(cscode, name, type, token); 
     } 

     public String LoginClick(string username, string password, bool createuser, int token) 
     { 
      ModelInterface MI = new ModelInterface(); 
      return MI.LoginClick(username, password, createuser, token); 
     } 

     public bool IsLoggedIn(int token) 
     { 
      ModelInterface MI = new ModelInterface(); 
      return MI.IsLoggedIn(token); 
     } 

     public object[] GetMessages(int token) 
     { 
      ModelInterface MI = new ModelInterface(); 
      return MI.GetMessages(token); 
     } 

     public int GetToken(int token) 
     { 
      ModelInterface MI = new ModelInterface(); 
      return MI.GetToken(token); 
     } 

     public string[][] GetPlugins(int token) 
     { 
      ModelInterface MI = new ModelInterface(); 
      return MI.GetPlugins(token); 
     } 

     public string Finalize(int token, string[] descriptions) 
     { 
      ModelInterface MI = new ModelInterface(); 
      return MI.Finalize(token, descriptions); 
     } 

     public object[][] Communicate(string methodName, int token, object[] args) 
     { 
      ModelInterface MI = new ModelInterface(); 
      return MI.Communicate(methodName, token, args); 
     } 
     // Add more operations here and mark them with [OperationContract] 
    } 
} 

이것은 뷰 모델의 ServiceReferences.ClientConfig입니다 :

내 서비스 코드

<configuration> 
<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_IServiceLayer" maxBufferSize="2147483647" 
       maxReceivedMessageSize="2147483647"> 
       <security mode="None" /> 
      </binding> 
      <binding name="BasicHttpBinding_IServiceLayer1" maxBufferSize="2147483647" 
       maxReceivedMessageSize="2147483647"> 
       <security mode="None" /> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:3263/front" binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_IServiceLayer" contract="IServiceLayer" 
      name="BasicHttpBinding_IServiceLayer" /> 
     <endpoint address="http://localhost:3263/front" binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_IServiceLayer1" contract="ServiceLayer.IServiceLayer" 
      name="BasicHttpBinding_IServiceLayer1" /> 
    </client> 
</system.serviceModel> 

그리고 이것은의 Web.Config 파일입니다 Silverlight 앱을 호스팅하는 웹 사이트에서 프로젝트를 시작하십시오. 나는 임대

<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0"/> 
    <pages controlRenderingCompatibilityVersion="4.0"/> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name=""> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <customBinding> 
     <binding name="OrgOS.Web.ServerCommunicationService.customBinding0"> 
      <binaryMessageEncoding/> 
      <httpTransport/> 
     </binding> 
     <binding name="OrgOS.Web.ServiceLayer.customBinding0"> 
      <binaryMessageEncoding/> 
      <httpTransport/> 
     </binding> 
     </customBinding> 
    </bindings> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/> 
    <services> 
     <service name="OrgOS.Web.ServiceLayer"> 
     <endpoint address="" binding="customBinding" bindingConfiguration="OrgOS.Web.ServiceLayer.customBinding0" contract="OrgOS.Web.ServiceLayer"/> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 

내 서버 내가 지불 한 사실에도 불구하고 ASP.NET없이왔다 : 또한 아래의 Web.config에 VM의 설정에서 ServiceModel은 서비스 섹션을 복사하는 예 -이 Could not find default endpoint element 가이드를 시도하기 때문에 나는 그것을 게시 그것을 위해, 지원은 휴가이고 나는 마감 시간을 내고있다! WCF의 작업을 얻기 위해 노력 화가 날 운전 - 저를 도와주세요 ...

신경 끄시 고

왜 그렇게 간단한 실버 라이트 프로젝트를 보여주기 위해 열심히 괴물이되어 ...

답변

0

아; View Silverlight 프로젝트, 웹 프로젝트 및 ViewModel Silverlight 프로젝트에 구성 설정을 게시해야합니다.

또한 모든 엔드 포인트와 바인딩을 삭제해야하지만 혼동을 피하려면 하나를 삭제해야합니다.

또한 namespace = "namespace"가 실제 네임 스페이스에 맞는지 확인하기 위해 변경된 사항이 있습니다.

... 그 이유 때문에 작동하지 않는 것, 오, noes는 모두 잘못된 결과입니다.

FML 지금.