2017-10-05 110 views
2

我最近下载了MVC5 ABP模板,该项目编译但我收到了109条警告。在执行该项目时,我得到一个YSOD。无法构建和运行ASP.NET Boilerplate MVC 5模板

  • ABP V3.0.0
  • .Net框架4.6.1
  • 的Visual Studio 2017
  • IIS 7

我得到YSOD以下错误信息:

Cannot load a reference assembly for execution.

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

[BadImageFormatException: Could not load file or assembly 'netfx.force.conflicts' 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) +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 'netfx.force.conflicts' 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) +726 
    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) +677 

[HttpException (0x80004005): Could not load file or assembly 'netfx.force.conflicts' 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) +772 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95 
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +196 

我得到丢失的引用,如约60警告:

The referenced component 'System.Xml.XmlDocument' could not be found. 

,我收到了一些警告这样的:

Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190. 

而且也是这个家伙:

Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: etc. 

展望与VS的解决冲突的建议......没有任何区别,除了删除警告。

+0

删除bin之后,我现在得到81个构建错误,例如'类型'对象'是在未引用的程序集中定义的。您必须添加对程序集'netstandard,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = cc7b13ffcd2ddd51'的引用。' – gareththegeek

回答

1

[BadImageFormatException:无法加载用于执行的参考汇编件。]

删除bin文件夹中的Web项目并重建溶液。

类型'对象'是在未引用的程序集中定义的。您必须添加对程序集“netstandard,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = cc7b13ffcd2ddd51”的引用。

ABP v3.0.0基于.NET标准2.0。

  • 无论您使用的是MVC 5.x,.NET Framework 4.x还是.NET Core 2.x,这都与您有关。
  • 您应该使用VS2017 15.3.3+。
+0

删除bin文件夹的工作方式,但“无法加载文件或程序集'netfx.force.conflicts'”在解决方案中运行另一个控制台项目时,再次发生YSOD,然后重新启动ASP项目。 –

+0

似乎它会在VS 2017.4中修复:https://github.com/dotnet/corefx/issues/23229 –