WCF Web Service Metadata Publishing Disabled Error - web-config

I modified my web.config to add a custom binding in order to increase the buffer and message size, and it seems like in creating the service element explicitly, it has somehow broken the reference to my behavior element.
When I try to run my web service from VS using the WCF Test Client, or I go to the service page, I get the error:
Metadata publishing for this service is currently disabled.
I've compared my web.config to a few different sources on this and everything seems to match. I've no idea what the issue is.
Here is the System.serviceModel element:
<system.serviceModel>
<services>
<service name="BIMIntegrationWS.BIMIntegrationService" behaviorConfiguration="metadataBehavior">
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="http://localhost:1895/BIMIntegrationService.svc"
binding="customBinding" bindingConfiguration="customBinding0"
contract="BIMIntegrationWS.IBIMIntegrationService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<!-- 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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="customBinding0">
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="262064"
maxBufferSize="262064"
maxBufferPoolSize="262064" />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
It almost seems like either the web service page is not finding the element. I don't get an error complaining that the target behaviorConfiguration doesn't exist, or anything like that, just that Metadata publishing is not enabled.
Any help would be greatly appreciated.
Thanks.

I think i've "fixed" the issue. More coming later.
EDIT:
In order to "fix" my issue, I basically added a new WCF service to my application, and had it implement my previous interface, I then copied all the code from my original service and when I tweaked the .config file (to look pretty much like the one posted in the question), everything worked fine.
Ofcourse, I know, like we all know, that there is no magic here, that there must be some discrepancy. This is when I noticed/remembered, that after I had created my original service, called "BIMIntegrationService.svc", I had decided that this was too long of a name, so I renamed/refactored my class to "BIMIntegrationWS". Doing this, however, does not change the name of the service file (and therefore the name of the file in the http:// address).
Long story short, I made 2 changes to my .config and everything worked:
1) I changed:
<service name="BIMIntegrationWS.BIMIntegrationService" behaviorConfiguration="metadataBehavior">
to
<service name="BIMIntegrationWS.BIMIntegrationWS" behaviorConfiguration="metadataBehavior">
After running the service like this, I got an error (a helpful one this time) complaining that if multipleSiteBindings was enabled, the endpoint address had to be relative. So:
2) I set that to false (because I don't remember why it was in there in the first place) and everything worked fine.
I guess I should have taken a hint when it seemed like my web service was not using my "service" element at all. :\
EDIT 2:
Actually, you can see in my second comment, in the original question, that the auto-generated tag was pointing to: , as opposed to "BIMIntegrationService".
That should have given it away.
I doubt many other people will have this same issue, but just in case.

I've had the same trouble; I've gotten everything configured correctly (even copied the code from a previous service I have running) and yet no change on allowing the service to expose metadata. yet, if I make a spelling error, parse error, etc. to the app.config I'm given exceptions telling me to correct the problem (which tells me the service is reading the config, just disregarding it.
I was able to bypass it by generating the config settings in the host application:
System.ServiceModel.Description.ServiceMetadataBehavior smb = new System.ServiceModel.Description.ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
ServiceBase host = new Servicebase(typeof(MyService), new Uri("http://localhost:1234/"));
host.Description.Behaviors.Add(smb);
host.Open();
...
host.Close();
Basically allow the code to override and push the config file changes i wanted applied. I know it's not ideal, but I was exposing the service through a windows service which made this do-able. if you do get your problem resolved, please pass along the solution though as I'd be curious to know why (at least in yours, if not both our cases) it's failing.

Related

Issues generating Enterprise jar for Salesforce Soap API; issue with generated WSDL XML from Salesforce

I've recently made some databasae changes to custom objects, and I'm trying to generate a new enterprise.jar to reflect these changes. I'm following all documentation located here for the process. I'll also note, with the exception of some new dependencies, I've followed this process before with no errors to generate the enterprise.jar file. So this is a process that has worked for my sandbox in the past, but we haven't had any structural changes to the database in a solid 5 years.
Following along with the steps is simple enough. I generate the XML file from my Salesforce login in my developer sandbox utilizing Enterprise WSDL (we clearly have Enterprise level service, just so that's established). From there, I go to the Maven repository, get force-wsc-48.0.0.jar from there (as per the current API version of my sandbox), and then download a few dependencies like rhino, ST, and antlr-runtime. I get all files together in a temp folder in my C drive and try running command:
java -classpath C:\temp\force-wsc-48.0.0.jar;C:\temp\rhino1_7R4\js.jar;C:\temp\ST-4.3.1.jar;\jdk\jdk1.8.0_251\lib\tools.jar;C:\temp\antlr-runtime-3.5.jar com.sforce.ws.tools.wsdlc C:\temp\enterprise.wsdl C:\temp\enterprise.jar
Here's where the trouble begins. Once I run this, I hit the following error:
Exception in thread "main" com.sforce.ws.wsdl.WsdlParseException: Parse error: Found invalid XML. could not determine namespace bound to element prefix xsd (position: TEXT seen ...ration value="ACTIONCALL_DUPLICATE_INPUT_PARAM">\r\n<xsd:annotation>... #17360:17)
at com.sforce.ws.wsdl.WsdlParser.next(WsdlParser.java:94)
at com.sforce.ws.wsdl.Definitions.read(Definitions.java:111)
at com.sforce.ws.wsdl.WsdlFactory.createFromInputStream(WsdlFactory.java:69)
at com.sforce.ws.wsdl.WsdlFactory.create(WsdlFactory.java:49)
at com.sforce.ws.codegen.Generator.generate(Generator.java:94)
at com.sforce.ws.tools.wsdlc.run(wsdlc.java:115)
at com.sforce.ws.tools.wsdlc.run(wsdlc.java:149)
at com.sforce.ws.tools.wsdlc.main(wsdlc.java:71)
Caused by: com.sforce.ws.ConnectionException: Found invalid XML. could not determine namespace bound to element prefix xsd (position: TEXT seen ...ration value="ACTIONCALL_DUPLICATE_INPUT_PARAM">\r\n<xsd:annotation>... #17360:17)
at com.sforce.ws.parser.XmlInputStream.next(XmlInputStream.java:138)
at com.sforce.ws.wsdl.WsdlParser.next(WsdlParser.java:90)
... 7 more
Caused by: com.sforce.ws.parser.XmlPullParserException: could not determine namespace bound to element prefix xsd (position: TEXT seen ...ration value="ACTIONCALL_DUPLICATE_INPUT_PARAM">\r\n<xsd:annotation>... #17360:17)
at com.sforce.ws.parser.MXParser.parseStartTag(MXParser.java:1826)
at com.sforce.ws.parser.MXParser.nextImpl(MXParser.java:1144)
at com.sforce.ws.parser.MXParser.next(MXParser.java:1111)
at com.sforce.ws.parser.XmlInputStream.next(XmlInputStream.java:136)
... 8 more
A snipped of the XML at error line:
<!--
These are the extension code to provide additional error information
-->
<simpleType name="ExtendedErrorCode">
<restriction base="xsd:string">
<enumeration value="ACTIONCALL_DUPLICATE_INPUT_PARAM">
<xsd:annotation>
<xsd:documentation>
Errors with this extended error code have the following properties: severity, actionCallName, parameterName
</xsd:documentation>
</xsd:annotation>
</enumeration>
<enumeration value="ACTIONCALL_DUPLICATE_OUTPUT_PARAM">
<xsd:annotation>
<xsd:documentation>
Errors with this extended error code have the following properties: severity, actionCallName, parameterName
</xsd:documentation>
</xsd:annotation>
</enumeration>
Parent schema:
<schema elementFormDefault="qualified" targetNamespace="urn:fault.enterprise.soap.sforce.com">
<import namespace="urn:enterprise.soap.sforce.com"/>
I don't know if it's necessary, but I'll note that there's no <xsd:schema...> at all in the XML file. xsd is used before this, but only to define element string types; eg: <element name="sessionId" type="xsd:string" nillable="true"/>
If I remove xsd prefix from everything that causes the error, I'll instead get the same error, but for soap instead of xsd. XML snippet of first instance of that:
<!-- Soap Binding -->
<binding name="SoapBinding" type="tns:Soap">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="login">
<soap:operation soapAction=""/>
<input>
<soap:header use="literal" message="tns:Header" part="LoginScopeHeader"/>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
There's no parent schema here.
Again, there is no <soap:schema...> defined in the XML. And if I remove all of the instances of using the soap prefix, I'll land on the following issue.
Exception in thread "main" com.sforce.ws.wsdl.WsdlParseException: targetNamespace not specified in wsdl:definitions
at com.sforce.ws.wsdl.Definitions.read(Definitions.java:115)
at com.sforce.ws.wsdl.WsdlFactory.createFromInputStream(WsdlFactory.java:69)
at com.sforce.ws.wsdl.WsdlFactory.create(WsdlFactory.java:49)
at com.sforce.ws.codegen.Generator.generate(Generator.java:94)
at com.sforce.ws.tools.wsdlc.run(wsdlc.java:115)
at com.sforce.ws.tools.wsdlc.run(wsdlc.java:149)
at com.sforce.ws.tools.wsdlc.main(wsdlc.java:71)
Again, not sure if it matters, but there's no <wsdl:definitions...> in the XML file.
I don't know if this is an issue of Salesforce generating a bad XML file (the issue occurs even in sandboxes I haven't made any database changes for, including production where I have an old but working enterprise.jar), if I don't have the right force-wsc jar file, if I'm not running it through the right version of Java (1.8, if it wasn't clear, but I've tried earlier versions of java and I just get the minor.major 52 error, which means it should be 8, as far as I know).
Any help pinpointing what the issue here is would be greatly appreciated. I'm more than open to suggestions. And if it is just Salesforce giving me a bad XML file, I can open a ticket there. I just want to make sure I'm not doing something wrong before I open a ticket.
After spending more time on this, and after coordinating with a co-worker who works on a different Salesforce project, we've discovered the following
1 Salesforce was absolutely giving a bad WSDL file.
2 The generation of the bad WSDL file only occurred because I was using a Firefox web browser. Using Chrome instead to access the WSDL generation fixed the issue, of all things.
So for any poor soul that comes across this issue in the future, I hope using Chrome fixes it for you as well.

Strange IIS/WCF Web Service Issue

Windows Server 2012 - IIS 8.x
I have a WCF web service (DLL) deployed in IIS that supports SOAP and REST over https. There is a certificate installed from Comodo for the SSL.
When I create a proxy for the service in C# apps everything works fine. Also, when I call most of the REST methods from a browser or from Postman they also work fine.
But there are a few REST methods that fail with no exception. In Chrome browser I get an error that says: "This site can't be reached." In Postman I get an error that says: "Could not get any response."
When I check the code in the WCF service I can see that the method gets called and actually executes with no exception, but nothing is returned. I've also checked the IIS logs and I don't seem to see any errors.
Here is an example of a method that works fine:
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/GetActivityRules?agencyID={agencyID}")]
List<ActivityRule> GetActivityRules(int agencyID);
Yet, this method fails:
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/GetActivity?agencyID={agencyID}&userID={userID}&date={date}&view={view}")]
List<Activity> GetActivity(int agencyID, int userID, string date, string view);
Has anyone experienced this before or have any ideas why this is happening or how best to troubleshoot?
UPDATE #1
I added code to the GetActivity function that writes to a log file each time its called. I can see the function executes correctly without error each time, but still there is no response. Makes me wonder if the problem is not related to WCF. I also added a trace listener to web config, but the file never gets created.
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "C:\Samadhi\TraceLog.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
UPDATE #2
I spent a week of mind numbing searching, reading, and checking everything I possibly could with no result. I raised a support issue with Microsoft, which was escalated to one of their senior engineers. They have spent two days looking into the problem with still no solution. They tell me they have never seen this before!
I tried using your code and testing it locally, and it looked like everything was working fine. Even if method 2 contains multiple parameters, WCF can receive them. I think the problem is somewhere else. For example, if the data volume transfer is too large, please try to configure the following code in the binding.
<binding name="mybinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
Or you can construct the collection return directly to eliminate problems with backend data queries.
to enable wcf tracing, you have to create a source configuration for System.ServiceModel. This should trace the service serialization:
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Verbose" propagateActivity="true">
<listeners>
<add name="svc" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="svc" type="System.Diagnostics.XmlWriterTraceListener" traceOutputOptions="DateTime" initializeData="c:\trace.svclog" />
</sharedListeners>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="svc" />
<remove name="Default" />
</listeners>
</trace>
<system.diagnostics>
How frustrating software development can be. I swear I'm going to need hair replacement therapy soon. I finally found what was causing the issue, and as is most often the case, it boils down to my programming error. The frustrating part is when you have no error message, or when a framework throws a generic error that gives no clue as to what's wrong.
The issue came down to the fact that WCF was unable to return the JSON result - unable to parse the list of objects into JSON. This happened because an uninitialised date value was outside the allowed min and max values. The net result was no response from the server, not even an error code. When calling the same method using SOAP, the XML parsed fine - only the REST call was failing.
I initially had problems setting up WCF trace. For some reason it was causing the service to stop working. And because it was a production server, I had only limited time frames to work with when making config changes. Finally after seeing the JSON error message I knew what to do to fix the problem.

Logging in Identity Server 3

There seems to be a lot of people asking questions about this, and yet the folks over there have decided to close my question before it's resolved; the perception being that I'm a lazy developer and haven't read documentation - not the case: https://github.com/IdentityServer/IdentityServer3/issues/3083
I've followed the instructions here: https://identityserver.github.io/Documentation/docsv2/configuration/logging.html
but I cannot get logging to happen.
My question really at this point in time is, assuming I haven't done something wrong, does it matter that I'm firing things from a unit test method?
I have a separate unit test project which is just requesting a token and writing the response out, but I'm getting a 500 error somewhere and I'd assume logging would tell me why.
The test was working before I had some repo issues a while ago and lost some work, and I THINK I am back to where I was, but I'm sure the root cause will be something simple that I've overlooked - it usually is.
Anyway, I really hope someone can help, and not just be snotty.
Many thanks!
First adding logger to IdentityServer Configuration (if Owin, under Startup public void Configuration(IAppBuilder app) method;
Serilog.Log.Logger = new LoggerConfiguration()
.WriteTo.Trace(outputTemplate: "{Timestamp} [{Level}] ({Name}){NewLine} {Message}{NewLine}{Exception}")
.CreateLogger();
Then adding webconfig the following under configuration;
<system.diagnostics>
<sources>
<source name="Thinktecture.IdentityServer" switchValue="Information, ActivityTracing">
<listeners>
<add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="trace.svclog" />
</listeners>
</source>
</sources>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="sybsListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="Trace.log" />
<remove name="Default" />
</listeners>
</trace>
After running, and trying to interact with the IndentityServer, you can check the Trace.log file under your project. Don't forget selecting "Show All Files"
Based on Trace.log, can you specify the problem again if you can't solve?
I managed get logging working by wrapping my unit test in
using (var logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.File(#"C:\Users\Richard Terris\Desktop\idsLogs.txt")
.CreateLogger())
{
It's not the best solution possibly, but it works!
Thanks for the replies!

Sitecore 8.1 error: "No session Id managers were found to manage the session Id for the current request"

I'm attempting to get a basic layout up and running in Sitecore 8.1, and I've hit an error about which I can find very little information. When attempting to view any page (even the backend interface or connecting from Sitecore Rocks), I get the message "No session Id managers were found to manage the session Id for the current request."
Some Googling suggests that this has to do with some issues with the out-of-box session provider and recommends swapping it out for keeping the sessions in Mongo. Sitecore's documentation provides a description of this, both for shared and private sessions. I've attempted to implement those but continue to receive the same error.
Here's my code as it stands now:
App_Config/Include/MongoSessionProvider.config
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<tracking>
<sharedSessionState>
<providers>
<clear/>
<add name="mongo" type="Sitecore.SessionProvider.MongoDB.MongoSessionProvider, Sitecore.SessionProvider.MongoDB" connectionString="session" pollingInterval="2" compression="true" sessionType="shared"/>
</providers>
</sharedSessionState>
</tracking>
</sitecore>
</configuration>
App_Config/Include/ConnectionStrings.config (excerpt)
<add name="session" connectionString="mongodb://localhost/sharedsession" />
Web.config (excerpt)
<sessionState mode="Custom" cookieless="false" timeout="20" sessionIDManagerType="Sitecore.FXM.SessionManagement.ConditionalSessionIdManager" customProvider="mongo">
<providers>
<add name="mongo" type="Sitecore.SessionProvider.MongoDB.MongoSessionStateProvider, Sitecore.SessionProvider.MongoDB" sessionType="Standard" connectionStringName="session" pollingInterval="2" compression="true" />
<add name="mssql" type="Sitecore.SessionProvider.Sql.SqlSessionStateProvider, Sitecore.SessionProvider.Sql" sessionType="Standard" connectionStringName="session" pollingInterval="2" compression="true" />
</providers>
</sessionState>
Note that this is on my local development machine. I have Mongo running (and confirmed its connection to Sitecore), and I created both the session and sharedsession databases in it using use session and use sharedsession, which I understand to be the way to create DBs in Mongo.
Am I missing something here? Or does the error simply not mean what I think it means?
The message you are seeing is not supposed to be an error, it is rather a log warning. It is related to retrieving the configuration of the Session ID Manager rather that to the configuration of the session itself.
Why this warning normally appears
In the Sitecore.config under <pipelines> there's the getSessionIdManager pipeline defined.
<getSessionIdManager>
</getSessionIdManager>
In the Sitecore.FXM.config, there is a processor configured for this pipeline:
<getSessionIdManager>
<processor type="Sitecore.FXM.Pipelines.ChooseSessionIdManager.FXMSessionIdManagerProcessor, Sitecore.FXM" />
</getSessionIdManager>
This pipeline allows to dynamically select a Session ID Manager for the request. In the default Sitecore configuration, a non-default Session ID Manager will be used only for requests with explicit sessionId URL parameter, i.e. for FXM requests only.
For all other requests, no Session ID Manager will be explicitly selected, and the default System.Web.SessionState.SessionIDManager will be used; this is reflected in the warning message you're seeing. There is nothing wrong with this situation per se, this is by default and by design.
Seeing the message as an error on every page request
This definitely sounds like a defect to me. This message is supposed to be logged once per application lifetime instead of being thrown as an exception on every page.
You should report this to Sitecore support.
An attempt to fix
I cannot debug your system, so I have to do this blindfolded. I would try to create you own Session ID Manager selector:
public class CustomSessionIdManagerProcessor
{
public void Process(GetSessionIdManagerArgs args)
{
if(args.SessionIdManager == null)
{
args.SessionIdManager = new System.Web.SessionState.SessionIDManager();
}
}
}
Configure it as the last processor in the getSessionIdManager pipeline. This will make sure that there is always an explicitly selected Session ID Manager and should hopefully prevent the error from happening.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<getSessionIdManager>
<processor type="YourNamespace.CustomSessionIdManagerProcessor, YourAssembly" />
</getSessionIdManager>
</pipelines>
</sitecore>
</configuration>
In case it helps anyone else, we were running into this issue as well after upgrading to Sitecore 8.1 rev. 151003.
In our particular case the issue was with a namespace change in this line in the Web.config:
<sessionState mode="InProc" cookieless="false" timeout="20"
sessionIDManagerType="Sitecore.FXM.SessionManagement.ConditionalSessionIdManager">
That should be the following:
<sessionState mode="InProc" cookieless="false" timeout="20"
sessionIDManagerType="Sitecore.SessionManagement.ConditionalSessionIdManager">
It might have been something we missed in the upgrade guide, but we finall found it after pulling down the a copy of Sitecore 8.1 rev. 151003.zip from the downloads page.

IISExpress 8 with custom configuration file - web service won't load

When I develop a WCF service or website solution, I always use IISExpress with a custom configuration file so I can share the setup with other developers in the team. Basically, I run a batch file with the following command in it:
"C:\Program Files (x86)\IIS Express\iisexpress.exe" /config:service-hosts.config
Where service-hosts.config is the path to my custom configuration file.
This method has been working perfectly fine, and still works fine in other solutions on my PC (each with their own service-hosts.config file). However, I've just started having a problem loading a WCF service using this method. I'm getting the following error when trying to browse to the service root dir, or any of the built in help endpoints:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information:
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x80070003
Config Error Cannot read configuration file
Config File \?\D:\Projects\MyProject\WCFSite\web.config
Requested URL http:// localhost:80/
Physical Path
Logon Method Not yet determined
Logon User Not yet determined
Request Tracing Directory C:\Users\Spikeh\Documents\IISExpress\TraceLogFiles\
Config Source:
-1:
0:
More Information:
This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.
If you see the text "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined", this error is because you are running a .NET Framework 3.5-based application in .NET Framework 4. If you are running WebMatrix, to resolve this problem, go to the Settings node to set the .NET Framework version to ".NET 2". You can also remove the extra sections from the web.config file.
View more information ยป
I've been debugging for hours and can't get this error to change, let alone fix it.
I've tried overwriting my service-hosts.config file with a few different versions of applicationHosts.config, running IISExspress in 64bit, replacing the web.config file with a very basic version, setting permissions on the directory (to the point where every user on my PC has access), and changing the app pool, but still no change.
The weird thing is... when I change the WCF project to use "IISExpress" in the Web section of project properties, then subsequently debug the project, everything works fine... even with all of my web.config settings in place.
This points to how I'm running IISExpress, or my service-hosts.config file... though the service-hosts.config file (with slight modifications for the sites involved) is exactly the same as it is in my other projects.
One thing to note (might be a red herring), but I did downgrade the solution from VS2012 to VS2010, and changed the framework target to .Net 4.0... not sure if something might be configured funny due to that?
Does anyone have any ideas? I'm at the point of jumping off the roof...
UPDATE:
Here's the debug information from IISExpress (running with /trace:e):
Running IIS...
Starting IIS Express ...
Initializing the W3 Server Started CTC = 5514916
PreInitSitesThread: Premature Exit Occured ( hr = 80070003 )
W3 Server initializing WinSock. CTC = 5514916
W3 Server WinSock initialized. CTC = 5514916
W3 Server ThreadPool initialized (ipm has signalled). CTC = 5514916
Start listenerChannel http:0
Successfully registered URL "http://*:80/" for site "MyWebsite" application "/"
Registration completed for site "MyWebsite"
AppPool 'MyCustomAppPool' initialized
InitComplete event signalled
IIS Express is running.
Enter 'Q' to stop IIS Express
IncrementMessages called
Request ended: http://localhost:80/ with HTTP status 500.19
And here's the important part of my service-hosts.config:
<applicationPools>
<add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_BIN%\config\templates\PersonalWebServer\aspnet.config" autoStart="true" />
<add name="Clr4ClassicAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_BIN%\config\templates\PersonalWebServer\aspnet.config" autoStart="true" />
<add name="Clr2IntegratedAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_BIN%\config\templates\PersonalWebServer\aspnet.config" autoStart="true" />
<add name="Clr2ClassicAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_BIN%\config\templates\PersonalWebServer\aspnet.config" autoStart="true" />
<add name="UnmanagedClassicAppPool" managedRuntimeVersion="" managedPipelineMode="Classic" autoStart="true" />
<add name="IISExpressAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_BIN%\config\templates\PersonalWebServer\aspnet.config" autoStart="true" />
<add name="MycustomAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
<applicationPoolDefaults managedRuntimeLoader="v4.0" >
<processModel/>
</applicationPoolDefaults>
</applicationPools>
<listenerAdapters>
<add name="http" />
</listenerAdapters>
<sites>
<site name="MyWebsite" id="1">
<application path="/" applicationPool="MyCustomAppPool">
<virtualDirectory path="/" physicalPath="D:\Projects\MyProject\WCFSite\" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
<webLimits />
Seems that the service-hosts.config file was pointing to something it shouldn't have been pointing to. I replaced my service-hosts.config with an copy from an older project (and therefore an older version of IISExpress / .Net Framework) and everything works fine.
Sounds like it was to do with my 4.5 -> 4.0 downgrade after all.