简体   繁体   English

实体框架未从WCF Web服务响应

[英]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). 我创建了WCF Web服务,并且在此Web服务中,我使用EF 6(也尝试过5)。 The project compiles and it runs perfectly on a different server (also 2012R2). 该项目可以编译,并且可以在其他服务器(也可以是2012R2)上完美运行。

In my application I set the webservice to create Asynchronous methods. 在我的应用程序中,我将Web服务设置为创建异步方法。

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. 使用Web服务时,出现与配置文件相关的错误(我没有更改此配置文件中的任何内容),但是稍后我会转到配置文件。

When I setup a sample program and only call "HelloWorld", I get Hello. 当我设置一个示例程序并仅调用“ HelloWorld”时,我会收到Hello。

So the webservice by itself functions. 因此,Web服务本身可以运行。

When on the server I create a test program that uses the same version of EF. 在服务器上时,我创建一个使用相同版本的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. 但是,当我尝试将Web服务与使用EF的方法一起使用时,根本不会发生任何事情。 e.result is string.empty, also no error is returned. e.result为string.empty,也不会返回错误。

How about the error in the web.config file. web.config文件中的错误如何处理。 When I publish the webservice with the original config file. 当我使用原始配置文件发布Web服务时。 I get the following error whe trying to open the webservice directly from the browser of the server: 尝试直接从服务器的浏览器打开Web服务时出现以下错误:

Error 500.19 Config Source: 4: For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 5: 错误500.19 Config来源:4:有关Entity Framework配置的更多信息,请访问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. 显然,它抱怨名称部分为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. 当我将EntityFramework更改为EntityFramework(因此使用大写字母E)时,我可以直接从服务器的浏览器中打开Web服务。 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. 如前所述,HelloWorld可以正常工作,但是尝试通过此Web服务使用EntiTyFramework时仍然存在问题。

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. 我还在此服务器上设置了VS2015,甚至在此服务器上创建了新项目。 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. 在安装此Web服务的服务器上,我将其安装在网站内部的目录中,该网站本身也使用实体框架。

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). IIS从此webserice读取web.config,但在内部将其从根目录添加到web.config(因此从网站将其添加到web.config)。

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). 该网站的IIS中的配置编辑器抱怨第二个条目的名称为EntityFramwork(并且只有当您将这些web.configs组合在一起时,您才能获得此名称。因为每个web.config只有一个条目:entityFramework)。

As I have multiple websites on this server, I simply installed the webservice on a website that doesn't use Entity Framwork. 由于该服务器上有多个网站,因此我只是在不使用实体框架的网站上安装了Web服务。 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. 我希望其他人可以从中受益,这花费了我很多时间来解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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