.Netto-4.6-website nicht laden Reference Assemblies korrekt

Ich habe ein web-Projekt in Visual Studio 2013, einschließlich mehrere library-Projekten bereit.

Problem ist, dass das hinzufügen einer Referenz (dh. System.Sammlung, System.Net), um das web-Projekt Hinzugefügt wird als "Referenz-Assembly" von C:\Program Files (x86)\Reference Assemblies\Microsoft, wenn geladen in IIS ist nicht richtig laden die Umsetzung der Baugruppe (GAC). Beispiel Fehlermeldung folgt.

[BadImageFormatException: Cannot load a reference assembly for execution.]

[BadImageFormatException: Could not load file or assembly 'System.Collections' or one of its dependencies. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
   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) +34
   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) +16
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'System.Collections' or one of its dependencies. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +728
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +196
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +45
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +172
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +111
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +156
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +624

[HttpException (0x80004005): Could not load file or assembly 'System.Collections' or one of its dependencies. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +659
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +189

Löschen der Referenz-dlls aus dem bin-Ordner behebt das Problem, aber ich bin mir nicht sicher, was geändert werden muss um dies zu beheben richtig.

Antwort aktualisiert [unten]
Ich kann eigentlich genau wissen, was Ihr problem ist: Sie muss geprüft Copy Local = true auf Ihrem Verweis auf System.Collections. Und jetzt haben Sie es in den Papierkorb und anderen Orten. Ihre website versucht zu kompilieren eines in bin. So, ja, Antwort unten, kann nur behebt es mit <remove assembly>. Aber wahr fix gesetzt Copy Local = false. Sie in der Regel nicht wollen, um die lokale Kopie jeder System.* Baugruppen.
gute Idee, habe ich überprüft alle Projekte und keines der beanstandeten Verweise gesetzt wurden, um die lokale Kopie
Die Frage bleibt dann. Wie System.Collections kommt in die Tonne? versuchen Sie, ein Gebäude jedes Projekt separat und überprüfen Sie die Ausgabe. Es muss ein Projekt an, kopiert es.
ja, noch ein Problem. Ich denke seine nach unten, um die Ausrichtung .net 4.6. die Standard-Baugruppen in iis 4.0, so würden diese zu stoßen, die Versionen bis (Theorie an diesem Punkt).

InformationsquelleAutor Sam | 2015-09-24

Schreibe einen Kommentar