84

启动我的 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

这是错误日志

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.

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

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

谢谢

4

19 回答 19

82

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


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

于 2012-12-19T01:57:20.147 回答
78

我有类似的问题。这真的很奇怪,因为该项目在前一天运行良好。

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

希望有帮助。

于 2013-02-08T17:03:42.953 回答
22

我在将 MVC 应用程序部署为bin deploy. 当您右键单击项目并选择Add deployable dependenciesVS 时,如果您选中ASP .NET Webpages with Razor syntax.

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

于 2013-02-04T18:02:55.547 回答
16

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

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

文件系统发布设置

于 2013-04-18T13:19:23.573 回答
12

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

Install-Package Microsoft.AspNet.WebPages.OAuth
于 2013-07-11T09:20:09.143 回答
4

只需在发布设置上选择“在目标位置删除其他文件”。这对我有用

于 2014-07-09T18:49:00.023 回答
3

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

  1. 从菜单中打开包管理器控制台:

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

  2. 安装包 DotNetOpenAuth.AspNet

  3. 安装包 Microsoft.AspNet.WebHelpers

希望这对你有帮助!!!

于 2013-11-08T16:22:26.007 回答
2

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

于 2012-12-18T22:59:33.393 回答
2

对我来说,它的工作方式如下,使用打包管理器控制台,我已经按照以下顺序卸载了软件包,然后我重新安装了它,它解决了我的问题..

卸载

Uninstall-Package Microsoft.AspNet.WebPages.OAuth
Uninstall-Package DotNetOpenAuth.AspNet 
Uninstall-Package DotNetOpenAuth.OpenId.RelyingParty
Uninstall-Package DotNetOpenAuth.OpenId.Core 
Uninstall-Package DotNetOpenAuth.OAuth.Consumer
Uninstall-Package DotNetOpenAuth.OAuth.Core
Uninstall-Package DotNetOpenAuth.core

构建,如果您没有使用上述软件包,那么这应该可以解决问题,如果需要再次安装上述软件包,请执行以下操作..

重新安装

install-Package DotNetOpenAuth.AspNet 
install-Package Microsoft.AspNet.WebPages.OAuth
install-Package DotNetOpenAuth.OpenId.RelyingParty
install-Package DotNetOpenAuth.OpenId.Core 
install-Package DotNetOpenAuth.OAuth.Consumer
install-Package DotNetOpenAuth.OAuth.Core
install-Package DotNetOpenAuth.core

推荐:

  • 进入项目的bin文件夹,清空
  • 何时发布到 IIS,删除虚拟目录并将网站再次分配给 IIS,因为我遇到了服务器中有现金的问题,这导致了问题......
于 2014-05-04T06:45:10.080 回答
1

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

<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>
于 2013-10-14T05:47:54.487 回答
1

我没有评论的声誉,但我可以确认我遇到了这个确切的问题,并且 Jack 为我提供了正确的解决方案。我最近按下了添加服务引用,它用上述错误消息破坏了程序。

删除 _bin_deployableAssemblies 文件夹和应用程序的 bin 文件夹,然后清理并重建应用程序使其再次工作。

于 2014-01-17T14:19:51.533 回答
0

我也遇到了这个错误,但是使用的是 ASP.NET MVC 5 项目。我通过安装 Package DotNetOpenAuth.Mvc5 并调用 AsActionResultMvc5() 而不是 AsActionResult() 解决了这个问题

于 2014-04-24T09:03:15.807 回答
0

我在这里遇到了同样的问题。我发布的 web.config 没有以下行:

  <dependentAssembly>
    <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
    <bindingRedirect oldVersion="1.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
  </dependentAssembly>

刚刚添加,它的工作。

于 2015-03-03T12:51:33.953 回答
0

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

于 2013-10-14T17:51:57.983 回答
0

对我来说,帮助将以下部分添加到 csproj 文件中:

<PropertyGroup>
   <PostSharpHostConfigurationFile>web.config</PostSharpHostConfigurationFile>            
</PropertyGroup>
于 2014-08-08T20:12:18.320 回答
0

我在更新我们所有的库时遇到了这个问题。这个链接帮助我解决了这个问题。https://www.devexpress.com/Support/Center/Question/Details/Q554890/the-could-not-load-file-or-assembly-dotnetopenauth-core-version-4-0-0-0-error-消息是.

特别是我将这些绑定重定向添加到我的 web.config 文件中。

      <dependentAssembly>
    <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780CCD10D57B246" culture="neutral" />
    <bindingRedirect oldVersion="1.0.0.0-4.1.0.0" newVersion="4.3.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780CCD10D57B246" culture="neutral" />
    <bindingRedirect oldVersion="1.0.0.0-4.1.0.0" newVersion="4.3.0.0" />
  </dependentAssembly>
于 2019-06-03T16:47:57.863 回答
0

只需从 wwwroot 中删除 BIN 文件夹,然后再次发布。

于 2015-10-06T13:31:02.983 回答
0

我能够通过删除 Microsoft.AspNet.Membership.OpenAuth 最终解决它

于 2016-03-27T07:14:28.127 回答
-2

删除项目中所有位置的任何 Microsoft.Web.WebPages.OAuth 依赖项。

于 2013-04-17T15:01:44.497 回答