开发者

Entity framework issue with WCF and IIS

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 config开发者_开发百科uration 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.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