I’ve been working the past week on some custom WCF transport channels. It’s been pretty instructive, though it can be a bit of a frustrating experience at times.
The past couple of days, I’ve been busy getting metadata/policy export/import working correctly, and ran into an error when using SvcUtil.exe to import my service metadata:
Attempting to download metadata from 'http://localhost:6466/Metadata/' using WS-Metadata Exchange or DISCO.
Error: An error occurred in the tool.
Error: The binding on the service endpoint cannot be configured.
Parameter name: endpoint.Binding
This is a pretty generic error message that, well, doesn’t really tell you anything.
SvcUtil.exe (and it’s related VS feature) is a pretty key piece of the WCF developer toolkit, but, unfortunately, it’s (a) full of bugs and (b) has horrible error handling, which makes diagnosing problems with metadata import incredibly frustrating.
As usual, the problem turned out to be mine: I had registered my
IPolicyImportExtension/IWsdlImportExtension implementation in a custom app.config file that I was feeding to SvcUtil using the
/svcutilConfig argument. This worked fine and the importer was getting correctly invoked and executed just fine.
However, I forgot to register my
bindingElementExtension for my custom binding and custom transport binding element, which prevented SvcUtil from serializing the custom binding to the configuration XML.
Once I fixed that, it worked right away. I just wish that SvcUtil could have generated a clearer error message pointing out what the problem actually was.