System.Security.SecurityException The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception

[15/08/19 00:03:10]	[DataManager-7292-ERROR]	System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.TypeInitializationException: The type initializer for ‘System.Data.Entity.Internal.AppConfig‘ threw an exception.
 ---> System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for entityFramework: Request failed. (D:\LST\LenovoSmartToolSrv.exe.Config line 8)
 ---> System.Security.SecurityException: Request failed.
   at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, RuntimeMethodHandleInternal method, RuntimeType parent, UInt32 invocationFlags)
   at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, IRuntimeMethodInfo method, RuntimeType parent, UInt32 invocationFlags)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
   at System.Configuration.TypeUtil.InvokeCtorWithReflectionPermission(ConstructorInfo ctor)
   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)
   --- End of inner exception stack trace ---
   at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
   at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.Data.Entity.Internal.AppConfig..ctor()
   at System.Data.Entity.Internal.AppConfig..cctor()
   --- End of inner exception stack trace ---
   at System.Data.Entity.Internal.AppConfig.get_DefaultInstance()
   at System.Data.Entity.Internal.LazyInternalConnection..ctor(DbContext context, String nameOrConnectionString)
   at System.Data.Entity.DbContext..ctor(String nameOrConnectionString)
   at DataAccessor.FireBirdDataManger.<>c__DisplayClass76.<DeleteTechnicalAndNotice>b__73()
   --- End of inner exception stack trace ---

Server stack trace:
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Data.Entity.Utilities.TypeExtensions.CreateInstance[T](Type type, Func`2 exceptionFactory)
   at System.Data.Entity.Utilities.TypeExtensions.CreateInstance[T](Type type, Func`3 typeMessageFactory, Func`2 exceptionFactory)
   at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.<.ctor>b__1()
   at System.Lazy`1.CreateValue()

Exception rethrown at [0]:
   at System.Lazy`1.get_Value()
   at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.GetConfiguration()
   at System.Data.Entity.Core.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
   at System.Data.Entity.Core.EntityClient.EntityConnection..ctor(String connectionString)
   at System.Data.Entity.Core.Objects.ObjectContext.CreateEntityConnection(String connectionString)
   at DataAccessor.FirebirdDataAccessorEntities..ctor()
   at DataAccessor.FireBirdDataManger.<>c__DisplayClass28`1.<Select>b__27()

  今天遇到了一个bug,通过现场复现,出现此bug的根源是测试手动更换了配置文件,而配置文件是通过skyp传输的,也就是通过网络获取的(通过网络获取是关键),此时配置文件Security为"Block"状态,正常情况下,是直接安装不会出现此情况,如图

当Frameworks读取app.config时,security check失败

手动“Unblock”,客户端一切运行正常

当发现此bug时,我们通过其他多台不同操作系统电脑多次尝试复现,均无法复现,而在出现此bug电脑,100%复现,所以我们一致认为这个和操作系统当前设置的安全级别有关,至于是不是这个原因,我们没继续去验证,因为我们已经认为它不是一个bug了

System.Security.SecurityException The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception

时间: 2024-10-24 00:51:17

System.Security.SecurityException The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception的相关文章

The type initializer for &#39;System.Data.Entity.Internal.AppConfig&#39; threw an exception.

当使用EF时,配置文件中会多出下面的配置代码: <configSections> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <section name="entityFramework" type="System.Data.Entity.Internal.C

System.Data.Entity.Internal.AppConfig 类型初始值设定项引发异常

在一开始时将connectionStrings 写在了configSections之上如下图一示,结果抛出:“System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发异常. 图一:最初配置 图二:抛出异常 解决方法,是将connectionStrings 写在了configSections之下,如图三 图三:调整后的配置

使用EF访问数据库,出现“System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发异常。

今天在使用的EF时候,发生了"System.Data.Entity.Internal.AppConfig"的类型初始值设定项引发异常.这样的一个错误 查了原因,原来是appconfig中,connectionStrings的位置放错了.因为configSections必须是appconfig的第一个节点 这样是不对的. 应该是 感觉这种情况应该不仅仅只限于这个EF,只要configSections不是第一个标签就会有问题,也适用于其他情况~~

“System.Data.Entity.Internal.AppConfig&quot;的类型初始值设定项引发异常。{转}

<connectionStrings> <add name="ConnectionStringName" providerName="System.Data.SqlClient" connectionString="Data Source=.;Initial Catalog=DataBaseName;Integrated Security=True;Pooling=False" /> </connectionStri

System.Data.Entity.Internal.AppConfig的类型初始值设定项引发异常

使用Entity的时候遇到的一个错 问题出在项目的App.config中 解决: 1.configSections要写在最顶端 2. 其中的incariantName会变成incariantNodeName 这个是安装Entity的时候自动生成的,你如果记得这句话,直接换成incariantName,或者卸载EF重新安装 3.如果你项目还引用了其他安装EF的项目 providerName可能被更改为providerNodeName,改回来即可 用了EF有几个月了,但是今天也是第一次遇到这问题,没

debian The type initializer for &#39;System.Drawing.KnownColors&#39; threw an exception

Change the "System.Drawing" reference of "CoreCompat.System.Drawing"if you throw The type initializer for 'System.Drawing.KnownColors' threw an exception to do:apt-get install libgdiplus debian The type initializer for 'System.Drawing.

System.Security.SecurityException The source was not found, but some or all event logs could not be searched.Inaccessible logs Security.

An exception occurred during the Install phase. System.Security.SecurityException The source was not found, but some or all event logs could not be searched.Inaccessible logs Security. 解决方法:使用管理员权限再次运行程序即可.

System.Security.SecurityException: System.Web.AspNetHostingPermission

今天部署一个网站,在net 4.0下面正常,但是在2.0下面发现有错误:System.Security.SecurityException,错误信息如下所示: 安全性异常 说明: 应用程序试图执行安全策略不允许的操作.要授予此应用程序所需的权限,请与系统管理员联系,或在配置文件中更改该应用程序的信任级别. 异常详细信息: System.Security.SecurityException: 请求“System.Web.AspNetHostingPermission, System, Versio

Windows服务安装异常:System.Security.SecurityException: 未找到源,但未能搜索某些或全部事件日志。不可 访问的日志: Security

原文地址:http://blog.csdn.net/joyhen/article/details/42262305 2种方法处理: 一.右键单击“以管理员身份运行”Visual Studio Command Prompt即可 二.以管理员身份运行vs,然后打开项目,再执行InstallService程序安装服务. 附:具体构建windows 服务,可以看看这篇文章:http://www.cnblogs.com/LoveJenny/archive/2013/03/05/2943691.html