I have an MVC project to which I have added a folder in the root directory called WCF. Within this folder I have created a WCF service entitled CustomFunctions
. When I attempt to start the service I receive the following error:
Error: Cannot obtain Metadata from
http://localhost/Viper/WCF/CustomFunctions.svc
... Metadata contains a reference that cannot be resolved:
With an additional description:
The type 'Viper.WCF.CustomFunctions', 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 was getting this error yesterday and spent some time scouring the internet for an answer. This led me to make a lot of changes to my Web.config as well as my Global.asax.cs. At one point yesterday, it started working and I stopped. However, when I came back this morning it wasn't working all over again. Nothing new was added and no code was changed between that time.
I have added the following to my Web.config:
<system.serviceModel>
<services>
<service behaviorConfiguration="WCFBehavior" name="Viper.WCF.CustomFunctions">
<endpoint address="" binding="wsHttpBinding" contract="Viper.WCF.ICustomFunctions">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/Viper/WCF/CustomFunctions/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
And this to my Global.asax.cs
:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.svc/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional
}, // Parameter defaults
new { controller = "^(?!CustomFunctions).*" }
);
routes.Add(new ServiceRoute("CustomFunctions", new ServiceHostFactory(),
typeof(CustomFunctions)));
}
Can anyone help me? I'm all out of ideas here.