2009-06-04 24 views
0

我跟着從另一篇文章在計算器上點擊此鏈接:配置和使用WCFExtras - WCF/C#/ VS2008

WCFExtras

這是從我的WCF服務庫我的app.config。

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <services> 
     <service behaviorConfiguration="TestClient.Service.Service1Behavior" 
     name="TestClient.Service.SearchService"> 
     <endpoint address="" behaviorConfiguration="Sample.WsdlSampleEndpointBehavior" binding="basicHttpBinding" bindingConfiguration="" 
      contract="TestClient.Service.ISearchService"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8731/TestClient.Service/Service1/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="Sample.WsdlSampleEndpointBehavior"> 
      <wsdlExtensions location="http://localhost:8731/TestClient.Service/Service1/"/> 
     </behavior> 

     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name="TestClient.Service.Service1Behavior"> 
      <!-- To avoid disclosing metadata information, 
      set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="True"/> 
      <!-- To receive exception details in faults for debugging purposes, 
      set the value below to true. Set to false before deployment 
      to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="False" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <extensions> 
     <behaviorExtensions> 
<!-- Declare that we have an extension called WSDL Extras--> 
     <add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/> 
     </behaviorExtensions> 
    </extensions> 
    </system.serviceModel> 
</configuration> 

我在這裏已經刪除了部分連接字符串部分。當我嘗試用[XmlComments]運行它給了我一個錯誤,例如:

Error: Cannot obtain Metadata from http://localhost:8731/TestClient.Service/Service1/mex 
If this is a Windows (R) Communication Foundation service to which you have access, 
please check that you have enabled metadata publishing at the specified address. 
For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error 
URI: http://localhost:8731/TestClient.Service/Service1/mex 
Metadata contains a reference that cannot be resolved: 'http://localhost:8731/TestClient.Service/Service1/mex'. 
<?xml version="1.0" encoding="utf-16"?> 
    <Fault xmlns="http://www.w3.org/2003/05/soap-envelope"> 
    <Code><Value>Receiver</Value><Subcode><Value xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</Value></Subcode></Code> 
    <Reason><Text xml:lang="en-US">An exception was thrown in a call to a WSDL export extension: WCFExtras.Wsdl.Documentation.XmlCommentsAttribute contract: http://tempuri.org/:ISearchService</Text></Reason> 
    <Detail xmlns:s="http://www.w3.org/2003/05/soap-envelope"><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
     <HelpLink i:nil="true"></HelpLink> 
     <InnerException><HelpLink i:nil="true"></HelpLink><InnerException i:nil="true"></InnerException> 
     <Message>XML documentation file for TestClient.Service.dll was not found. Make sure the XML documentation option is enabled in the project properties for that assembly.</Message> 
     <StackTrace> 
at WCFExtras.Utils.XmlCommentsUtils.LoadXmlComments(Type type, Boolean throwIfNotFound) in C:\sandbox\WCFExtras\WCFExtras\Utils\XmlCommentsUtils.cs:line 305 
at WCFExtras.Wsdl.Documentation.XmlCommentsExporter.ExportContract(WsdlExporter exporter, WsdlContractConversionContext context, XmlCommentFormat format) in C:\sandbox\WCFExtras\WCFExtras\Wsdl\Documentation\XmlCommentsExporter.cs:line 172 
at WCFExtras.Wsdl.Documentation.XmlCommentsAttribute.ExportContract(WsdlExporter exporter, WsdlContractConversionContext context) in C:\sandbox\WCFExtras\WCFExtras\Wsdl\Documentation\XmlCommentsAttribute.cs:line 45 
at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlContractConversionContext contractContext, IWsdlExportExtension extension)</StackTrace><Type>System.ApplicationException</Type></InnerException><Message>An exception was thrown in a call to a WSDL export extension: WCFExtras.Wsdl.Documentation.XmlCommentsAttribute contract: http://tempuri.org/:ISearchService</Message><StackTrace> 
at System.ServiceModel.Description.ServiceMetadataBehavior.MetadataExtensionInitializer.GenerateMetadata() at System.ServiceModel.Description.ServiceMetadataExtension.EnsureInitialized() 
at System.ServiceModel.Description.ServiceMetadataExtension.WSMexImpl.GatherMetadata(String dialect, String identifier) 
at System.ServiceModel.Description.ServiceMetadataExtension.WSMexImpl.Get(Message request) at SyncInvokeGet(Object , Object[] , Object[]) 
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs) 
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc) 
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc) 
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace> 
    <Type>System.InvalidOperationException</Type></ExceptionDetail></Detail></Fault> 
HTTP GET Error 
URI: http://localhost:8731/TestClient.Service/Service1/mex 
There was an error downloading 'http://localhost:8731/TestClient.Service/Service1/mex'. 
The request failed with HTTP status 400: Bad Request. 

回答

5

錯誤消息的肉就在那裏:

XML文檔文件的 TestClient.Service .dll未找到。 確保在該程序集的項目屬性 中啓用了XML文檔選項 。

轉到項目選項,在「構建」頁面上,啓用XML文檔的創建。