I have a WCF service that I've had running on Server 2012R2. I tried moving the service to Server 2016 and began getting the following error:
The type 'MyService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
I literally moved the whole directory from one server to the other -- so all the code and settings are the same.
My service is configured in web.config
like this:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
...
<services>
<service name="MyService" behaviorConfiguration="BehaviorConfig">
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="json" contract="IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
My myservice.svc
looks like this:
<%@ ServiceHost Language="C#" Debug="true" Service="MyService" CodeBehind="~/App_Code/MyService.cs" %>
Yes, the .dll containing the service is in my Bin
directory.
My service definition looks like this:
[ServiceContract(Namespace="")]
public interface IMyService
{
[OperationContract]
[WebInvoke(Method ="POST", RequestFormat=WebMessageFormat.Json,ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
string Validate(string userId, string userText);
[OperationContract]
[WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
void UserName(string userId);
}
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class MyService: BaseService, IMyService
{
//Implementation here
}
So I've read a number of posts that indicate that the .svc
file is supposed to contain the type of the service -- including namespace. However, in my case there is no namespace.
The project targets .NET Framework 4.6.1.
What am I missing?
I finally got this working. After hours of messing with this, I finally realized that on the original server, my Services sub-folder had also been made its own Web Application. IOW, I have a Web Application within a Web Application.
On the new server, I had not turned the services sub-folder into a Web Application.