views:

61

answers:

1

Hello all,

I have a WCF service, a MS SQL database, and the Visual Studio 2008 development environment all in one machine. The operating system is Windows Server 2008 with IIS 7 on it. The IIS 7 hosts my WCF service and the service is connecting to a database using Microsoft Entity Framework. Currently, I'm testing the WCF service using the WCF Test Client program from Microsoft.

The problem is that when I declare an entity like this in my WCF method:

NewTestDBEntities db = new NewTestDBEntities();

the WCF service client shows an error if I connecting to the WCF service hosting on IIS.

This is the error message form the WCF service client:

Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.

I know this line throws an error because if I take this line away, then the WCF call completes.

I also tried to test the WCF service by running the debugger (the WCF service client is connected to the ASP.NET Development Server, not IIS), and this line of code

NewTestDBEntities db = new NewTestDBEntities();

runs without error. Does anyone know why this happen?

Thank you very much.

A: 

Your WCF service is hosted in IIS - but did you copy the connection string needed for EF4 into the relevant web.config, too??

If just the creation of the object context (the NewTestDBEntities) fails off the bat, it's typically because the connection info isn't available to your host application (here: IIS).

marc_s
Thank you very much for your help. I solved the issue.
Peter
@peter: would you care to share how you solved the issue?? Someone else might benefit from that
marc_s
I have a ASP .NET project in the same solution as my WCF service project. The ASP .NET project basically referenced the WCF project so I can put on to IIS. Thus, there will be two .config file. I have the connection string in my config file in WCF service project but not the config file in the ASP .NET project. That's the promblem that I had. So the solution is to copy the connection string to the config file in the ASP .NET project. That's it!
Peter