Thursday, September 20, 2007

The type 'namespace.ClassName', provided as the Service attribute value in the ServiceHost directive could not be found.

So I'm working through my WCF Step-by-step using my favourite langauge, VB.NET, although the book is written in C#! No VB.NET code here so I have to translate and type, no copy paste for me. Well after carefully crafting an interface as the public part of my service and implementing the interface in a class, I build the svc file just like the book and get

The type 'Products.ProductsServiceImpl', provided as the Service attribute value in the ServiceHost directive could not be found.

I think this is a typo, so I check my namespace, OK, I check the Class that implents the interface and it checks out, so I google a bit and some say, you need the fully qualified name. hmmm So I take of the rootnamespace on the assembly and all is OK. But this is not the way to fix problems, I want my rootnamspace so I decide to alter the svc to look like this:

ServiceHost Service="ProductsService.Products.ProductsServiceImpl"

Looks good but then I get another error:

Service 'ProductsService.Products.ProductsServiceImpl' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

So lets look in the Web.config, under system.serviceModel section:

service behaviorconfiguration="ProductsBehavior" name="Products.ProductsServiceImpl"
endpoint address="" contract="Products.IProductsService" binding="basicHttpBinding"

Ohhh the servicename and the contract are now wrong:


Ah at last the service is up and running and browsing the svc file in IE7 shows me the link to the WSDL and all is well.


TennesseeJed said...

Thank you!! I've been banging my head against a wall for about 4 hours now trying to get these examples to work! I can't believe that VB has to be so much more difficult than C#.

Jakesy said...

Oh man. THANK YOU! I've just spend five hours on this problem. Man I reckon you've just saved for five more.

Gordopolis said...

top tip - works a treat!