2017-05-28 117 views
0

我似乎無法在任何地方找到此問題,可能是因爲它非常通用。無法加載文件或程序集「AMS」或它的一個依賴項

我在visual studio 2017社區版中創建了一個空的asp.net web應用程序。該應用程序被命名爲AMS。

當我調試,我得到以下錯誤:

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文件綁定的Login and Register aspx頁面,該文件鏈接到CSS文件並鏈接到頭部的JQuery文件的Google內容交付網絡。我還創建了一個Startup.vb,加載OwinStartup程序集並配置應用程序以使用Cookie身份驗證。

我的web.config文件看起來是這樣的:

<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年,再次從頭開始創建項目和複製/粘貼內容,管理員運行,清理,重建,改變目標CPU。奇怪的部分是,如果我刷新頁面很多次,或者如果重新開始調試很多次,它有時會起作用,但有時候我永遠無法使它工作。我似乎無法做任何日誌/堆棧跟蹤。

我應該注意到我的VS2010 Pro,VS2012 Pro和VS2015社區也安裝在我的電腦上。

如果有幫助,我的電腦是一個AMDx64,Windows 7的

提前感謝!

UPDATE: enter image description here

+0

您是否在計算機上安裝了「防病毒軟件」? – Rainmaker

+0

是的,但我一直都有。幾個月前我在VS2015中創建了一個web api項目,並沒有任何相同的問題。從那時起,除了安裝新的VS2017之外,沒有什麼改變了。 (我也嘗試在VS2012和VS2015中從頭創建應用程序,並得到相同的間歇性錯誤)。 – user1422348

回答

0

一些引用的NuGet軟件包可以參考不同版本的同一總成。在這種情況下,您甚至可以成功構建解決方案,但在調試時會出現錯誤。一些引用的Nuget包可能會錯過包描述中所需的外部依賴關係 - 並且它們不會自動安裝。這個問題沒有通用的解決方案,除了徹底分析什麼程序集被引用以及什麼是錯過/衝突。

您可能會發現有用的工具我這種類型的分析提出:http://www.marss.co.ua/2017/05/reference-conflicts-analyzer-visual.html

只要選擇DLL你的web應用內置的(我認爲它應該是AMS.dll)和相應的web.config文件,你會獲取所有引用的組件。

+0

我使用你的工具(非常酷btw)更新我的帖子與依賴關係的截圖。它看起來不像有問題,但我錯過了什麼? – user1422348

+0

一切看起來不錯。該工具會忽略一些程序集,並且不會將它們包括在圖中以使其更簡單。但是這些是以「系統」開頭的組件。我認爲,與他們有關的衝突的可能性非常低。抱歉,我的建議沒有幫助。 – marss

相關問題