C# 无法加载文件或程序集“DotNetOpenAuth.Core”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13942653/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 10:10:14  来源:igfitidea点击:

Could not load file or assembly 'DotNetOpenAuth.Core

c#asp.net.netasp.net-mvcasp.net-mvc-4

提问by Dimas Longo

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

当我启动我的 asp net mvc 4 应用程序时出现以下错误:

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.

我已经使用打包管理器从 DotNetOpenAuth 中删除了所有引用。我还通过我的自我引用检查了我项目中的每个 Auth 程序集,但没有。

This is my packages.config

这是我的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

谢谢

采纳答案by Ian Li

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

如果您不想使用 OAuth,请删除引用:WebPages OAuth DLL(我认为是Microsoft.Web.WebPages.OAuth.dll 1)和 DotNetOpenAuth DLL。



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

1:您可以在Calling assembly. 因此,删除所有calling assembly内容DotNetOpenAuth.Core应该对您有用。这种方法应该适用于其他未使用的缺失引用。

回答by Heather

Try doing a global solution search (ctrl+shift+f if you haven't changed it) for the value '2780ccd10d57b246'. I'm guessing you'll find it in your web.config.

尝试对值 '2780ccd10d57b246' 进行全局解决方案搜索(如果您尚未更改,请按 ctrl+shift+f)。我猜你会在你的 web.config 中找到它。

回答by Hyman

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

我在将 MVC 应用程序部署为bin deploy. 当您右键单击一个项目并选择Add deployable dependenciesVS 时,如果您选中旁边的框,VS 将添加对 Oauth 的引用ASP .NET Webpages with Razor syntax

To fix this, delete the _bin_deployableAssembliesfolder, and your application's binfolder and then clean and rebuild your application and it will work again.

要解决此问题,请删除该_bin_deployableAssemblies文件夹和您的应用程序bin文件夹,然后清理并重建您的应用程序,它会再次运行。

回答by Sylwester Gryzio

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.

从项目文件夹中删除 obj 和 bin 文件夹,清理解决方案并重建它。

Hope that helps.

希望有帮助。

回答by Carmen

Remove any Microsoft.Web.WebPages.OAuth dependencies everywhere in your projects.

删除项目中随处可见的任何 Microsoft.Web.WebPages.OAuth 依赖项。

回答by mitaka

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.

在我的例子中,MVC4 应用程序在 VS2012 调试器中运行良好,但是当我在服务器上发布应用程序时出现“无法加载文件或程序集‘DotNetOpenAuth.Core’”错误。

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

选中发布 Web 窗口设置选项卡上的“发布前删除所有现有文件”复选框解决了该问题。

File System Publishing Settings

文件系统发布设置

回答by mLar

I solved the problem by installing the package using Nuget

我通过使用 Nuget 安装包解决了这个问题

Install-Package Microsoft.AspNet.WebPages.OAuth

回答by MuJosh

One more solution option is to have assembly dependency as follows:

另一种解决方案选项是具有程序集依赖性,如下所示:

<dependentAssembly>
  <assemblyIdentity name="DotNetOpenAuth.AspNet"
                    publicKeyToken="2780ccd10d57b246"
                    culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
  <assemblyIdentity name="DotNetOpenAuth.Core"
                    publicKeyToken="2780ccd10d57b246"
                    culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>

回答by Fijjit

In case this helps anyone - I was unable to uninstall the DotNetOpenAuth components through Nuget, so I resolved this error by deleting them from the references list directly and then re-installing dotnetopenauth through nuget.

如果这对任何人有帮助 - 我无法通过 Nuget 卸载 DotNetOpenAuth 组件,因此我通过直接从参考列表中删除它们然后通过 nuget 重新安装 dotnetopenauth 来解决此错误。

回答by user2969674

By installing the following two packages I resolved this problem on VS2012 Professional Update 4 RC:

通过安装以下两个包,我在 VS2012 Professional Update 4 RC 上解决了这个问题:

  1. Open the Package Manager Console from the Menu:

    Tools| Library Package Manage | Package Manager Console

  2. Install-Package DotNetOpenAuth.AspNet

  3. Install-Package Microsoft.AspNet.WebHelpers
  1. 从菜单打开包管理器控制台:

    工具| 库包管理 | 包管理器控制台

  2. 安装包 DotNetOpenAuth.AspNet

  3. 安装包 Microsoft.AspNet.WebHelpers

Hope this helps for you!!!

希望这对你有帮助!!!