Could not load file or assembly 'DotNetOpenAuth.Core

102,162

Solution 1

If you don't want use OAuth, remove references: both the WebPages OAuth DLL (I think it's Microsoft.Web.WebPages.OAuth.dll 1) and DotNetOpenAuth DLLs.


1: You can find the filename in Calling assembly. So, removing all calling assembly of DotNetOpenAuth.Core should work for you. This approach should work for other unused missing references.

Solution 2

I had similar problem. It was really strange as the project was running OK a day before.

Removing obj and bin folders from the project folder, cleaning the solution and rebuilding it worked.

Hope that helps.

Solution 3

I've seen this happen when deploying an MVC application as bin deploy. When you right-click on a project and select Add deployable dependencies VS will add the references to Oauth if you check the box next to ASP .NET Webpages with Razor syntax.

To fix this, delete the _bin_deployableAssemblies folder, and your application's bin folder and then clean and rebuild your application and it will work again.

Solution 4

In my case the MVC4 application was running fine in the VS2012 debugger, but I was getting the "Could not load file or assembly 'DotNetOpenAuth.Core'" error when I publish the application on the server.

Checking the "Delete all existing files prior to publish" checkbox on the settings tab of Publish Web window solved the issue.

File System Publishing Settings

Solution 5

I solved the problem by installing the package using Nuget

Install-Package Microsoft.AspNet.WebPages.OAuth
Share:
102,162

Related videos on Youtube

Dimas Longo
Author by

Dimas Longo

Updated on July 08, 2022

