Data Platform Developer Center > Data Platform Development Forums > ADO.NET Entity Framework and LINQ to Entities > FileNotFoundException on constructor for ADO.NET Entity Model
Ask a questionAsk a question
 

AnswerFileNotFoundException on constructor for ADO.NET Entity Model

  • Thursday, September 25, 2008 2:53 PMLaila21 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi guys,

    I'm using EF for the first time in a project, and it worked ok until now... We had a change in our database, so I regenerated the model. Now I'm getting the following error when I try to intialize the model:

    Could not load file or assembly 'System.Drawing, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.":"System.Drawing, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

    This is the StackTrace:
       at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
       at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
       at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       at System.Reflection.Assembly.ReflectionOnlyLoad(String assemblyString)
       at System.Data.Metadata.Edm.DefaultAssemblyResolver.GetAllDiscoverableAssemblies()
       at System.Data.Metadata.Edm.DefaultAssemblyResolver.GetWildcardAssemblies()
       at System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
       at System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource..ctor(String originalPath, String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
       at System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.CreateResourceLoader(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
       at System.Data.Metadata.Edm.MetadataArtifactLoader.Create(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)
       at System.Data.Metadata.Edm.MetadataArtifactLoader.Create(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry)
       at System.Data.EntityClient.EntityConnection.SplitPaths(String paths)
       at System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections)
       at System.Data.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection()
       at System.Data.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor)
       at System.Data.Objects.ObjectContext..ctor(String connectionString)
       at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
       at BR_Prestatiemodule.Data.PrestationEntities..ctor()

    I have no idea what might cause this kind of exception right now. I've even tried throwing away the whole model and making a new one... Nothing.

    Any ideas?

    Thanks in advance!

Answers

  • Friday, September 26, 2008 9:29 PMCraig Lee - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Please see this article on MSDN:

     

    http://msdn.microsoft.com/en-us/library/cc716756.aspx

     

    About half-way down you will see a section about how the metadata= part of the entity connection string is built.  

     

    I assume that you have chosen to have the runtime artifacts embedded as resources (right click on a blank area in the designer, choose properties, look at the property window).

     

    There is a note in the above MSDN page that outlines the effect of keeping the default "res://*" value that the designer writes out.  In your case, you should change this so that it uses explicit paths.  I suspect that because you have "res://*", the EF runtime is scanning your DLL and all referenced DLLs for any EF runtime artifacts.

All Replies

  • Thursday, September 25, 2008 5:33 PMsravanik Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    • Could you add more details on the exact steps that you took that led to this error. When you say you regenrated the model, did you do an "update Model From Database" on your "Edmx" file in the project ?
    • "I've even tried throwing away the whole model and making a new one... Nothing. "
      Does this mean that any time you go to the "Add New Item" menu and select "ADO.NET Entity Data Model" template you get this error ?

     

  • Friday, September 26, 2008 2:48 AMLucas F. Zacutti Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    hello, i m having the same problem..

    everything was working ok until i have installed vs 2008 sp1..

    after that, this error occur..

    "Could not load file or assembly 'System.Drawing, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies"

    I have not done any code modification..

    Someone knows what happen ?

     

    Thanks.. Lucas

     

  • Friday, September 26, 2008 3:48 AMLucas F. Zacutti Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    hello Laila, after several probing thing, finally i have solved my problem.. i tell you the solution, in my project i used Infragistics controls (UI).. when removed this references, everything work fine..

    so, i think is a problem with some reference in your project.. but, .. this worked for me, now you may try and then you'll tell me...

     

    saludos.

     

     

  • Friday, September 26, 2008 1:06 PMLaila21 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Wel, it's true I'm using an external API, Aspose.

    About my model, i did try to regenerate it in both way you specified.

    I just tried out to throw out the Aspose DLL and everything is working again.
    But it just can't be possible that I can't use EF in combination with an external API!!!!?

    What do you think?
  • Friday, September 26, 2008 8:00 PMsravanik Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I'm having trouble repro'ing your scenario.

    Could you clarify the following

    1) What kind of project were you using ?

    2) Are you running against VS 2008 SP1 RTM ?

    3) Are you running the correct version of Aspose (You will need to run with Aspose version for .NET Fx 3.5). I'm curious about what kind of Aspose dll you are running with?

  • Friday, September 26, 2008 9:29 PMCraig Lee - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Please see this article on MSDN:

     

    http://msdn.microsoft.com/en-us/library/cc716756.aspx

     

    About half-way down you will see a section about how the metadata= part of the entity connection string is built.  

     

    I assume that you have chosen to have the runtime artifacts embedded as resources (right click on a blank area in the designer, choose properties, look at the property window).

     

    There is a note in the above MSDN page that outlines the effect of keeping the default "res://*" value that the designer writes out.  In your case, you should change this so that it uses explicit paths.  I suspect that because you have "res://*", the EF runtime is scanning your DLL and all referenced DLLs for any EF runtime artifacts.

  • Friday, September 26, 2008 10:48 PMLucas F. Zacutti Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    hello Craig,
    i think there is something to review because this behavior cause problem when i use thrid party components.. maybe them (Infragistics) have have a new version of the component, but in several cases i need to pay for those releases ..

     

    thanks. Lucas

  • Wednesday, October 01, 2008 3:13 PMLaila21 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Well, Aspose is an earlier version, but I don't consider that a reason.
    This version of Aspose works fine in all .NET 3.5 SP1 applications, except when I'm using EF and have a model I instantiate in my code.

    On the other side, it doesn't seem completly right you have to upgrade all your third-party libraries (with the necessary costs) because you want to upgrade to a newer version of the .NET framework?

    Thanks for your feedback!