1

Closed

MVC: Could not load file or assembly 'DotNetOpenAuth.Core,...'

description

Please remove the dependency on DotNetOpenAuth.Core from Microsoft.Web.WebPages.OAuth. Because I don't need to use DotNetOpenAuth on my project.

Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The system cannot find the file specified.

Stack Trace:

[FileNotFoundException: Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The system cannot find the file specified.]
Microsoft.Web.WebPages.OAuth.PreApplicationStartCode.Start() +0

[InvalidOperationException: The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The system cannot find the file specified..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection1 methods, Func1 setHostingEnvironmentCultures) +550
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +90
System.Web.Compilation.BuildManager.ExecutePreAppStart() +135
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516

[HttpException (0x80004005): The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The system cannot find the file specified..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +456
Closed Aug 20, 2012 at 7:36 PM by BradWilson
MVC doesn't have a dependency on OAuth. If you don't want it, remove references to both the WebPages OAuth DLL and the DotNetOpenAuth DLLs via NuGet.

comments

cdunlap wrote Aug 28, 2012 at 10:19 AM

I had this same problem, but realized that I need to clean the solution, delete the Bin directory for the application, and perform a full rebuild.

There were some old assemblies still hanging out in the Bin directory that were no longer referenced but were still being loaded.

Pithecanthropus wrote Mar 31, 2013 at 6:22 AM

@cdunlap, how do I do this? When I rebuild the project the bin directory gets recreated and repopulated. I believe this is happening because I once tried to build a deployable package. At the time I thought it was a sort of ad-lib option I could use or not use as I pleased, but something seems to have "stuck" in my build configuration. Is there any way I can undo it?

joeller wrote Feb 20, 2014 at 5:26 PM

@Dunlap I did this. I also deleted the Account Directory in the views folder, the AccountController.cs file, the references to this in the Web.config the references to this in the packages.config, the packages associated with this, the project references to this, and the assemblies for it in the bin folder. I deleted the project's dll and pdb file from the bin. There is no bin\debug folder or bin\release folder like there used to be.

Yet I am still experiencing this error on the initial page load.

I am using MVC 4.4, EF 5 project template in VS 2012.

joeller wrote Jul 21, 2014 at 2:07 PM

@Dunlap;
Same here. I am using MVC 4.0.30319 Delete every reference to OAuth in the entire project and I am still getting this error.