Entity Framework and windows.winmd

0

I m developing an Windows 8 application (not Windows store app) using .Net 4 and EF. Everything is working fine until i want to add the Windows.winmd reference. I got the following exception :

System.Data.DataException occurred
  HResult=-2146233087
  Message=An exception occurred while initializing the database. See the InnerException for details.
  Source=EntityFramework
  StackTrace:
       at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
       at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
       at System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c)
       at System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)
       at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action)
       at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
       at System.Data.Entity.Internal.InternalContext.Initialize()
       at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
       at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
       at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
       at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
       at System.Linq.Queryable.OrderBy[TSource,TKey](IQueryable`1 source, Expression`1 keySelector)
       at Yawd.Dal.Dal.getIncludeFolders() in c:\Users\Jeff\Documents\Visual Studio 2010\Projects\Yawd.old\Yawd\Dal\Dal.cs:line 170
  InnerException: System.Data.EntityCommandCompilationException
       HResult=-2146232005
       Message=An error occurred while preparing the command definition. See the inner exception for details.
       Source=System.Data.Entity
       StackTrace:
            at System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)
            at System.Data.EntityClient.EntityProviderServices.CreateCommandDefinition(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)
            at System.Data.EntityClient.EntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
            at System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree)
            at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Span span, ReadOnlyCollection`1 compiledQueryParameters, AliasGenerator aliasGenerator)
            at System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption)
            at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
            at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
            at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
            at System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1[TResult](IEnumerable`1 sequence)
            at System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
            at System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression)
            at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
            at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
            at System.Data.Entity.Internal.EdmMetadataRepository.QueryForModelHash(Func`2 createContext)
            at System.Data.Entity.Internal.InternalContext.QueryForModelHash()
            at System.Data.Entity.Internal.ModelCompatibilityChecker.CompatibleWithModel(InternalContext internalContext, ModelHashCalculator modelHashCalculator, Boolean throwIfNoMetadata)
            at System.Data.Entity.Internal.InternalContext.CompatibleWithModel(Boolean throwIfNoMetadata)
            at System.Data.Entity.Database.CompatibleWithModel(Boolean throwIfNoMetadata)
            at System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context)
            at System.Data.Entity.Internal.InternalContext.<>c__DisplayClass8.<PerformDatabaseInitialization>b__6()
            at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
       InnerException: System.IO.FileLoadException
            HResult=-2146233067
            Message=Could not load file or assembly 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
            Source=mscorlib
            FileName=Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime
            FusionLog=""
            StackTrace:
                 at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
                 at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
                 at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
                 at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
                 at System.Data.Metadata.Edm.MetadataAssemblyHelper.SafeLoadReferencedAssembly(AssemblyName assemblyName)
                 at System.Data.Metadata.Edm.MetadataAssemblyHelper.<GetNonSystemReferencedAssemblies>d__0.MoveNext()
                 at System.Data.Metadata.Edm.ObjectItemCollection.ImplicitLoadViewsFromAllReferencedAssemblies(Assembly assembly)
                 at System.Data.Mapping.StorageMappingItemCollection.ViewDictionary.SerializedCollectViewsFromReferencedAssemblies(MetadataWorkspace workspace, Dictionary`2 extentMappingViews)
                 at System.Data.Mapping.StorageMappingItemCollection.ViewDictionary.SerializedGetGeneratedViews(EntityContainer container)
                 at System.Data.Common.Utils.Memoizer`2.<>c__DisplayClass2.<Evaluate>b__0()
                 at System.Data.Common.Utils.Memoizer`2.Result.GetValue()
                 at System.Data.Common.Utils.Memoizer`2.Evaluate(TArg arg)
                 at System.Data.Mapping.StorageMappingItemCollection.ViewDictionary.GetGeneratedView(EntitySetBase extent, MetadataWorkspace workspace, StorageMappingItemCollection storageMappingItemCollection)
                 at System.Data.Metadata.Edm.MetadataWorkspace.GetGeneratedView(EntitySetBase extent)
                 at System.Data.Query.PlanCompiler.PreProcessor.ExpandView(Node node, ScanTableOp scanTableOp, IsOfOp& typeFilter)
                 at System.Data.Query.PlanCompiler.PreProcessor.ProcessScanTable(Node scanTableNode, ScanTableOp scanTableOp, IsOfOp& typeFilter)
                 at System.Data.Query.PlanCompiler.PreProcessor.Visit(ScanTableOp op, Node n)
                 at System.Data.Query.InternalTrees.ScanTableOp.Accept[TResultType](BasicOpVisitorOfT`1 v, Node n)
                 at System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.VisitNode(Node n)
                 at System.Data.Query.PlanCompiler.SubqueryTrackingVisitor.VisitChildren(Node n)
                 at System.Data.Query.PlanCompiler.SubqueryTrackingVisitor.VisitRelOpDefault(RelOp op, Node n)
                 at System.Data.Query.PlanCompiler.PreProcessor.Visit(ProjectOp op, Node n)
                 at System.Data.Query.InternalTrees.ProjectOp.Accept[TResultType](BasicOpVisitorOfT`1 v, Node n)
                 at System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.VisitNode(Node n)
                 at System.Data.Query.PlanCompiler.SubqueryTrackingVisitor.VisitChildren(Node n)
                 at System.Data.Query.PlanCompiler.SubqueryTrackingVisitor.VisitRelOpDefault(RelOp op, Node n)
                 at System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.VisitSortOp(SortBaseOp op, Node n)
                 at System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.Visit(ConstrainedSortOp op, Node n)
                 at System.Data.Query.InternalTrees.ConstrainedSortOp.Accept[TResultType](BasicOpVisitorOfT`1 v, Node n)
                 at System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.VisitNode(Node n)
                 at System.Data.Query.PlanCompiler.SubqueryTrackingVisitor.VisitChildren(Node n)
                 at System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitDefault(Node n)
                 at System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitPhysicalOpDefault(PhysicalOp op, Node n)
                 at System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.Visit(PhysicalProjectOp op, Node n)
                 at System.Data.Query.InternalTrees.PhysicalProjectOp.Accept[TResultType](BasicOpVisitorOfT`1 v, Node n)
                 at System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.VisitNode(Node n)
                 at System.Data.Query.PlanCompiler.PreProcessor.Process(Dictionary`2& tvfResultKeys)
                 at System.Data.Query.PlanCompiler.PreProcessor.Process(PlanCompiler planCompilerState, StructuredTypeInfo& typeInfo, Dictionary`2& tvfResultKeys)
                 at System.Data.Query.PlanCompiler.PlanCompiler.Compile(List`1& providerCommands, ColumnMap& resultColumnMap, Int32& columnCount, Set`1& entitySets)
                 at System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)
            InnerException: 

If i remove the reference eveything is working fine. If i don't use EF but only Windows.winmd everything is working fine too, but i can't use both in same app.

Any clue on this ?

Thanks for your time.

Jeff

entity-framework
windows-8
asked on Stack Overflow Oct 22, 2012 by myCollections

1 Answer

0

Entity Framework is trying to load all referenced assemblies to check if they contain views. winmd assemblies are not .NET assemblies (as explained here Cannot get types from .winmd file) and therefore fail to load. Having said that - EF should not fail if it encounters an assembly like that - it's a bug.

I filed a bug for this http://entityframework.codeplex.com/workitem/609

This has been fixed for EF6

answered on Stack Overflow Oct 23, 2012 by Pawel • edited May 23, 2017 by Community

User contributions licensed under CC BY-SA 3.0