Hi,
I've a WCF application which works fine.
Today I've created a nunit test and got the error below when executing the code. This *only *happen when running the code in a unit test. When the code run via WCF it works fine.
I do NOT use injection mechanism at all, so it's strange.
The code fail on a IIdentity component. I've found several subject that have the same problem (i.e. https://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=15411&HighLight=1) but didn't find any solution.
GetNextActorsForTemplateEntityTest_T1 has failed:
System.TypeInitializationException : The type initializer for 'SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton' threw an exception.
----> System.Runtime.Serialization.SerializationException : Type is not resolved for member 'DF.MyApp.Authentication.CompanyIdentity,DF.MyApp.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=1eb1c673988515c1'.
c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Core\EntityCore.cs(1429, 0) : SD.LLBLGen.Pro.ORMSupportClasses.EntityCore`1.PerformDependencyInjection()
d:\Project\trunk\MyApp\DF.MyApp.Datalayer\DatabaseGeneric\EntityClasses\DfUserEntity.cs(1178, 0) : DF.MyApp.Datalayer.EntityClasses.DfUserEntity.InitClassMembers()
d:\Project\trunk\MyApp\DF.MyApp.Datalayer\DatabaseGeneric\EntityClasses\DfUserEntity.cs(1409, 0) : DF.MyApp.Datalayer.EntityClasses.DfUserEntity.InitClassEmpty(IValidator validator, IEntityFields2 fields)
d:\Project\trunk\MyApp\DF.MyApp.Datalayer\DatabaseGeneric\EntityClasses\DfUserEntity.cs(148, 0) : DF.MyApp.Datalayer.EntityClasses.DfUserEntity..ctor(IEntityFields2 fields)
d:\Project\trunk\MyApp\DF.MyApp.Datalayer\DatabaseGeneric\FactoryClasses\EntityFactories.cs(852, 0) : DF.MyApp.Datalayer.FactoryClasses.DfUserEntityFactory.Create(IEntityFields2 fields)
c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Core\EntityFactoryCore.cs(284, 0) : SD.LLBLGen.Pro.ORMSupportClasses.EntityFactoryCore2.Create()
c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\FastSerialization\EntityFactoryCache2.cs(109, 0) : SD.LLBLGen.Pro.ORMSupportClasses.EntityFactoryCache2.GetEntityFactory(IEntityFactory2 factory)
c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\FastSerialization\EntityFactoryCache2.cs(137, 0) : SD.LLBLGen.Pro.ORMSupportClasses.EntityFactoryCache2.GetEntityFactory(Type factoryType)
d:\Project\trunk\MyApp\DF.MyApp.Datalayer\DatabaseGeneric\EntityClasses\DfUserEntity.cs(1018, 0) : DF.MyApp.Datalayer.EntityClasses.DfUserEntity.CreateEntityFactory()
c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\EntityBase2.cs(221, 0) : SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.CreateFields()
d:\Project\trunk\MyApp\DF.MyApp.Datalayer\DatabaseGeneric\EntityClasses\DfUserEntity.cs(1407, 0) : DF.MyApp.Datalayer.EntityClasses.DfUserEntity.InitClassEmpty(IValidator validator, IEntityFields2 fields)
d:\Project\trunk\MyApp\DF.MyApp.Datalayer\DatabaseGeneric\EntityClasses\DfUserEntity.cs(140, 0) : DF.MyApp.Datalayer.EntityClasses.DfUserEntity..ctor()
d:\Project\trunk\MyApp\DF.MyApp.Tools\MailConvert.cs(324, 0) : DF.MyApp.Tools.MailConvert.Convert(UserData userData)
d:\Project\trunk\MyApp\DF.MyApp.TestCenter\TestDataFactory.cs(275, 0) : DF.MyApp.TestCenter.TestDataFactory.GetMockForUserService()
d:\Project\trunk\MyApp\DF.MyApp.TestCenter\TestDataFactory.cs(570, 0) : DF.MyApp.TestCenter.TestDataFactory.GetUserService()
d:\Project\trunk\MyApp\DF.MyApp.TestCenter\Services\MailServiceTest.cs(2123, 0) : DF.MyApp.TestCenter.Services.MailServiceTest.getServiceForNextActorsTest()
d:\Project\trunk\MyApp\DF.MyApp.TestCenter\Services\MailServiceTest.cs(408, 0) : DF.MyApp.TestCenter.Services.MailServiceTest.GetNextActorsForTemplateEntityTest_T1()
c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\DependencyInjection\DependencyInjectionInfoProvider.cs(274, 0) : SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProvider.Init()
c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\DependencyInjection\DependencyInjectionInfoProvider.cs(122, 0) : SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProvider..ctor()
c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\DependencyInjection\DependencyInjectionInfoProvider.cs(54, 0) : SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton..cctor()
Passed: 0, Failed: 1, Ignored: 0
Duration : 1,18218362090722
The problem happen only if I use a Setup method for my nunit test :
[SetUp]
public void Setup()
{
Thread.CurrentPrincipal = new GenericPrincipal(
new CompanyIdentity("nunit","DB", this.User, this.Company, true, true, null),
new string[]{Role.Admin}
);
}
I've tried to disable NUnit Shadow Copy but it still fail.
Using procmon, I see it's search the dll in the correct directory and found it.
But then, later, it search again for this dll in the nunit's directory, and of course it doesn't find it. Then it search with same name and ".exe" extension, but still in the nunit directory.
I don't understand why the autodiscovery is used ? And why it trigger an error ?
Thank you for any help