Could not load file or assembly 'Microsoft.AspNet.Scaffolding.12.0' or one of its dependencies

0

After pulling an old project down from source control and attempting to run it, I'm getting the following error:

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.AspNet.Scaffolding.12.0
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Microsoft.AspNet.Scaffolding.12.0 | Domain ID: 3
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/PROJECTS/C.App/
LOG: Initial PrivatePath = C:\PROJECTS\C.App\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\PROJECTS\C.App\web.config
LOG: Using host configuration file: C:\Users\C\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/C/AppData/Local/Temp/Temporary ASP.NET Files/vs/566b0c0d/a2911b5/Microsoft.AspNet.Scaffolding.12.0.DLL.
LOG: Attempting download of new URL file:///C:/Users/C/AppData/Local/Temp/Temporary ASP.NET Files/vs/566b0c0d/a2911b5/Microsoft.AspNet.Scaffolding.12.0/Microsoft.AspNet.Scaffolding.12.0.DLL.
LOG: Attempting download of new URL file:///C:/PROJECTS/C.App/bin/Microsoft.AspNet.Scaffolding.12.0.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

What could be causing this?

I've tried:

  • Deleting bin/obj/Resharper Cache
  • Restarting VS
  • Looking for the dll and finding it here but I'm unable to load it as a reference for some reason; Visual Studio won't show it in File Explorer
  • Searching for it on Nuget
  • Finding out why this is even needed but I don't see any references in any files

I'm using IISExpress; this is localhost and the error is appearing when I run the app in Release and Debug modes (classic yellow ASP.Net error).

Full stack trace:

[BadImageFormatException: Could not load file or assembly 'Microsoft.AspNet.Scaffolding.12.0' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +225
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +110
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22
   System.Reflection.Assembly.Load(String assemblyString) +34
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +48

[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.AspNet.Scaffolding.12.0' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +729
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +247
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +157
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +226
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +73
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +321
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +170
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +734

[HttpException (0x80004005): Could not load file or assembly 'Microsoft.AspNet.Scaffolding.12.0' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +118
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +708
c#
asp.net
asp.net-mvc
visual-studio
visual-studio-2015
asked on Stack Overflow Jul 18, 2018 by Mick R • edited Jul 18, 2018 by Mick R

2 Answers

1

Please double check that 64-Bit IISExpress is not being run in Visual Studio

Go to: Tools -> Options -> Project and Solutions -> Web Projects

uncheck "Use 64-bit IIS Express"

answered on Stack Overflow Jul 18, 2018 by Victor Procure
0

Check the version of Microsoft.AspNet.Scaffolding in packages.config and see if it is different then the version of your DLL. Correct the version in packages.config if its incorrect.

answered on Stack Overflow Jul 20, 2018 by Bishal Th.

User contributions licensed under CC BY-SA 3.0