Home > .NET > WCF Add Service Reference gotcha with Windows Server

WCF Add Service Reference gotcha with Windows Server

We recently switched from developing in Vista to Windows Server 2003. Someone had the bright idea that we should develop in the same environment the application is going to be hosted on. Go figure.

What that meant is that you run into wierd issues like this one. When trying to add a Service Reference to a WCF service hosted under IIS you keep getting this 'Add Service Reference Error':

Metadata contains a reference that cannot be resolved: 'http://merill/Services.Host/ClientProfile.svc?wsdl'.
The WSDL document contains links that could not be resolved.
There was an error downloading 'http://merill/Services.Host/ClientProfile.svc?xsd=xsd0'.
The underlying connection was closed: An unexpected error occurred on a receive.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host
Metadata contains a reference that cannot be resolved: 'http://localhost/Services.Host/ClientProfile.svc'.
Metadata contains a reference that cannot be resolved: 'http://localhost/Services.Host/ClientProfile.svc'.
If the service is defined in the current solution, try building the solution and adding the service reference again.

The key part of this message is the reference to the downloading of the xsd. When I tried accessing the .svc url in a browser it worked fine, but trying to access the .svc?xsd=xsd0 brings up the generic 'cannot display webpage' message.

When you unleash your weapon (Process Monitor) on the csc.exe process (this is the compiler generating the xsd) you'll realise that the IIS identity IIS_WPG does not have access to the Windows\Temp folder. Give enough rights to the folder and viola problemo solved.

Happy WCF programming on Windows Server!

Categories: .NET Tags:
  1. 5he11
    January 31st, 2009 at 08:36 | #1

    thx a lot ! it helps

  2. February 10th, 2009 at 12:03 | #2

    Hey many thanks for this post, i’ve been hours trying to solve this problem, thanks again

  3. Nick
    February 20th, 2009 at 07:41 | #3

    That was the most helpful article I have found on this issue. No way I would have thought of looking for directory permissions. Thanks.

  4. Sivaram
    July 14th, 2009 at 16:53 | #4

    Thanks a lot for the post. I had a similiar issue. Your solution resolved the issue.

  5. TC
    August 22nd, 2009 at 09:57 | #5

    Thankyou! This solved my problem.

  6. Charlie
    November 11th, 2009 at 03:29 | #6

    Thank you very much! I wouldn’t have come to this solution on my own!

  7. Feng
    February 12th, 2010 at 00:40 | #7

    Thank you! You save my time! :-)

  8. Eking
    April 21st, 2010 at 11:54 | #8

    Hi there- i got exactly the same problem but the solution provided here didnt help me… in my error it also says …..401: Access Denied….The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'….
    PLEASE HELP – IT CONSUMED MORE THAN A FEW WORK DAYS TO ME!!
    Thank you all in advance

  9. emizzle
    May 19th, 2010 at 00:34 | #9

    Thanks, mate! Worked like a charm!

  10. June 3rd, 2010 at 01:38 | #10

    I totally agree the standpoint of upstairs, and I believe this will be a trend. I often come this forum , rom here I learn much and know the newest tide! the content here constantly update shoe and I love it! Another I know some websites which often update their contents, you guys should browse if you are free. http://inin-from.com

  11. SandraMillhouse
    June 11th, 2010 at 09:22 | #11

    It seems that the Windows server was created to make our lives a living hell! I'm just kidding. Yes, this type of server has made many programmer's lives unhappy but that happens with any type of equipment. I use Windows for my VPS hosting although a year ago I was using Linux. Can't really see a difference.

  12. Aviad
    August 8th, 2010 at 13:20 | #12

    Worked for me, thanks!

  13. Ramesh Pydi
    August 10th, 2010 at 21:19 | #13

    i am also getting the same problem. I given full permissions on windowsTemp folders for IISUSers. still same error. please help me out !!

  14. Aasmund
    November 5th, 2010 at 09:52 | #14

    Fantastic – I would never have occurred to me that permissions on the temp folder could be the source of the problem. (Looks like I should invest some time in learning Process Monitor.) This saved a lot of hair-pulling; thank you!

  15. Hrmz
    November 10th, 2010 at 22:57 | #15

    Many many… Thanx

  16. chandu
    November 23rd, 2010 at 11:43 | #16

    thanks for the nice information

  17. Deepka Gaur20
    December 30th, 2010 at 05:02 | #17

    it’s working fine.. thanks buddy.. it’s really nice implementation

  18. April 16th, 2011 at 18:12 | #18

    Thank you, thank you! This error was driving me crazy!!!!

  19. June 2nd, 2011 at 14:35 | #19

    YOu have no idea how long i’ve been fighting with this… Thank you.

  20. sushil Jadhav
    June 25th, 2011 at 01:07 | #20

    Thank you. Thank you. Thank you. Finally my search stopped. :)

  21. VipeR
    October 19th, 2011 at 05:51 | #21

    THX!!!

  22. Luciano
    November 18th, 2011 at 04:07 | #22

    THX! You save my head …

  23. December 3rd, 2011 at 07:47 | #23

    Holy crap, thank you so much. I was pulling my hair out over the past 4 hours trying to get our WCF service running correctly on a production machine with HTTPS. Gave the IIS_USERS rights to Windows/Temp and poof, XSD files were available. THANK YOU!!!!!!

  24. zviadi
    December 14th, 2011 at 21:35 | #24

    thanks a lot it worked. I gave IIS_IUSRS read write permissions to Windows/Temp folder and worked :)

  1. February 3rd, 2010 at 06:25 | #1
  2. December 20th, 2011 at 06:31 | #2