none
Assembly Load Error with Entity Framework 4 - ExecuteStoreQuery RRS feed

  • Question

  • A .Net 4 / Entity Framework 4 / MVC 3 application which has been deployed and working for years has started to error when attempting to call context.ExecuteStoreQuery functions with the following message:

    System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
    File name: 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
       at DynamicModule.ns.Wrapped_DatesUTCStorageLocalizedOutput_6497cf775e6a4fa9b39c4f3852aae624.CurrentDateTimeUTC()
       at Service.BackgroundScheduler.Job.TimerEntryPoint(Object State)

    The application does not reference MVC4.

    My best guess as to the internal cause of the error is ObjectContext.ExecuteStoreQueryInternal->this.MetadataWorkspace.ImplicitLoadAssemblyForType(....

    which eventually looks to call ObjectItemCollection.ImplicitLoadAllReferencedAssemblies, which seems to be trying to load all referenced assemblies.  

    How can I determine the assembly that is causing this problem? And is the correct fix to deploy System.Web.MV (v4) with my app?

    Where the application works: My Development PC, DEV Web Server (2012 Server), STAGE Web Servers, PROD Web Servers

    Where the issue occurs: DEV Web Server (2008 Server)

    Already completed:
    1)WinDiff of applications between environments reveals no differences
    2) Multiple  server / IIS restarts
    3) Turned on FusionLogging on working systems and broken system.  Only broken system attempts to load MVC4 dlls and the FusionLog  Calling Assembly is listed as (Unknown).

    Monday, June 26, 2017 2:35 PM

Answers

  • Issue was related to SCOM 2016 and is a known bug, we resolved this issue by removing the APM component.

    The comments at the bottom describe some of the same issues.
    https://blogs.technet.microsoft.com/kevinholman/2017/05/27/ur3-for-scom-2016-step-by-step/

    • Marked as answer by Andrew Pierro Tuesday, June 27, 2017 6:01 PM
    Tuesday, June 27, 2017 6:01 PM

All replies

  • Well, this is not an EF issue. You have MVC issues with a Web MVC DLL. You have application configuration issues with DLL(s),  because somehow and someway a developer's machine maybe picked up the version 4 DLL, and it was complied into the executables. The reference to the DLL is not going to get there any other way other than a reference was set to the DLL and the solution was compiled using the version 4 DLL, as stated in the manifest.
    Monday, June 26, 2017 6:50 PM
  • I hear what you are saying.  Could you please help me understand how the Fusion Assembly Load Logs on my DEV box do NOT show any attemp (fail or success) for the System.Web.MVC V4 file?
    Monday, June 26, 2017 6:54 PM
  • I hear what you are saying.  Could you please help me understand how the Fusion Assembly Load Logs on my DEV box do NOT show any attemp (fail or success) for the System.Web.MVC V4 file?

    Your DLL's on your DEV box and the DLL(s) on Win 2k8 server are two different things. It's the Win 2k8 server that you need to investigate.

    Maybe, you use something like Dependency Walker. Maybe, you use something like Process Explorer to look at what DLL(s) are being used, their file paths, at time of application execution.

    https://en.wikipedia.org/wiki/Dependency_Walker

    https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx?f=255&MSPPError=-2147217396

    https://docs.microsoft.com/en-us/dotnet/framework/app-domains/assembly-manifest

    Monday, June 26, 2017 7:26 PM
  • But how can it work one place with no loading of MVC4 DLLs and require them on another server?
    Monday, June 26, 2017 9:01 PM
  • Hi Andrew Pierro,

    According to your description, it seems that the application could not MVC dll file, I would suggest that you could migrate mvc3 to mvc4 or high version project.

    And the following link about migrating mvc3 to mvc4 for your reference.

    http://www.c-sharpcorner.com/UploadFile/amit12345/how-to-upgrade-mvc-3-to-mvc4/

    In addition, since the issue is a asp.net MVC, you could also post your issue on asp.net mvc forum for support.

    https://forums.asp.net/1146.aspx/1?MVC

    Best regards,

    Cole Wu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 27, 2017 10:21 AM
    Moderator
  • But how can it work one place with no loading of MVC4 DLLs and require them on another server?

     You'll have to figure that out.

    As mentioned, there is a mvc section in the ASP.NET forum.

    Tuesday, June 27, 2017 10:44 AM
  • Issue was related to SCOM 2016 and is a known bug, we resolved this issue by removing the APM component.

    The comments at the bottom describe some of the same issues.
    https://blogs.technet.microsoft.com/kevinholman/2017/05/27/ur3-for-scom-2016-step-by-step/

    • Marked as answer by Andrew Pierro Tuesday, June 27, 2017 6:01 PM
    Tuesday, June 27, 2017 6:01 PM