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

來源:互聯網
上載者:User

標籤:

[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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.