Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Entity framework EF 6.1使用WCF拦截器的配置_Entity Framework_Wcf - Fatal编程技术网

Entity framework EF 6.1使用WCF拦截器的配置

Entity framework EF 6.1使用WCF拦截器的配置,entity-framework,wcf,Entity Framework,Wcf,我正在尝试使用EF6.1中添加的拦截器功能打开数据库日志记录。当我在ASP.NET web.config文件中打开时,它可以正常工作,但当我尝试在使用EF 6.1的WCF服务中使用时,它会出现以下错误 异常:System.ServiceModel.ServiceActivationException:由于编译期间出现异常,无法激活服务“/DataAccessService.svc”。异常消息是:“System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发了

我正在尝试使用EF6.1中添加的拦截器功能打开数据库日志记录。当我在ASP.NET web.config文件中打开时,它可以正常工作,但当我尝试在使用EF 6.1的WCF服务中使用时,它会出现以下错误

异常:System.ServiceModel.ServiceActivationException:由于编译期间出现异常,无法激活服务“/DataAccessService.svc”。异常消息是:“System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发了异常。更具说明性的消息来自内部异常:无法识别的元素“interceptors”。web.config第123行

注意:根据第一个答案,我将从web.config提供更多元素


.
.
.
您没有注册正确定义
的。换句话说,您是否在配置文件的顶部有此项

<configuration> 
  <configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" 
       type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
  </configSections> 
</configuration>


是的,我已经按照您的描述和您所附链接中的描述注册了实体框架。WCF服务中的数据库调用都会正常运行,直到通过在entityFramework部分的interceptors子部分下包含interceptor元素来注册拦截器为止。正如我所提到的,我对另一个网站使用了完全相同的机制,其中数据库调用是ASP.NET MVC网站的一部分,在这种情况下一切正常。然后我所能想到的就是检查版本号(我相信您已经多次这样做了)。您是否在WCF服务中使用了日志功能?我想知道是否有人让它工作?我将版本号与日志工作的MVC网站中的版本号进行了比较。web.cofig中的版本号是“EntityFramework,version=6.0.0.0”,引用的dll路径是C:\…\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll。在mvcweb.config中,条目是相同的。我很高兴知道是否有人将EF拦截器与WCF一起使用。