0

I am currently working on a WCF service application in C#. There are some dependencies from both .NET and 3rd party libraries.

After deploying it on IIS 7, the structure looks like this:

  • App_Code
    • IService.cs
    • Service.svc.cs
    • ...
  • bin
    • [3rd party libs].dll
  • Service.svc
  • Web.config

The Service.svc file contains this:

<%@ ServiceHost Service="MyWebService.Service" %>

And when opened in the web browser on the server itself, I get the missing reference error (CS0234). So I tried to add references manually in the Web.config:

<system.web>
    <compilation debug="true" targetFramework="4.5">
        <assemblies>
            <add assembly="System" />
            [...]

Now obviously I need a fully qualified name here, not just "System". But where do I get it? I feel like I've done something wrong in the process of deployment. I tried to use VS "publish" feature, but I didn't get it running yet, so I don't know if "publish" will do it for me.

So the question remains: How do I add my references to the WCF service? Web.config or otherwise...?

bytecode77
  • 14,163
  • 30
  • 110
  • 141
  • you can access the endpoint. Get the `wsdl` from there. – Amit Kumar Ghosh Jun 23 '16 at 11:46
  • have you tried adding a web service by right-clicking References -> Add Service Reference... and entering http://foo.bar/mywebservice.svc ? – Ryan Searle Jun 23 '16 at 11:47
  • My WCF service absolutely works on localhost. The only difference on live using IIS is that the **.csproj** file is not deployed and therefore the service doesn't know which assemblies to reference to. – bytecode77 Jun 23 '16 at 13:01
  • Your problem isn't what you think it is. It's impossible to say with the info you have provided but I will guess it is a framework mismatch if System is one of the missing references. Is the app pool running under framework 2 or 4? – Crowcoder Jun 23 '16 at 23:35
  • We use .NET 4 (4.5) for everything. And I'm pretty sure the issue lies in the fact that it's not fully qualified, like for example `LibraryXYZ, Version=1.0.0.0, Culture=neutral, PublicKeyToken=FFFFFFFFF`. When I create an ASP.NET Web**Site** and add references, they are added to **Web.config**. In this example, nothing was added and I'm not really sure how I'm supposed to add it myself. – bytecode77 Jun 24 '16 at 06:06
  • What is "it"? You mean System? You don't worry about that, its in the GAC. You haven't said if you checked the AppPool. – Crowcoder Jun 24 '16 at 10:26
  • "System" might be in the GAC, but other dependencies aren't. And I would like to manage this using the Web.config, not IIS. Also, specifying "System", like in my example doesn't work, because fully qualified names are required. – bytecode77 Jun 24 '16 at 11:58
  • If I'm wrong you only wasted 5 seconds of your life. Unless you have changed the default configuration, your app pool is probably running under framework 2.0. This has nothing to do with how you compiled your code. Check your app pool! – Crowcoder Jun 24 '16 at 12:27
  • I checked it: It's running under v4.0, not v2.0. – bytecode77 Jun 24 '16 at 12:32

0 Answers0