Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when consuming service : The type name ‘AAA' does not exist in the type ‘YYY.YYY’

I'm trying to consume a WCF 4.0 service in my application. I built, tested, and deployed the service from the ground up. The service works in the WCF test client and can be consumed in any other test project I built. The problem is this one particular application... the only one that matters as it's the reason I built the service.

When I build the application after referencing the service I get an error. The error is "The type name 'AAA' does not exist in the type 'YYY.YYY' ".

The project consuming the service is named 'YYY.Web' and is in the 'YYY' namespace.

The service was initially created in the 'YYY.ReportingService' namespace. It has been changed to a different namespace once this problem started. Is now in the 'MMM' namespace.

I added a using directive 'YYY.Service1'. I also tried aliasing the using directive (using test = YYY.Service1)

To make sure something wasn't messed up with my service and its namespaces, I built a new service with a single method. It takes a string parameter and returns "Hello, " and whatever string is passed. This services also works in the WCF test client and the couple of test projects I created. This service is in the SimpleTestService namespace, BasicService class, with a methiod named GetGreeting. Naming was done intentionally to avoid any possible naming collisions. The error still occurs with this new service.

Any thoughts on this? Thanks!

like image 558
user978467 Avatar asked Oct 04 '11 13:10

user978467


2 Answers

This one took me a while. Turned out, that "The type name 'AAA' does not exist in the type 'YYY.YYY' " was caused by the YYY.YYY - my consuming class sharing name with its containing namespace.

Solution: rename the consuming class to something that is not equal to the full name of its namespace, i.e. YYY.XXX.

like image 103
Frederik Struck-Schøning Avatar answered Oct 21 '22 06:10

Frederik Struck-Schøning


I realize it's and old question, but I just had this problem and the issue was a namespace conflict.

In my case AAA was named ServiceClient and that generated the same error you experienced. Once I removed the namespace conflict (called it ConsoleClient instead) all worked as expected.

like image 32
Sean Gough Avatar answered Oct 21 '22 08:10

Sean Gough