Comments

  • Dimas Longo
    Dimas Longo almost 2 years

    I get the following error when I start my asp net mvc 4 application:

    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
    

    This is the error log

    Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
    Running under executable  C:\Windows\SysWOW64\inetsrv\w3wp.exe
    --- A detailed error log follows. 
    
    === Pre-bind state information ===
    LOG: User = notebook\Guilherme
    LOG: DisplayName = DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246
     (Fully-specified)
    LOG: Appbase = file:///C:/Users/Guilherme/Documents/Visual Studio 2012/Projects/Gedi/Gedi/
    LOG: Initial PrivatePath = C:\Users\Guilherme\Documents\Visual Studio 2012\Projects\Gedi\Gedi\bin
    Calling assembly : Microsoft.Web.WebPages.OAuth, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:\Users\Guilherme\Documents\Visual Studio 2012\Projects\Gedi\Gedi\web.config
    LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet.config
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Post-policy reference: DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/2635bb56/154c3fbb/DotNetOpenAuth.Core.DLL.
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/2635bb56/154c3fbb/DotNetOpenAuth.Core/DotNetOpenAuth.Core.DLL.
    LOG: Attempting download of new URL file:///C:/Users/Guilherme/Documents/Visual Studio 2012/Projects/Gedi/Gedi/bin/DotNetOpenAuth.Core.DLL.
    LOG: Attempting download of new URL file:///C:/Users/Guilherme/Documents/Visual Studio 2012/Projects/Gedi/Gedi/bin/DotNetOpenAuth.Core/DotNetOpenAuth.Core.DLL.
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/2635bb56/154c3fbb/DotNetOpenAuth.Core.EXE.
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/2635bb56/154c3fbb/DotNetOpenAuth.Core/DotNetOpenAuth.Core.EXE.
    LOG: Attempting download of new URL file:///C:/Users/Guilherme/Documents/Visual Studio 2012/Projects/Gedi/Gedi/bin/DotNetOpenAuth.Core.EXE.
    LOG: Attempting download of new URL file:///C:/Users/Guilherme/Documents/Visual Studio 2012/Projects/Gedi/Gedi/bin/DotNetOpenAuth.Core/DotNetOpenAuth.Core.EXE.
    

    I have already remove all references from DotNetOpenAuth with packager manager. Also I checked by my self references for every Auth assembly I had in my project and there is none.

    This is my packages.config

    <packages>
      <package id="AutoMapper" version="2.2.0" targetFramework="net45" />
      <package id="EntityFramework" version="5.0.0" targetFramework="net45" />
      <package id="jQuery" version="1.7.1.1" targetFramework="net45" />
      <package id="jQuery.UI.Combined" version="1.8.20.1" targetFramework="net45" />
      <package id="jQuery.Validation" version="1.9.0.1" targetFramework="net45" />
      <package id="knockoutjs" version="2.1.0" targetFramework="net45" />
      <package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net45" />
      <package id="Microsoft.AspNet.Razor" version="2.0.20710.0" targetFramework="net45" />
      <package id="Microsoft.AspNet.Web.Optimization" version="1.0.0" targetFramework="net45" />
      <package id="Microsoft.AspNet.WebApi" version="4.0.20710.0" targetFramework="net45" />
      <package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" targetFramework="net45" />
      <package id="Microsoft.AspNet.WebApi.Core" version="4.0.20710.0" targetFramework="net45" />
      <package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.20710.0" targetFramework="net45" />
      <package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net45" />
      <package id="Microsoft.AspNet.WebPages.Data" version="2.0.20710.0" targetFramework="net45" />
      <package id="Microsoft.AspNet.WebPages.WebData" version="2.0.20710.0" targetFramework="net45" />
      <package id="Microsoft.jQuery.Unobtrusive.Ajax" version="2.0.20710.0" targetFramework="net45" />
      <package id="Microsoft.jQuery.Unobtrusive.Validation" version="2.0.20710.0" targetFramework="net45" />
      <package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net45" />
      <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
      <package id="Modernizr" version="2.5.3" targetFramework="net45" />
      <package id="Newtonsoft.Json" version="4.5.11" targetFramework="net45" />
      <package id="Repository" version="1.0.2.12" targetFramework="net45" />
      <package id="RestSharp" version="103.4" targetFramework="net45" />
      <package id="WebGrease" version="1.1.0" targetFramework="net45" />
    </packages>
    

    Thanks

  • Dimas Longo
    Dimas Longo over 11 years
    This is the problem... there is no reference. Find all "2780ccd10d57b246", Subfolders, Find Results 1, Entire Solution, "" Matching lines: 0 Matching files: 0 Total files searched: 182
  • Dimas Longo
    Dimas Longo over 11 years
    What is the best way to complete remove DotNetOpenAuth* from my project? I have deleted the temp dir, excluded the bin and obj folders, re-built the solution and removed all OpenAuth and OpenID packages using packager manager console... I have no idea what to do now. Also googling by complete remove of DotNetOpenAuth There is no helpful result.
  • Michael Haren
    Michael Haren about 11 years
    This probably worked by purging an oauth-related DLL that was already in your bin/obj folders. Removing the reference and rebuilding wouldn't remove the offending files, but blowing away the directories would.
  • Adrian Smith
    Adrian Smith almost 11 years
    This solved my problem although I was uploading to Azure and the tick box label was 'Remove additional files at destination'.
  • Andranik Hovhannisyan
    Andranik Hovhannisyan almost 11 years
    Had the same issue, oauth dll was added, but no DotNetOauth dll was added. Cleaning didnt work, manually deleting bind and obj folders works. These small, but application-breaking-issues in visual studio are starting to get on my nerves.
  • aked
    aked almost 11 years
    I was trying to Run MSDN - Project Silk . the above steps helped me to solve the problem
  • felickz
    felickz over 10 years
    and Microsoft.Web.WebPages.OAuth.dll from top response above
  • Catto
    Catto over 10 years
    It was helpful to see the reference name Microsoft.Web.WebPages.OAuth.dll since most references started with DotNetOpenAuth. That helped resolve the issue for me. Thank you Ian Li
  • SSP
    SSP over 10 years
    please add content over here
  • Sumurai8
    Sumurai8 over 10 years
    Please do not post link-only answers. Please write out the relevant information from the link in your answer.
  • Kamil Budziewski
    Kamil Budziewski over 10 years
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
  • Andrzej Gis
    Andrzej Gis over 10 years
    Delete all existing files prior to publish really worked. Thanks!
  • chiapa
    chiapa over 9 years
    I have the same problem and deleting those folders doesn't work. I delete them, clean and rebuild the solution, and the issue remains
  • Jerther
    Jerther over 9 years
    instead of deleting the whole _bin_deployableAssemblies folder, just removing the Microsoft.Web.WebPages.OAuth files from there was enough for me. (of course, clean and rebuild was also needed, as well as cleaning the target publishing folder)
  • saiyancoder
    saiyancoder over 9 years
    Such an easy solution should have 1k upvotes! I've been struggling with this for three days, trying to publish to Azure.
  • Mel
    Mel almost 8 years
    this oauth library uses webactivator to initialize so removing the references are not enough, the libraries have to be removed from the bin folder (webactivator enumerates dll files in the folder it was loaded in)
  • wha7ever
    wha7ever over 6 years
    Just like chiapa I had same issue. I deleted bin and obj, cleaned and rebuiled, but issue remained. But then I restarted visual studio and it worked.