简体   繁体   中英

Entity FrameWork not responding from a WCF webservice

I create a WCF webservice and in this webservice I use EF 6 (tried 5 as well). The project compiles and it runs perfectly on a different server (also 2012R2).

In my application I set the webservice to create Asynchronous methods.

When using the webservice I get an error related to the config file (I haven't changed anything in this config file), but I will get to the config file a bit later.

When I setup a sample program and only call "HelloWorld", I get Hello.

So the webservice by itself functions.

When on the server I create a test program that uses the same version of EF. It works. So no problem there.

But when I try to use my webservice with a method that uses EF, than simply nothing happens. e.result is string.empty, also no error is returned.

How about the error in the web.config file. When I publish the webservice with the original config file. I get the following error whe trying to open the webservice directly from the browser of the server:

Error 500.19 Config Source: 4: For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 5:
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </configSections>

It clearly complains about the name section entityFramework.

When I change entityFramework into EntityFramework ( so with a capital E), than I can open the webservice directly from the browser of my server. And now I can also implement it in my programs.

As mentioned HelloWorld works fine, but there still is a problem when trying to use EntiTyFramework through this webservice.

Is there some setting that I forgot on this server?? As mentioned when I test it on a different server (with the original config file) than it works??

I also setup VS2015 on this server and even created the project new on this server. It didn't make any difference.

I hope someone can tell me what to do??

I found the actual problem and a solution for me.

On the server that I installed this webservice, I installed it on a directory inside a website where the website itself is also using entity framework.

IIS reads the web.config from this webserice but internally it adds this to the web.config from the root (so the web.config from the website).

The configuration editor in IIS for the website complains about a second entry with the name entityFramwork (and only when you would combine these web.configs would you get this. Because each web.config only has one entry: entityFramework).

As I have multiple websites on this server, I simply installed the webservice on a website that doesn't use Entity Framwork. Eh Voila, my problem is over.

I hope someone else may benefit from this, it cost me a lot of time to figure this out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM