0
votes

I have a ASP.Net Web Forms application (project 1), an Entity Framework data access library (project 2) and a WCF service library (project 3). The Asp.Net project has an *svc file that redirects calls to the corresponding WCF service in project 3. I am debugging locally using VS 2012 (+ its integrated server) and thus NO IIS is used.
I am encountering the following problem: if I use a page inside project 1 to get some data from the EF database, everything works fine, but when I use a remote WCF client to call the same method, if fails. The error says that the connection string for the database couldn't be found. Upon investigating, I figured out that the if I call the query from the ASP project, the connection string located in Web.config file of project 1 is correctly used. However, if I call the query over the WCF service, the App.config of the service library is used (which of course doesn't contain any connection strings).
Up until now I thought that .NET does NOT support fragmented configuration files for DLLs (this is the reason why you have to copy over the endpoint/service configuration elements from the service App.config to the ASp.Net Web.config file).
So does anybody know how I can get my service to use the Web.config instead it's very own App.Config, which it shouldn't use anyways?

Edit: added code for *svc file and service interface + service implementation

SimulatorWcfServices.svc (project 1: the main ASP.Net Web Application):

<%@ ServiceHost Language="C#" Debug="true" Service="Blub.SimulatorWcfServices.DataExchangeService" %>

IDataExchangeService.cs (project 3: the SimulatorWcfServices service library)

  [ServiceContract]
    public interface IDataExchangeService
    {
        [OperationContract]
        IDictionary<string,string> GetData();
    }

DataExchangeService.cs (project 3: the SimulatorWcfServices service library)

 [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class DataExchangeService : IDataExchangeService
    {
        public IDictionary<string, string> GetData()
        {
            return new DataAccessImplementation.DataDAO().GetAllData(); //call to project 2
        }
    }
1
delete the app.config - T McKeown
WCF uses Web.config. Copy your connection string into them. - Gandarez
@TMcKeown McKeown: if I do this, the Service doesn't work at all because it does not know its configuration. It seems to get its whole configuration from the App.config in the service DLL. Gandarez: my whole problem is that the WCF service does NOT use the Web.config... - Cleo
then this service is not coded as a .svc web resource OR you are specifically looking for that config. - T McKeown
I don't know what a ".svc web resource" is; so I have added my code for clarification... - Cleo

1 Answers

0
votes

I solved the issue by switching my webserver used for debugging from "Local IIS Webserver" to "Visual Studio Development Server" (Project --> Properties --> Web --> Server). So basically I downgraded the used server. Now its uses the correct Config file and the assemblies seem to be loaded in correct order and not only partially.