Why can't I use this in WCF Service Library

Jun 3, 2009 at 8:04 PM

Project Type: C# WCF Service Library VS2008 Pro edition

This is my app.config from my WCF Service library.

<?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>


I have stripped out parts like connection string section here. When i hit F5 after adding [XmlComments] it gives me an error:

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">The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the &lt;serviceDebug&gt; configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.</Text></Reason></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.

Set the includeExceptionDetailInFaults to true

this the detailed error

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.

anyone has any idea on what I am missing from my app.config file?


May 4, 2010 at 1:30 PM

I've got the same problem.

If I enter the XmlComments Attribute, the service isn't connectable.

Any solution yet?