Search code examples
wcf

WCF Service Client Generation name space issue


I have an issue with the generation of a WCF Client. The main project is called TestX. In that project, I'd like to include a WCF Service named MgmtService. I can include that service in another project just fine.

I add the connected service reference and (on purpose) I name it ServiceReference1 (I have tried other arbitrary names as well to rule out a namespace clash - no change).

Immediately when I try to to compile, I will get the error message

The type name 'ServiceReference1' does not exist in the type 'TestX'

What really gets me is, that I can add an additional project (a simple DLL) and then add the reference there and it will compile just fine and work like a charm.

How can I debug this issue? It looks like there is an underlying issue and it's not the creation of the client itself.


Solution

  • Well, of course it was a namespace clash, although at some completely different place than expected.

    I had the namespace TestX used and since this was a windows service type application it also contained a class called TestX. This in itself was not an issue until I added the WCF Client.

    Adding the WCF Client created the type TestX.ServiceReference1 BUT the compiler now didn't know if to use the namespace TestX or the class TestX.

    Renaming the class which previously existed fixed the issue.