【问题标题】:Using command to add an external DLL file as "Reference" in a .NET project使用命令在 .NET 项目中添加外部 DLL 文件作为“参考”
【发布时间】:2019-02-19 14:03:22
【问题描述】:

我有 7 个项目的解决方案。我还有一个可以通过 Visual Studio 添加的外部 DLL:

它在 Visual Studio 中运行良好。 我尝试使用命令行模拟相同的操作,即 Powershell:

Add-Type -Path "D:\ExternalDlls\Scorm.dll"

我收到了这个错误:

Add-Type : 无法加载文件或程序集 'file:///D:\ExternalDlls\Scorm.dll' 或其 de 此程序集之一 由比当前加载的运行时更新的运行时构建,并且不能 被加载。在行:1 字符:9 + 添加类型

我的环境是:

  • Visual Studio 2015(它可以完成任务,但我需要 CLI)
  • Windows 7 - Service Pack1
  • Powershell

【问题讨论】:

    标签: c# .net powershell command-line-interface


    【解决方案1】:

    您能否指定您使用的 .NET 框架版本? 如果 .NET 版本不匹配,也可能出现此错误“此程序集由比当前加载的运行时更新的运行时构建,无法加载”。

    请参考以下参考: "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded"

    另一种可能性是,我们还需要加载其他相关的 dll。

    谢谢,

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多