none
Errors when trying to develop a WCF service

    Question

  • Hello to anyone who can help,

    I'm just going through error after error with WCF.  I have Windows 7 64-bit edition, am running IIS7, and using C# and Visual Studio 2010.  I'd like to know if there's a definitive guide to deploying a WCF service to IIS without errors.  Right now, when I try to follow any MSDN guides, they don't explain what any possible errors might mean and so I have no idea what I did wrong (or what to do next) when I run into errors.

    First of all, I created an IIS Application called "MagicEightBallService" as a test WCF server.  I followed the guide located here but named it MagicEightBallService instead of IISHostedCalcService.  As I'm following the guide, I feel myself questioning the process--it seems odd that I'm directly placing all my code in "App_Code\Service.cs" (The guide is ambiguous here; do all web services need this Service.cs? How do I split this into multiple files? How is it getting compiled? I can really just run this straight off of source code? That doesn't seem right.). 

     

    Sure enough, when I navigate to http://localhost/MagicEightBall/Service.svc, I get a big fat error page:


    HTTP Error 404.17 - Not Found

    The requested content appears to be script and will not be served by the static file handler.

     

    So, what am I doing wrong?

     

    My folder hierarchy:

        C:\WCFTEST\MagicEightBallService <-- IIS Application Physical Path

        C:\WCFTEST\MagicEightBallService\Service.svc

        C:\WCFTEST\MagicEightBallService\App_Code

        C:\WCFTEST\MagicEightBallService\App_Code\Service.cs

        C:\WCFTEST\MagicEightBallService\App_Code\Web.config

     

    Thanks,

    Jay Sullivan


    Tuesday, June 14, 2011 8:27 PM

Answers

  • Okay, I think I fixed it.  Here's what I did.

    In Visual Studio, I clicked "Publish to File System" to a temp directory, to see the contents, which was:

        - bin

            - MagicEightBall.dll

            - MagicEightBal.pdb

        - MagicEightBallService.svc

        - Web.config

    So I copied these to my application directory (C:\WCFTEST\MagicEightBallService) and navigated to http://localhost/MagicEightBall/MagicEightBallService.svc and it works.

    Sometimes MSDN leads me down a horrible path of outdated information that really gets me in trouble.  They need to clarify which version of what they're dealing with. 

    • Marked as answer by Yi-Lun Luo Thursday, June 16, 2011 2:20 AM
    Wednesday, June 15, 2011 4:51 PM

All replies

  • It looks as if IIS doesn;t know about WCF services

    Try running servicemodelreg -ia 

    This .exe is located in the framework system folder

    c:\windows\Microsoft.NET\Framework\v4.0.30319


    Richard Blewett, thinktecture - http://www.dotnetconsult.co.uk/weblog2
    Twitter: richardblewett
    Wednesday, June 15, 2011 7:13 AM
    Moderator
  • Okay, I did:

     

      c:\Windows\Microsoft.NET\Framework\v4.0.30319>servicemodelreg -ia
      Microsoft (R) WCF/WF registration tool version 4.0.0.0
      Copyright (c) Microsoft Corporation. All rights reserved.
    
      Administration utility that manages the installation and uninstallation of
      WCF and WF components on a single machine.
    
      [Warning]The HTTP namespace reservation already exists.

     


    And restarted the web site.  Nothing changed, I still get the same error. 

    What do I do??


    Wednesday, June 15, 2011 2:22 PM
  • Also, is it normal that my IIS tree view for the site looks like this:

     

    - Sites

      - WCFTEST

        - MagicEightBallService

        - MagicEightBall

            - App_Code

     

    Where the "MagicEightBallService" entry has a folder icon (I can't remove it, I think IIS is picking it up as a folder) and "MagicEightBall" is an Application and has a web application icon. How do I avoid the duplicate entry here?

    Wednesday, June 15, 2011 2:27 PM
  • I have only deployed a couple WCF web services but all my compiled code was in the Bin folder and the web.config file along with the .svc file was at the root level of the target folder tree not down in the App_code folder.
    Wednesday, June 15, 2011 2:39 PM
  • Okay, I think I fixed it.  Here's what I did.

    In Visual Studio, I clicked "Publish to File System" to a temp directory, to see the contents, which was:

        - bin

            - MagicEightBall.dll

            - MagicEightBal.pdb

        - MagicEightBallService.svc

        - Web.config

    So I copied these to my application directory (C:\WCFTEST\MagicEightBallService) and navigated to http://localhost/MagicEightBall/MagicEightBallService.svc and it works.

    Sometimes MSDN leads me down a horrible path of outdated information that really gets me in trouble.  They need to clarify which version of what they're dealing with. 

    • Marked as answer by Yi-Lun Luo Thursday, June 16, 2011 2:20 AM
    Wednesday, June 15, 2011 4:51 PM
  • On the newer MSDN webpages there is a filter near the top of the page ( right under the title ) to select which version of the framework you are working under.
    Wednesday, June 15, 2011 5:05 PM