System.Reflection.TargetInvocationException in Silverlight code First Model with DevForce

StackOverflow https://stackoverflow.com/questions/22968830

  •  30-06-2023
  •  | 
  •  

Pregunta

I am using Cocktail, Devforce 2012 7.2.2 and I have a codeFirst model.

When I try to preload my entities using cocktail, one of my entity use an abnormal amount of time to import only 7 entities into my entityManager's cache !! Following to the log below, it takes ~6s to import them.

(DEBUG SL) 16:32:28.187 : MyApp.Common.PreLoadRepository`1:OnManagerCreated : PreLoadRepository<MyApp.Module.Domain.Entities.ModeTraitment>.Seed() imported 0 entites in 0.9998 ms. : ThreadId(1)
(DEBUG SL) 16:32:28.226 : MyApp.Common.PreLoadRepository`1:OnManagerCreated : PreLoadRepository<MyApp.Module.Domain.Entities.Motif>.Seed() imported 23 entites in 33.0001 ms. : ThreadId(1)
(DEBUG SL) 16:32:28.230 : MyApp.Common.PreLoadRepository`1:OnManagerCreated : PreLoadRepository<MyApp.Module.Domain.Entities.Attribut>.Seed() imported 0 entites in 1.0002 ms. : ThreadId(1)
Une exception de première chance de type 'System.NullReferenceException' s'est produite dans MyApp.Module.Domain.tn.SL
Une exception de première chance de type 'System.Reflection.TargetInvocationException' s'est produite dans mscorlib.dll
Une exception de première chance de type 'System.NullReferenceException' s'est produite dans MyApp.Module.Domain.tn.SL
Une exception de première chance de type 'System.Reflection.TargetInvocationException' s'est produite dans mscorlib.dll

...

Une exception de première chance de type 'System.NullReferenceException' s'est produite dans MyApp.Module.Domain.tn.SL
Une exception de première chance de type 'System.Reflection.TargetInvocationException' s'est produite dans mscorlib.dll
(MyApp DEBUG SL) 16:32:34.958 : MyApp.Common.PreLoadRepository`1:OnManagerCreated : PreLoadRepository<MyApp.Module.Domain.Entities.TypeInterv>.Seed() imported 7 entites in 6726.06 ms. : ThreadId(1)
(MyApp DEBUG SL) 16:32:34.972 : MyApp.Common.PreLoadRepository`1:OnManagerCreated : PreLoadRepository<MyApp.Module.Domain.Entities.TypeIdentity>.Seed() imported 2 entites in 10.0012 ms. : ThreadId(1)

All the exception shown in the logs happen during the execution of : entityManager.ImportEntities(entities, MergeStrategy.OverwriteChanges) on this entity : TypeInterv

This entity use TPH. TypeInterv inherit of a base class named RefenceBase. The Preloader also loads many entities which also inherit of this base class (ModeTraitment, Attribut, ...) without any problem !

The entity looks like this :

[DataContract(IsReference = true)]
public class TypeInterv : ReferenceBase
{
    [DataMember]
    [Required]
    public bool ForProf { get; set; }

    [DataMember]
    [Required]
    [Taux]
    public decimal TauxRet { get; set; }

    [DataMember]
    public RelatedEntityList<Tarif> Tarif { get { return null; } }
}

I tried to cleanup the entity to find out what could be the issue. If I remove the RelatedEntityList I still get the exceptions and the excessive execution time. If I remove the TWO properties (only one doesn't fix it), I no longer get the exceptions and the entities imports in 7ms.

What could cause the issue ? I am guessing something related to the code injected by postsharp ?

Note : The entity have a basic Configuration class :

public class TypeIntervConfiguration: EntityTypeConfiguration<TypeInterv>
{
    public TypeIntervConfiguration()
    {
        Map(e =>
                {
                    e.ToTable(Cst.Tables.TblReferenceBase);
                    e.Requires(Cst.Fields.Discriminant)
                        .HasValue(Cst.ReferenceBase.DiscriminantTypeInterv);
                });

        Property(p => p.ForProf)
            .HasColumnName(Cst.Fields.TypeIntervForProf);
        Property(p => p.TauxRet)
            .HasColumnName(Cst.Fields.TypeIntervTauxRet);
    }
}

The attribute Taux is an EF Convention (I tried to test without the attribut and it doesn't fix it)

public class TauxConvention: Convention
{
    /// <summary>
    /// Constructeur
    /// </summary>
    public TauxConvention()
    {
        this.Properties()
            .Where(x => x.GetCustomAttributes(false).OfType<TauxAttribute>().Any())
            .Configure(c => c.HasPrecision(18, 8));
    }
}

Any idea ?

¿Fue útil?

Solución

A response to this issue can be found on DevForce forum

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top