2017-05-28 4 views
0

Ich kann nicht scheinen, dieses Problem überall zu finden, wahrscheinlich, weil es so generisch ist.Konnte Datei oder Assembly 'AMS' oder eines seiner Abhängigkeiten nicht laden

Ich habe eine leere asp.net Web-Anwendung in Visual Studio 2017 Community Edition erstellt. Die Anwendung heißt AMS.

Wenn ich debuggen, erhalte ich folgende Fehlermeldung:

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 

Die App ist sehr einfach, so weit. Ich habe Pakete von NuGet für Identiy, EntityFramework, Owin, Owin.Host.SystemWeb, Owin.Security und Owin.Security.Cookies bekommen. Ich habe eine einzelne leere JavaScript-Datei, eine einzelne kurze CSS-Datei und Login und registrieren Aspx-Seite mit einer einzigen MasterPage-Datei mit Links zu der CSS-Datei und Google Content Delivery Network einer JQuery-Datei im Kopfbereich gebunden. Ich habe auch eine Startup.vb erstellt, die die OwinStartup-Assembly lädt und die App so konfiguriert, dass sie die Cookie-Authentifizierung verwendet.

Meine web.config-Datei sieht wie folgt aus:

<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> 

habe ich versucht, so viele Dinge: Neustarten, Visual Studio 2017 neu zu installieren, um das Projekt von Grund auf neu erstellen wieder und Kopieren/Einfügen der Inhalte in Administrator ausgeführt wird , Reinigen, Neuaufbau, Ändern der Ziel-CPU. Der komische Teil ist, dass es manchmal funktioniert, wenn ich die Seite einige Male aktualisiere oder wenn ich das Debuggen einige Male neu starte, aber manchmal kann ich es nie zum Laufen bringen. Und ich kann anscheinend nichts von der Log/Stack-Spur machen.

Ich sollte beachten, dass ich VS2010 Pro, VS2012 Pro und VS2015 Community auch auf meinem Computer installiert habe.

Wenn es hilft, mein PC ist ein AMDx64, Windows 7.

Vielen Dank im Voraus!

UPDATE: enter image description here

+0

haben Sie "Antivirus-Software" auf dem Computer installiert? – Rainmaker

+0

Ja, aber ich hatte es schon immer. Ich habe vor ein paar Monaten ein Web-API-Projekt in VS2015 erstellt und hatte keine der gleichen Probleme. Seither hat sich an meinem Ende nichts geändert, außer dass der neue VS2017 installiert wurde. (Ich habe auch versucht, die App von Grund auf in VS2012 und VS2015 zu erstellen und die gleichen intermittierenden Fehler). – user1422348

Antwort

0

Einige verwiesen Nuget Pakete können verschiedene Versionen derselben Assembly verweisen. In solchen Situationen können Sie sogar erfolgreich die Lösung erstellen, aber beim Debuggen Fehler bekommen. Einige referenzierte Nuget-Pakete können die erforderlichen externen Abhängigkeiten in der Paketbeschreibung übersehen - und sie werden nicht automatisch installiert. Es gibt keine universelle Lösung für dieses Problem außer einer gründlichen Analyse, auf welche Assemblies verwiesen wird und was verpasst/widersprüchlich ist.

Sie finden kann nützlich, um ein Werkzeug, das ich für diese Art der Analyse gemacht: http://www.marss.co.ua/2017/05/reference-conflicts-analyzer-visual.html

Wählen Sie einfach dll Ihre Web-Anwendung eingebaut (ich nehme an, es AMS.dll sein sollte) und die entsprechenden web.config und Sie werden Alle referenzierten Assemblys abrufen

+0

Ich aktualisierte meinen Post mit einem Screenshot der Abhängigkeiten mit Ihrem Tool (sehr cool BTW). Es sieht nicht so aus, als gäbe es Probleme, aber vermisse ich etwas? – user1422348

+0

Alles sieht gut aus. Das Tool ignoriert einige Assemblys und fügt sie nicht in das Diagramm ein, um es einfacher zu halten. Aber das sind Baugruppen, deren Namen mit "System" beginnen. und ich denke, dass die Wahrscheinlichkeit von Konflikten sehr gering ist. Entschuldigung, dass mein Vorschlag nicht hilfreich war. – marss

Verwandte Themen