2014-03-19 8 views
0

큰 문제가 있습니다코드에 WCF app.config

이 구성으로 자체 호스팅 서비스를 받았습니다.

<bindings> 
     <basicHttpBinding> 
     <binding name="NewBinding0" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" /> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="ReportServiceBehavior" name="ConsoleApplication1.ReportService"> 
     <endpoint address="ReportService" binding="basicHttpBinding" bindingConfiguration="NewBinding0" contract="ConsoleApplication1.IParameterService"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="ReportService/resources" behaviorConfiguration="WebBehavior" binding="webHttpBinding" contract="Telerik.Reporting.Service.IResourceService" /> 
     <endpoint address="" behaviorConfiguration="WebBehavior" binding="webHttpBinding" contract="Telerik.Reporting.Service.IClientAccessPolicy" /> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:54321" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ReportServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="WebBehavior"> 
      <webHttp /> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 

!

그러나 나는 코드로 설정을해야, 그래서의 app.config에서 설정을 삭제하고 내가 잘못하고있는 무슨이

host = new System.ServiceModel.ServiceHost(typeof(ReportService), new System.Uri("http://localhost:54321")); 
       BasicHttpBinding binding = new BasicHttpBinding() { MaxBufferPoolSize = int.MaxValue, MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue }; 

       var g = host.AddServiceEndpoint(typeof(IParameterService), binding, "ReportService" /*Url here can either be empty or the same one as serviceUri*/); 
       EndpointAddress myEndpointAdd = new EndpointAddress(new System.Uri("http://localhost:54321/ReportService"), 
       EndpointIdentity.CreateDnsIdentity("localhost")); 
       g.Address = myEndpointAdd; 



       var d1 = host.AddServiceEndpoint(typeof(Telerik.Reporting.Service.IResourceService), new WebHttpBinding(), "ReportService/resources" /*Url here can either be empty or the same one as serviceUri*/); 
       var d2 = host.AddServiceEndpoint(typeof(Telerik.Reporting.Service.IClientAccessPolicy), new WebHttpBinding(), "" /*Url here can either be empty or the same one as serviceUri*/); 
       d1.Behaviors.Add(new WebHttpBehavior()); 
       d2.Behaviors.Add(new WebHttpBehavior()); 


       host.Description.Behaviors.Add(new ServiceMetadataBehavior() { HttpGetEnabled = true }); 

       ServiceMetadataBehavior smb = host.Description.Behaviors.Find<ServiceMetadataBehavior>(); 
       if (smb == null) 
        smb = new ServiceMetadataBehavior(); 




       smb.HttpGetEnabled = true; 
       smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; 
host.open 

같은 서비스를 시작하려고?

답변

관련 문제