I receive this error and I cannot shake it. This question is similar to this SO question and quite a few others, not to mention the page itself.
Yes, I am fully cognizant that the namespace
and service name
MUST MATCH EXACTLY. I read that a zillion fold now.
I have a WCF Service Library, which I am running in IIS. The server is a Windows Server 2016 Standard edition. I renamed App.config
to Web.config
, though I tried as App.config
. I tried what seems like a zillion configurations of each and still the same error. Yes, I tried adding in binding and specifying basicHttpBinding
.
Web.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="MyTesterLibrary.MyTester" behaviorConfiguration="MetadataBehavior">
<endpoint address="" binding="wsHttpBinding" contract="MyTesterLibrary.IMyTester" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" httpHelpPageEnabled="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Main Class
namespace MyTesterLibrary
{
public class MyTester : IMyTester
{
public string GetVersionInfo()
{
Backup.GetVersionInfo(out string response);
return response;
}
}
}
Interface Class
namespace MyTesterLibrary
{
[ServiceContract]
public interface IMyTester
{
[WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/GetVersionInfo")]
[OperationContract]
string GetVersionInfo();
}
}
ProductServiceHost.svc
<%@ ServiceHost Service="MyTesterLibrary.MyTester" %>
I followed instructions on another site and created the IIS site. This screenshot says it all.
I know that in the referenced SO article, the guy was insistent that the problem was in IIS and it was not, but my problem sure seems that way. I just tried basicHttpBinding
again and the same.
This question on the asp.net forum was interesting too. I instinctively renamed App.config
to Web.config
and rebuilt the DLL. IIS does not read `App.config'.
Thoughts?
That last referenced article stated the problem and my suspicion was correct. I am leaving this question here as I wrote it up nicely, but more importantly an IMPORTANT fact was not stated.
Either Visual Studio
or C#
does not embed Web.config OR IIS does not pull the file from the DLL. All the articles that I read talk say to write a SVC file, place the DLL in the bin file, but all leave out two crucial pieces of information.
Copy App.config
to `Web.config'.
Place a copy of Web.config
in the same folder as the SVC file.
There is no need to refresh the website in IIS, but one does have to refresh the browser page.
I hope that this answer helps someone, as I really suffered and almost did not get it.