首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法加载文件或程序集“AMS”或其依赖项之一

无法加载文件或程序集“AMS”或其依赖项之一
EN

Stack Overflow用户
提问于 2017-05-28 10:48:39
回答 1查看 574关注 0票数 0

我似乎在任何地方都找不到这个问题,可能是因为它太通用了。

我在visual studio 2017社区版中创建了一个空的asp.net web应用程序。应用程序名为AMS。

当我调试时,我得到以下错误:

代码语言:javascript
复制
Could not load file or assembly 'AMS' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'AMS' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'AMS' could not be loaded.


=== Pre-bind state information ===
LOG: DisplayName = AMS
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: AMS | Domain ID: 2
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:/Save_Here/Development/AMS/AMS/AMS/
LOG: Initial PrivatePath = C:\Save_Here\Development\AMS\AMS\AMS\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Save_Here\Development\AMS\AMS\AMS\web.config
LOG: Using host configuration file: C:\Users\Zalmy\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\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/Zalmy/AppData/Local/Temp/Temporary ASP.NET Files/vs/790b60e8/774f1d4b/AMS.DLL.
LOG: Attempting download of new URL file:///C:/Users/Zalmy/AppData/Local/Temp/Temporary ASP.NET Files/vs/790b60e8/774f1d4b/AMS/AMS.DLL.
LOG: Attempting download of new URL file:///C:/Save_Here/Development/AMS/AMS/AMS/bin/AMS.DLL.
LOG: Using application configuration file: C:\Save_Here\Development\AMS\AMS\AMS\web.config
LOG: Using host configuration file: C:\Users\Zalmy\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
ERR: Failed to complete setup of assembly (hr = 0x80070020). Probing terminated.

Stack Trace: 


[FileLoadException: Could not load file or assembly 'AMS' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)]

[FileLoadException: Could not load file or assembly 'AMS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)]
   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.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +21
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'AMS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +738
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531

[HttpException (0x80004005): Could not load file or assembly 'AMS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9963856
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

到目前为止,这个应用程序非常简单。我从NuGet得到了适用于Identiy、EntityFramework、Owin、Owin.Host.SystemWeb、Owin.Security和Owin.Security.Cookies的包。我有一个空的javascript文件,一个简短的CSS文件,以及一个连接到一个MasterPage文件的登录和注册aspx页面,这个文件在标题部分有到CSS文件和Google的内容分发网络的JQuery文件的链接。我还创建了一个Startup.vb,它加载OwinStartup程序集并将应用程序配置为使用Cookie身份验证。

我的web.config文件如下所示:

代码语言:javascript
复制
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
      <add name="DefaultConnection" connectionString="Data Source=Zalmy-PC;Initial Catalog=AMS;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" />
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v13.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

我尝试过很多事情:重新启动、重新安装Visual Studio 2017、从头开始创建项目并复制/粘贴内容、在Administrator中运行、清理、重建、更改目标CPU。奇怪的是,有时如果我多次刷新页面,或者多次重新启动调试,它就会工作,但有时我永远不会让它工作。我似乎不能对日志/堆栈跟踪做任何事情。

我应该注意到,我的计算机上还安装了VS2010专业版、VS2012专业版和VS2015社区。

如果有用的话,我的电脑就是AMDx64和Windows7。

提前感谢!

更新:

EN

回答 1

Stack Overflow用户

发布于 2017-05-29 03:24:07

一些引用的Nuget包可以引用同一程序集的不同版本。在这种情况下,您甚至可以成功构建解决方案,但在调试时开始出现错误。一些引用的Nuget包可能会在包描述中遗漏所需的外部依赖项-并且它们不会自动安装。除了彻底分析引用了什么程序集以及遗漏了什么/冲突之外,对于这个问题没有通用的解决方案。

您可能会发现我为这种类型的分析创建的一个有用的工具:http://www.marss.co.ua/2017/05/reference-conflicts-analyzer-visual.html

只需选择您的web应用程序内置的dll (我假设它应该是AMS.dll)和相应的web.config,您将获得所有引用的程序集。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44223366

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档