Exception when using custom IIdentity

Posts   
 
    
GunnarIF
User
Posts: 13
Joined: 29-May-2008
# Posted on: 02-Mar-2009 17:19:02   

Hi! I get this exception after I set the Thread.CurrentPrincipal with my custom IIdentity.

Test method Saga.BusinessLogic.Test.MedicalData.TextView.EncounterViewListTests.GetEncounterViewList_ByPatientInt_Valid threw exception: Csla.DataPortalException: DataPortal.Fetch failed (DataPortal.Update failed (System.TypeInitializationException: The type initializer for 'SD.LLBLGen.Pro.DQE.Oracle.DynamicQueryEngine' threw an exception. ---> System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Saga.Library.Security.SagaIdentity,Saga.Library, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'. at System.AppDomain.get_Evidence() at System.AppDomain.get_Evidence() at System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, String& typeName) at System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath) at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig) at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig) at System.Configuration.ClientConfigurationHost.get_ConfigPaths() at System.Configuration.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord record) 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, Boolean getLkg, Boolean checkPermission) 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 SD.LLBLGen.Pro.DQE.Oracle.DynamicQueryEngine..cctor()

Any ideas?

I'm using version: 2.6.8.72

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 02-Mar-2009 17:32:17   

This happens because the static ctor failed. In that ctor it tries to read values from the application's config file.

It seems the used of the current thread isn't able to read a section because a section defined in the config file (by a reference to a type in some assembly (see your exception)) is not accessable by the user of the thread?

Frans Bouma | Lead developer LLBLGen Pro
GunnarIF
User
Posts: 13
Joined: 29-May-2008
# Posted on: 02-Mar-2009 20:48:04   

I think this happens because the SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProvider is using my custom IIdentity class in a different AppDomain. And therefore is unable to resolve the type because it's not in the GAC.

This is maybe a more meaningful exception:


Test method Saga.BusinessLogic.Test.MedicalData.TextView.EncounterViewListTests.GetEncounterViewList_ByPatientInt_Valid threw exception:  System.TypeInitializationException: The type initializer for 'SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton' threw an exception. --->  System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Saga.Library.Security.SagaIdentity,Saga.Library, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'..

System.AppDomain.get_Evidence()
System.AppDomain.get_Evidence()
System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, String& typeName)
System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath)
System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
System.Configuration.ClientConfigurationHost.get_ConfigPaths()
System.Configuration.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord record)
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
System.Configuration.ConfigurationManager.GetSection(String sectionName)
SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProvider.Init()
SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProvider..ctor()
SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton..cctor()
SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton.PerformDependencyInjection(Object injectionTarget)
SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.PerformDependencyInjection()

This could probably be solved if you fetch all the configuration elements before creating the AppDomain.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 02-Mar-2009 21:15:57   

That's impossible unless you first create an adapter and then an entity in your app. The DI info provider static ctor runs when its type is in scope, which is not set in stone when that happens but likely before the adapter/DQE is used.

Frans Bouma | Lead developer LLBLGen Pro
GunnarIF
User
Posts: 13
Joined: 29-May-2008
# Posted on: 02-Mar-2009 21:24:20   

It appears that there is a bug in MSTest. confused Not with LLBL, sorry for you trouble.

nasser
User
Posts: 12
Joined: 23-Jun-2004
# Posted on: 15-Apr-2009 19:01:56   

I ran into the same problem today, with the following setting: - Project with LLBLGen generated code - Test project (NUnit) - Application project with validation and authorization classes.

I got the error trying to run the test units through the Visual Studio Test Runner while using auto-discovery for the dependency injection. Using manual-discovery solved the problem and I can use the VS Test Runner now.

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 16-Apr-2009 11:56:04   

Thanks for the feedback on this issue.