1

我将我的解决方案 ElasticSearch.net 和嵌套库升级到 7.1.0 版本。部署代码后,我收到以下错误:

BadImageFormatException: Could not load file or assembly 'netstandard' 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.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +225
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +110
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22
   System.Reflection.Assembly.Load(String assemblyString) +34
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +48

我尝试将库复制到我部署的服务器,但这不起作用。

升级细节:1.)ElasticSearch.net 5.6.1 到 7.1.0

2.)嵌套 5.6.1 到 7.1.0

3.) .NetFramework 4.7.3 已安装

4.) VS2017

从 nuget 包管理器升级。

4

1 回答 1

2

通过在 csproj 文件中手动添加 netstandard 库的引用,问题得到解决,如下所示:

<Reference Include="netstandard">
  <Private>True</Private>
</Reference> 

上述解决方法来自 -您必须添加对程序集 'netstandard, Version=2.0.0.0 的引用

于 2019-09-13T08:54:12.820 回答