Thursday, June 19, 2008

WCF - The type name ServiceReference1 does not exist in the type Namespace.ClassName

This is a short blog post about a strange error when adding a WCF service reference. A WCF service was created and I wanted to add a service reference to a client project. I added the reference through Visual Studio and everything went fine until I compiled. Then I got this error:
Error    3    The type name 'ServiceReference1' does not exist in the type 'MyWorld.MyWorld' ...\Service References\ServiceReference1\Reference.cs

I found that this is caused by me having the same namespace name as class name (MyWorld.MyWorld = Namespace.ClassName). Change your namespace to a name that is not the same name as your class and this will compile.

29 comments:

duluca said...

Very good find. Saved me a lot of heartache.

Anonymous said...

Excellent, been wracking my head over this on and off for a few hours!

roc1 said...

Thanks for posting this. You solved my problem.

regain said...

Ditto

Anonymous said...

I love you for this.

Luke_PL said...

Thanks a lot for this ! :)

Anonymous said...

Great find. Saved me major pain.

Anonymous said...

Great find. Saved me major pain.

Anonymous said...

Great:) Solved my problem.

Vaibs said...

Great Work!!

Anonymous said...

Another thank you... worked a charm!

Anonymous said...

Thanks
I had been going at this for over an hour.

Juliana said...

Thanks a lot, my pain has gone

Anonymous said...

That was my headache, too! Thx!

WhiteRabbit said...
This comment has been removed by the author.
WhiteRussian said...

Thank you!

seezeey said...

Thanks for saving me lots of time, great post...

--engin

Santosh said...

thanks a lot dude..really helped me..

nape said...

I want you to have my baby.

Andy said...

So simple. Thank you very much for the assistance.

shparun said...

it's great that you wrote this post

Anonymous said...

Thanks so much!

Vladimir said...

Thank you for your post.

As it happens it's relevant to WCF 4.0 too

Anonymous said...

Thanks, this helped me out a ton.

85 XJS said...

How did you find/figure this out. I appreciate your posting it because I couldn't figure out how to make it go away.

Anonymous said...

Great, it worked for me. All I did was rename my namespace and it fixed the error. Well said.

Samchez said...

OMG thanks a lot, I can't believe I fell for this.

David M. Sterling said...

Kudos; saved me while working on SharePoint 2010.

Anonymous said...

Also a big Thank you.

This has wasted hours of my time.